br.ufg.integrate.wrapper.csv
Class CSVScrollableReader

java.lang.Object
  extended by br.ufg.integrate.wrapper.csv.CSVReaderAdapter
      extended by br.ufg.integrate.wrapper.csv.CSVScrollableReader

public class CSVScrollableReader
extends CSVReaderAdapter

This class Class provides facility to navigate on the Result Set.

Version:
$Id: CSVScrollableReader.java,v 1.2 2007/09/19
Author:
Chetan Gupta, Rogerio Arantes Gaioso

Field Summary
 
Fields inherited from class br.ufg.integrate.wrapper.csv.CSVReaderAdapter
buf, charset, columnNames, columns, fileName, separator, suppressHeaders, tableName
 
Constructor Summary
CSVScrollableReader(String fileName)
          Constructor for the CsvReader object
CSVScrollableReader(String fileName, char separator, boolean suppressHeaders, String charset)
          Can be put in adpater apart from the last line Insert the method's description here.
 
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.
 void close()
          Method close.
 boolean first()
          Moves the cursor to the first row in this ResultSet object.
 int getRow()
          Retrieves the current row number.
 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.
 boolean next()
           
protected  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 br.ufg.integrate.wrapper.csv.CSVReaderAdapter
getColumn, getColumn, getColumnNames, getLineCount, getTableName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVScrollableReader

public CSVScrollableReader(String fileName)
                    throws Exception
Constructor for the CsvReader object

Parameters:
fileName - Description of Parameter
Throws:
Exception - Description of Exception
Since:

CSVScrollableReader

public CSVScrollableReader(String fileName,
                           char separator,
                           boolean suppressHeaders,
                           String charset)
                    throws Exception
Can be put in adpater apart from the last line Insert the method's description here. Creation date: (6-11-2001 15:02:42)

Parameters:
fileName - java.lang.String
separator - char
suppressHeaders - boolean
Throws:
Exception - The exception description.
Since:
Method Detail

parseCsvLine

protected String[] parseCsvLine(String line)
                         throws SQLException
Specified by:
parseCsvLine in class CSVReaderAdapter
Throws:
SQLException

close

public void close()
Method close.

Specified by:
close in class CSVReaderAdapter

next

public boolean next()
             throws SQLException
Specified by:
next in class CSVReaderAdapter
Returns:
Is has next element.
Throws:
SQLException
Since:

previous

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

Overrides:
previous in class CSVReaderAdapter
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

isBeforeFirst

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

Overrides:
isBeforeFirst in class CSVReaderAdapter
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

isAfterLast

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

Overrides:
isAfterLast in class CSVReaderAdapter
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

isFirst

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

Overrides:
isFirst in class CSVReaderAdapter
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.

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

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.

Overrides:
beforeFirst in class CSVReaderAdapter
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.

Overrides:
afterLast in class CSVReaderAdapter
Throws:
SQLException - if a database access error occurs or the result set type is TYPE_FORWARD_ONLY

first

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

Overrides:
first in class CSVReaderAdapter
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

last

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

Overrides:
last in class CSVReaderAdapter
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

getRow

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

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

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().

Overrides:
absolute in class CSVReaderAdapter
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

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().

Overrides:
relative in class CSVReaderAdapter
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.