br.ufg.integrate.wrapper.csv
Class CSVReaderAdapter

java.lang.Object
  extended by br.ufg.integrate.wrapper.csv.CSVReaderAdapter
Direct Known Subclasses:
CsvReader, CSVScrollableReader

public abstract class CSVReaderAdapter
extends Object

This class an abstract class that contains the common functionality of the Scrollable and Non Scrollable Reader

Version:
$Id: CSVReaderAdapter.java,v 1.3 2007/09/19
Author:
Jonathan Ackerman, Sander Brienen, Stuart Mottram (fritto), Jason Bedell, Tomasz Skutnik, Chetan Gupta, Rogerio Arantes Gaioso

Field Summary
protected  String buf
           
protected  String charset
           
protected  String[] columnNames
           
protected  String[] columns
           
protected  String fileName
           
protected  char separator
           
protected  boolean suppressHeaders
           
protected  String tableName
           
 
Constructor Summary
CSVReaderAdapter()
           
 
Method Summary
 boolean absolute(int row)
          Moves the cursor to the given row number in this ResultSet object.
 void afterLast()
          Moves the cursor to the end of this ResultSet object, just after the last row.
 void beforeFirst()
          Moves the cursor to the front of this ResultSet object, just before the first row.
abstract  void close()
           
 boolean first()
          Moves the cursor to the first row in this ResultSet object.
 String getColumn(int columnIndex)
          Get the value of the column at the specified index.
 String getColumn(String columnName)
          Get value from column at specified name.
 String[] getColumnNames()
          Gets the columnNames attribute of the CsvReader object
 int getLineCount()
          Retorna a quantidade de linhas (para consultas do tipo COUNT(*).
 int getRow()
          Retrieves the current row number.
 String getTableName()
           
 boolean isAfterLast()
          Retrieves whether the cursor is after the last row in this ResultSet object.
 boolean isBeforeFirst()
          Retrieves whether the cursor is before the first row in this ResultSet object.
 boolean isFirst()
          Retrieves whether the cursor is on the first row of this ResultSet object.
 boolean isLast()
          Retrieves whether the cursor is on the last row of this ResultSet object.
 boolean last()
          Moves the cursor to the last row in this ResultSet object.
abstract  boolean next()
           
protected abstract  String[] parseCsvLine(String line)
           
 boolean previous()
          Moves the cursor to the previous row in this ResultSet object.
 boolean relative(int rows)
          Moves the cursor a relative number of rows, either positive or negative.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

columnNames

protected String[] columnNames

columns

protected String[] columns

buf

protected String buf

separator

protected char separator

suppressHeaders

protected boolean suppressHeaders

tableName

protected String tableName

fileName

protected String fileName

charset

protected String charset
Constructor Detail

CSVReaderAdapter

public CSVReaderAdapter()
Method Detail

absolute

public boolean absolute(int row)
                 throws SQLException
Moves the cursor to the given row number in this ResultSet object.

If the row number is positive, the cursor moves to the given row number with respect to the beginning of the result set. The first row is row 1, the second is row 2, and so on.

If the given row number is negative, the cursor moves to an absolute row position with respect to the end of the result set. For example, calling the method absolute(-1) positions the cursor on the last row; calling the method absolute(-2) moves the cursor to the next-to-last row, and so on.

An attempt to position the cursor beyond the first/last row in the result set leaves the cursor before the first row or after the last row.

Note: Calling absolute(1) is the same as calling first(). Calling absolute(-1) is the same as calling last().

Parameters:
row - the number of the row to which the cursor should move. A positive number indicates the row number counting from the beginning of the result set; a negative number indicates the row number counting from the end of the result set
Returns:
true if the cursor is on the result set; false otherwise
Throws:
SQLException - if a database access error occurs, or the result set type is TYPE_FORWARD_ONLY

afterLast

public void afterLast()
               throws SQLException
Moves the cursor to the end of this ResultSet object, just after the last row. This method has no effect if the result set contains no rows.

Throws:
SQLException - if a database access error occurs or the result set type is TYPE_FORWARD_ONLY

beforeFirst

public void beforeFirst()
                 throws SQLException
Moves the cursor to the front of this ResultSet object, just before the first row. This method has no effect if the result set contains no rows.

Throws:
SQLException - if a database access error occurs or the result set type is TYPE_FORWARD_ONLY

close

public abstract void close()

first

public boolean first()
              throws SQLException
Moves the cursor to the first row in this ResultSet object.

Returns:
true if the cursor is on a valid row; false if there are no rows in the result set
Throws:
SQLException - if a database access error occurs or the result set type is TYPE_FORWARD_ONLY

getColumn

public String getColumn(int columnIndex)
                 throws SQLException
Get the value of the column at the specified index.

Parameters:
columnIndex - Description of Parameter
Returns:
The column value
Throws:
SQLException
Since:

getColumn

public String getColumn(String columnName)
                 throws SQLException
Get value from column at specified name. If the column name is not found, throw an error.

Parameters:
columnName - Description of Parameter
Returns:
The column value
Throws:
SQLException - Description of Exception
Since:

getColumnNames

public String[] getColumnNames()
Gets the columnNames attribute of the CsvReader object

Returns:
The columnNames value
Since:

getLineCount

public int getLineCount()
Retorna a quantidade de linhas (para consultas do tipo COUNT(*).


getRow

public int getRow()
           throws SQLException
Retrieves the current row number. The first row is number 1, the second number 2, and so on.

Returns:
the current row number; 0 if there is no current row
Throws:
SQLException - if a database access error occurs

getTableName

public String getTableName()

isAfterLast

public boolean isAfterLast()
                    throws SQLException
Retrieves whether the cursor is after the last row in this ResultSet object.

Returns:
true if the cursor is after the last row; false if the cursor is at any other position or the result set contains no rows
Throws:
SQLException - if a database access error occurs

isBeforeFirst

public boolean isBeforeFirst()
                      throws SQLException
Retrieves whether the cursor is before the first row in this ResultSet object.

Returns:
true if the cursor is before the first row; false if the cursor is at any other position or the result set contains no rows
Throws:
SQLException - if a database access error occurs

isFirst

public boolean isFirst()
                throws SQLException
Retrieves whether the cursor is on the first row of this ResultSet object.

Returns:
true if the cursor is on the first row; false otherwise
Throws:
SQLException - if a database access error occurs

isLast

public boolean isLast()
               throws SQLException
Retrieves whether the cursor is on the last row of this ResultSet object. Note: Calling the method isLast may be expensive because the JDBC driver might need to fetch ahead one row in order to determine whether the current row is the last row in the result set.

Returns:
true if the cursor is on the last row; false otherwise
Throws:
SQLException - if a database access error occurs

last

public boolean last()
             throws SQLException
Moves the cursor to the last row in this ResultSet object.

Returns:
true if the cursor is on a valid row; false if there are no rows in the result set
Throws:
SQLException - if a database access error occurs or the result set type is TYPE_FORWARD_ONLY

next

public abstract boolean next()
                      throws SQLException
Throws:
SQLException

parseCsvLine

protected abstract String[] parseCsvLine(String line)
                                  throws SQLException
Throws:
SQLException

previous

public boolean previous()
                 throws SQLException
Moves the cursor to the previous row in this ResultSet object.

Returns:
true if the cursor is on a valid row; false if it is off the result set
Throws:
SQLException - if a database access error occurs or the result set type is TYPE_FORWARD_ONLY

relative

public boolean relative(int rows)
                 throws SQLException
Moves the cursor a relative number of rows, either positive or negative. Attempting to move beyond the first/last row in the result set positions the cursor before/after the the first/last row. Calling relative(0) is valid, but does not change the cursor position.

Note: Calling the method relative(1) is identical to calling the method next() and calling the method relative(-1) is identical to calling the method previous().

Parameters:
rows - an int specifying the number of rows to move from the current row; a positive number moves the cursor forward; a negative number moves the cursor backward
Returns:
true if the cursor is on a row; false otherwise
Throws:
SQLException - if a database access error occurs, there is no current row, or the result set type is TYPE_FORWARD_ONLY


Copyright © 2008 Rogério Arantes Gaioso. All Rights Reserved.