org.brains2b.data.cursor
Class CursorData

java.lang.Object
  extended by org.brains2b.data.cursor.CursorData
All Implemented Interfaces:
java.lang.Cloneable, OptimisticLock

public class CursorData
extends java.lang.Object
implements OptimisticLock, java.lang.Cloneable

Object for containing results from a Cursor

Version:
0.22 [16-01-2008]
Author:
dennis@brains2b.nl
See Also:
Cursor

Constructor Summary
CursorData(java.lang.String name)
          Constructor for CursorData.
 
Method Summary
 java.lang.Object clone()
          clone will copy the column definitions, but will not clone the values set for this CursorData.
 java.lang.Object cloneAll()
          clone will copy the column definitions including the values
 boolean equals(java.lang.Object obj)
          determines if two objects are equal by comparing their hashCodes
 int getChecksum()
          get the checksum value
 java.lang.String getColumn(int idx)
          get the column identifier for the column at the given index
 int getColumnCount()
          get the number of fields in this cursor data object
 java.lang.Class getColumnType(int idx)
          get the column type for the column given by the specified index
 java.lang.Class getColumnType(java.lang.String name)
          get the column type for the column identified by name
 double getDoubleValue(int idx)
          get the value of the column at the given index as a double
 double getDoubleValue(java.lang.String name)
          get the double balue belonging to the column identified by name
 int getIntValue(int idx)
          get the value of the column at the given index as an integer.
 int getIntValue(java.lang.String name)
          get the intValue belonging to the column identified by name
 long getLongValue(int idx)
          get the value of the column at the given index as a long.
 long getLongValue(java.lang.String name)
          get the longValue belonging to the column identified by name
 java.lang.String getName()
          get the name of the Cursor this CursorData object is a result for
 int getRowNo()
          get the position of this CursorData object in a collection
 java.lang.Object getValue(int idx)
          get the value of the column at the given index as an Object
 java.lang.Object getValue(java.lang.String name)
          get the value of the column identified by name as an Object
 int hashCode()
          get a hash for the particular object that implements this interface.
 int serialID()
           
 void setChecksum(int value)
          set the checksum value.
 void setColumn(int idx, java.lang.String name)
          set a column identified by name at the specified position
 void setColumnType(int idx, java.lang.Class c)
          set the Class identifying the type of content for this column by index.
 void setColumnValue(int idx, java.lang.String name, java.lang.Object value)
          convinience method to set the column name and value at once at a given index
 void setName(java.lang.String name)
          set the name of the Cursor this CursorData object is a result for
 void setRowNo(int rowNo)
          set the position of this CursorData object in a collection
 void setValue(int idx, java.lang.Object value)
          set the content value for the specified index
 void setValue(java.lang.String name, java.lang.Object value)
          set the content value for the column identified by name
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CursorData

public CursorData(java.lang.String name)
Constructor for CursorData.

Parameters:
name - String, the name of the data source for information purposes only
Method Detail

getColumnCount

public int getColumnCount()
get the number of fields in this cursor data object

Returns:
int, the number of columns

setColumn

public void setColumn(int idx,
                      java.lang.String name)
set a column identified by name at the specified position

Parameters:
idx - int, the index to set the column to
name - String, the identifier for this column

getColumn

public java.lang.String getColumn(int idx)
get the column identifier for the column at the given index

Parameters:
idx - int, the index of the column
Returns:
String, the column identifier

setColumnType

public void setColumnType(int idx,
                          java.lang.Class c)
set the Class identifying the type of content for this column by index.

Parameters:
idx - int, the index of the column
c - Class, the class identifying the content for this column. Use the Integer.TYPE, Boolean.TYPE, etc. for the primitives

getColumnType

public java.lang.Class getColumnType(java.lang.String name)
get the column type for the column identified by name

Parameters:
name - String, the column identifier
Returns:
Class, the Class-definition of the column, for primitives are returned as Integer.TYPE, Double.TYPE, etc.
Since:
DataC 0.30

getColumnType

public java.lang.Class getColumnType(int idx)
get the column type for the column given by the specified index

Parameters:
idx - int, the index of the column
Returns:
Class, the Class-definition of the column, for primitives are returned as Integer.TYPE, Double.TYPE, etc.
Since:
DataC 0.30

setValue

public void setValue(int idx,
                     java.lang.Object value)
set the content value for the specified index

Parameters:
idx - int, the index of the column
value - Object, the value for this specific column. The type of Object should be consistent with the type of column you defined through setColumnType(int,Class)
See Also:
setColumnType(int, Class)

setValue

public void setValue(java.lang.String name,
                     java.lang.Object value)
set the content value for the column identified by name

Parameters:
name - String, the column identifier
value - Object, the value for this specific column. The type of Object should be consistent with the type of column you defined through setColumnType(int,Class)
See Also:
setColumnType(int, Class)

setColumnValue

public void setColumnValue(int idx,
                           java.lang.String name,
                           java.lang.Object value)
convinience method to set the column name and value at once at a given index

Parameters:
idx - int, the index of the column
name - String, the column identifier
value - Object, the value for this specific column. You can set the column type afterwards. The value and type should be consistent

getValue

public java.lang.Object getValue(int idx)
get the value of the column at the given index as an Object

Parameters:
idx - int, the index of the column
Returns:
Object, the value of this column, will return null if no previous value was set

getDoubleValue

public double getDoubleValue(int idx)
get the value of the column at the given index as a double

Parameters:
idx - int, the index of the column
Returns:
double, the double value for this column, 0 (zero) if the column is not defined (yet)
Throws:
NumberFormatException, - If the value set to this specific column cannot be cast to an int

getDoubleValue

public double getDoubleValue(java.lang.String name)
get the double balue belonging to the column identified by name

Parameters:
name - String, the name of the column
Returns:
double, the value for this column, 0 (zero) if the column is not defined (yet)
Throws:
NumberFormatException, - If the value set to this specific column cannot be cast to an int

getIntValue

public int getIntValue(int idx)
get the value of the column at the given index as an integer.

Parameters:
idx - int, the index of the column
Returns:
int, the int value for this column, 0 (zero) if the column is not defined (yet)
Throws:
NumberFormatException, - If the value set to this specific column cannot be cast to an int

getLongValue

public long getLongValue(int idx)
get the value of the column at the given index as a long.

Parameters:
idx - int, the index of the column
Returns:
long, the long value for this column, 0 (zero) if the column is not defined (yet)
Throws:
NumberFormatException, - If the value set to this specific column cannot be cast to an int
Since:
DataC 0.31

getLongValue

public long getLongValue(java.lang.String name)
get the longValue belonging to the column identified by name

Parameters:
name - String, the name of the column
Returns:
long, the value for this column, 0 (zero) if the column is not defined (yet)
Throws:
NumberFormatException, - If the value set to this specific column cannot be cast to an int
Since:
DataC 0.31

getValue

public java.lang.Object getValue(java.lang.String name)
get the value of the column identified by name as an Object

Parameters:
name - String, the column identifier
Returns:
Object, the value for this column

getIntValue

public int getIntValue(java.lang.String name)
get the intValue belonging to the column identified by name

Parameters:
name - String, the name of the column
Returns:
int, the value for this column, 0 (zero) if the column is not defined (yet)
Throws:
NumberFormatException, - If the value set to this specific column cannot be cast to an int

getChecksum

public int getChecksum()
Description copied from interface: OptimisticLock
get the checksum value

Specified by:
getChecksum in interface OptimisticLock
Returns:
int, the checksum value

setChecksum

public void setChecksum(int value)
Description copied from interface: OptimisticLock
set the checksum value. Usually just a newly calculated hashCode()

Specified by:
setChecksum in interface OptimisticLock
Parameters:
value - int, the new checksum value

hashCode

public int hashCode()
Description copied from interface: OptimisticLock
get a hash for the particular object that implements this interface.

Here to remind you: You cannot rely on Object.hashCode() to implement a meaningfull OptimisticLock

Specified by:
hashCode in interface OptimisticLock
Overrides:
hashCode in class java.lang.Object
Returns:
int
See Also:
Object.hashCode()

clone

public java.lang.Object clone()
clone will copy the column definitions, but will not clone the values set for this CursorData.

This is mostly used to get from a prototype to a real CursorData object

Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

cloneAll

public java.lang.Object cloneAll()
clone will copy the column definitions including the values


getRowNo

public int getRowNo()
get the position of this CursorData object in a collection

This value is set by the select procedure itself and does not have to be consistent with List.indexOf(Object) and is used to update a specific cursor object

Returns:
int, the row number of this CursorData object in a collection

setRowNo

public void setRowNo(int rowNo)
set the position of this CursorData object in a collection

This value is set by the select procedure itself and does not have to be consistent with List.indexOf(Object). It is used to update a specific cursor object

Parameters:
rowNo - int, the position to set

getName

public java.lang.String getName()
get the name of the Cursor this CursorData object is a result for

Returns:
String, the name of the Cursor

setName

public void setName(java.lang.String name)
set the name of the Cursor this CursorData object is a result for

Parameters:
name - String, the name to set

equals

public boolean equals(java.lang.Object obj)
determines if two objects are equal by comparing their hashCodes

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

serialID

public int serialID()
Specified by:
serialID in interface OptimisticLock