litebase
Class RowIterator

java.lang.Object
  extended by litebase.RowIterator

public class RowIterator
extends java.lang.Object

Used to iterate through the rows of a database. It can access some attributes from the row that eases the control of which row was changed, deleted or is newer since a synchronization.


Field Summary
 int attr
          The attribute for this row.
 byte[] data
          The data for the current row.
static int ROW_ATTR_DELETED
          Indicates if the row was deleted.
static int ROW_ATTR_NEW
          Indicates if the row is new.
static int ROW_ATTR_SYNCED
          Indicates if the a row was synced.
static int ROW_ATTR_UPDATED
          Indicates if the row was updated.
 int rowid
          The rowid for the current row.
 int rowNumber
          The number of the row.
 
Method Summary
 void close()
          Closes this iterator.
 byte[] getBlob(int column)
          Returns a blob contained in the current row.
 totalcross.util.Date getDate(int column)
          Returns a date contained in the current row.
 totalcross.sys.Time getDateTime(int column)
          Returns a datetime contained in the current row.
 double getDouble(int column)
          Returns a double precision floating point number contained in the current row.
 double getFloat(int column)
          Returns a floating point number contained in the current row.
 int getInt(int column)
          Returns an integer contained in the current row.
 long getLong(int column)
          Returns a long integer contained in the current row.
 short getShort(int column)
          Returns a short contained in the current row.
 java.lang.String getString(int column)
          Returns a string contained in the current row.
 boolean next()
          Moves to the next record and fills the data members.
 boolean nextNotSynced()
          Moves to the next record with an attribute different of SYNCED.
 void reset()
          Resets the counter to zero so it is possible to restart to fetch records.
 void setSynced()
          If the attribute is currently NEW or UPDATED, this method sets them to SYNCED.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROW_ATTR_SYNCED

public static final int ROW_ATTR_SYNCED
Indicates if the a row was synced.

See Also:
Constant Field Values

ROW_ATTR_NEW

public static final int ROW_ATTR_NEW
Indicates if the row is new.

See Also:
Constant Field Values

ROW_ATTR_UPDATED

public static final int ROW_ATTR_UPDATED
Indicates if the row was updated.

See Also:
Constant Field Values

ROW_ATTR_DELETED

public static final int ROW_ATTR_DELETED
Indicates if the row was deleted.

See Also:
Constant Field Values

data

public byte[] data
The data for the current row. The whole row is included.


rowid

public int rowid
The rowid for the current row.


attr

public int attr
The attribute for this row. It is necessary to use the constants beginning with ROW_ATTR_ to compare or assign.


rowNumber

public int rowNumber
The number of the row. Note: this must be READ ONLY. Changing it will corrupt your database.

Method Detail

next

public boolean next()
             throws DriverException
Moves to the next record and fills the data members.

Returns:
true if it is possible to iterate to the next record. Otherwise, it will return false.
Throws:
DriverException - If an IOException occurs.

nextNotSynced

public boolean nextNotSynced()
                      throws DriverException
Moves to the next record with an attribute different of SYNCED.

Returns:
true if it is possible to iterate to a next record not synced. Otherwise, it will return false.
Throws:
DriverException - If an IOException occurs.

setSynced

public void setSynced()
               throws DriverException
If the attribute is currently NEW or UPDATED, this method sets them to SYNCED. Note that if the row is DELETED, the change will be ignored.

Throws:
DriverException - If an IOException occurs.

close

public void close()
Closes this iterator.


reset

public void reset()
Resets the counter to zero so it is possible to restart to fetch records.


getShort

public short getShort(int column)
               throws DriverException
Returns a short contained in the current row.

Parameters:
column - The short column index, starting from 1.
Returns:
The value of the column.
Throws:
DriverException - if the column is not a short or an IOException occurs.

getInt

public int getInt(int column)
           throws DriverException
Returns an integer contained in the current row.

Parameters:
column - The integer column index, starting from 1.
Returns:
The value of the column.
Throws:
DriverException - if the column is not a integer or an IOException occurs.

getLong

public long getLong(int column)
             throws DriverException
Returns a long integer contained in the current row.

Parameters:
column - The long integer column index, starting from 1.
Returns:
The value of the column.
Throws:
DriverException - if the column is not a long integer or an IOException occurs.

getFloat

public double getFloat(int column)
                throws DriverException
Returns a floating point number contained in the current row.

Parameters:
column - The floating point number column index, starting from 1.
Returns:
The value of the column.
Throws:
DriverException - if the column is a not floating point number or an IOException occurs.

getDouble

public double getDouble(int column)
                 throws DriverException
Returns a double precision floating point number contained in the current row.

Parameters:
column - The double precision floating point number column index, starting from 1.
Returns:
The value of the column.
Throws:
DriverException - if the column is not a double precision floating point number or an IOException occurs.

getString

public java.lang.String getString(int column)
                           throws DriverException
Returns a string contained in the current row. Note that this method must be used only with CHAR types.

Parameters:
column - The string column index, starting from 1.
Returns:
The value of the column.
Throws:
DriverException - if the column is not of type string or an IOException occurs.

getBlob

public byte[] getBlob(int column)
               throws DriverException
Returns a blob contained in the current row.

Parameters:
column - The blob column index, starting from 1.
Returns:
The value of the column.
Throws:
DriverException - if the column is not of type blob or an IOException occurs.

getDate

public totalcross.util.Date getDate(int column)
                             throws DriverException
Returns a date contained in the current row.

Parameters:
column - The date column index, starting from 1.
Returns:
The value of the column.
Throws:
DriverException - if the column is not of type date, an IOException or an InvalidDateException occurs, or the date is not valid.

getDateTime

public totalcross.sys.Time getDateTime(int column)
                                throws DriverException
Returns a datetime contained in the current row.

Parameters:
column - The datetime column index, starting from 1.
Returns:
The value of the column.
Throws:
DriverException - if the column is not of type datetime or an IOException occurs.