org.brains2b.data.cursor
Class CursorData

java.lang.Object
  |
  +--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.21 [07-04-2004]
Author:
dennis@brains2b.nl

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.
 boolean equals(java.lang.Object obj)
          determines if two objects are equal by comparing their hashCodes
 int getChecksum()
          implemented to be consistent with a system that might use optimistic locking for normal data access
 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
 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
 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()
          implemented to be consistent with a system that might use optimistic locking for normal data access
 void setChecksum(int value)
          implemented to be consistent with a system that might use optimistic locking for normal data access
 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

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

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()
implemented to be consistent with a system that might use optimistic locking for normal data access

Specified by:
getChecksum in interface OptimisticLock
Returns:
int, the checksum value
See Also:
OptimisticLock.getChecksum()

setChecksum

public void setChecksum(int value)
implemented to be consistent with a system that might use optimistic locking for normal data access

Specified by:
setChecksum in interface OptimisticLock
Parameters:
value - int, the new checksum value
See Also:
OptimisticLock.setChecksum(int)

hashCode

public int hashCode()
implemented to be consistent with a system that might use optimistic locking for normal data access

Specified by:
hashCode in interface OptimisticLock
Overrides:
hashCode in class java.lang.Object
Returns:
int
See Also:
OptimisticLock.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(), Cursor.getProtoType(ResultSetMetaData)

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


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)