uk.org.ogsadai.tuple
Class SimpleTuple

java.lang.Object
  extended by uk.org.ogsadai.tuple.SimpleTuple
All Implemented Interfaces:
java.io.Serializable, Tuple
Direct Known Subclasses:
StampedTuple

public class SimpleTuple
extends java.lang.Object
implements Tuple

The implementation of the Tuple interface.

Author:
The OGSA-DAI Project Team
See Also:
Serialized Form

Field Summary
protected  java.util.List mElements
          The List containing the elements of the tuple.
protected  Null mODNULL
          SQL NULL representation.
protected  boolean mWasNull
          Checks whether the last column value was null or not.
 
Constructor Summary
protected SimpleTuple()
           
  SimpleTuple(java.util.List elements)
          Constructor of the tuple object.
  SimpleTuple(Tuple tupleA, Tuple tupleB)
          Constructs a new tuple by joining two given tuples.
 
Method Summary
 boolean equals(java.lang.Object obj)
          
 java.math.BigDecimal getBigDecimal(int columnIndex)
          Gets the value of the specified column as a BigDecimal.
 java.math.BigDecimal getBigDecimal(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a BigDecimal.
 java.sql.Blob getBlob(int columnIndex)
          Gets the value of the specified column as an Blob.
 java.sql.Blob getBlob(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a Blob.
 boolean getBoolean(int columnIndex)
          Gets the value of the specified column as a boolean.
 boolean getBoolean(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a boolean.
 char getChar(int columnIndex)
          Gets the value of the specified column as a char.
 char getChar(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a char.
 java.sql.Clob getClob(int columnIndex)
          Gets the value of the specified column as an Clob.
 java.sql.Clob getClob(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a java.sql.Clob.
 int getColumnCount()
          Get the number of columns in the tuple.
 java.sql.Date getDate(int columnIndex)
          Gets the value of the specified column as a Date.
 java.sql.Date getDate(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a Date.
 double getDouble(int columnIndex)
          Gets the value of the specified column as a double.
 double getDouble(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a double.
 java.io.File getFile(int columnIndex)
          Gets the value of the specified column as a File.
 java.io.File getFile(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a File.
 float getFloat(int columnIndex)
          Gets the value of the specified column as a float.
 float getFloat(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a float.
 int getInt(int columnIndex)
          Gets the value of the specified column as an int.
 int getInt(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as an int.
 long getLong(int columnIndex)
          Gets the value of the specified column as a long It is the recommended Java mapping for the JDBC type BIGINT.
 long getLong(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a long.
 java.lang.Object getObject(int columnIndex)
          For cases where none of the below get methods fits.
 java.lang.Object getObject(TupleMetadata metadata, java.lang.String columnName)
          Gets the object of a specified column name of the tuple.
 short getShort(int columnIndex)
          Gets the value of the specified column as a shprt.
 short getShort(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a short.
 java.lang.String getString(int columnIndex)
          Gets the value of the specified column as a String.
 java.lang.String getString(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a String.
 java.sql.Time getTime(int columnIndex)
          Gets the value of the specified column as a Time.
 java.sql.Time getTime(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a Time.
 java.sql.Timestamp getTimestamp(int columnIndex)
          Gets the value of the specified column as a Timestamp.
 java.sql.Timestamp getTimestamp(TupleMetadata metadata, java.lang.String columnName)
          Gets the value of the specified column as a Timestamp.
 int hashCode()
          
 java.lang.String toString()
          Auxiliary method to see the output of the Tuple Overrides the usual java toString() method.
 boolean wasNull()
          Reports whether the last column read had a value of SQL NULL.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mODNULL

protected Null mODNULL
SQL NULL representation.


mWasNull

protected boolean mWasNull
Checks whether the last column value was null or not.


mElements

protected java.util.List mElements
The List containing the elements of the tuple.

Constructor Detail

SimpleTuple

protected SimpleTuple()

SimpleTuple

public SimpleTuple(java.util.List elements)
Constructor of the tuple object.

Parameters:
elements - The list of elements of the tuple

SimpleTuple

public SimpleTuple(Tuple tupleA,
                   Tuple tupleB)
Constructs a new tuple by joining two given tuples. The resulting tuple has all the column values of tuple A followed by all the column values of tuple B.

Parameters:
tupleA - tuple A
tupleB - tuple B
Method Detail

getColumnCount

public int getColumnCount()
Get the number of columns in the tuple.

Specified by:
getColumnCount in interface Tuple
Returns:
the number of columns in the tuple.

getObject

public java.lang.Object getObject(int columnIndex)
                           throws ColumnNotFoundException
For cases where none of the below get methods fits. Gets the object of a specified column of the OD tuple

Specified by:
getObject in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
The object of a specified column of the OD tuple
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getBoolean

public boolean getBoolean(int columnIndex)
                   throws ColumnNotFoundException
Gets the value of the specified column as a boolean. It is the recommended Java mapping for the JDBC type BIT.

Specified by:
getBoolean in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is false
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getFloat

public float getFloat(int columnIndex)
               throws ColumnNotFoundException
Gets the value of the specified column as a float. It is the recommended Java mapping for the JDBC type REAL.

Specified by:
getFloat in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getInt

public int getInt(int columnIndex)
           throws ColumnNotFoundException
Gets the value of the specified column as an int. It is the recommended Java mapping for the JDBC type INTEGER.

Specified by:
getInt in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getLong

public long getLong(int columnIndex)
             throws ColumnNotFoundException
Gets the value of the specified column as a long It is the recommended Java mapping for the JDBC type BIGINT.

Specified by:
getLong in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getString

public java.lang.String getString(int columnIndex)
                           throws ColumnNotFoundException
Gets the value of the specified column as a String. It is the recommended Java mapping for the JDBC type CHAR, VARCHAR.

Specified by:
getString in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getChar

public char getChar(int columnIndex)
             throws ColumnNotFoundException
Gets the value of the specified column as a char.

Specified by:
getChar in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getDouble

public double getDouble(int columnIndex)
                 throws ColumnNotFoundException
Gets the value of the specified column as a double. It is the recommended Java mapping for the JDBC type DOUBLE, FLOAT.

Specified by:
getDouble in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column number is out of bounds
java.lang.NumberFormatException - if the value cannot be converted into a double

getShort

public short getShort(int columnIndex)
               throws ColumnNotFoundException
Gets the value of the specified column as a shprt. It is the recommended Java mapping for the JDBC type TINYINT, SMALLINT.

Specified by:
getShort in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getFile

public java.io.File getFile(int columnIndex)
                     throws ColumnNotFoundException
Gets the value of the specified column as a File.

Specified by:
getFile in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getDate

public java.sql.Date getDate(int columnIndex)
                      throws ColumnNotFoundException
Gets the value of the specified column as a Date.

Specified by:
getDate in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getTime

public java.sql.Time getTime(int columnIndex)
                      throws ColumnNotFoundException
Gets the value of the specified column as a Time.

Specified by:
getTime in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getTimestamp

public java.sql.Timestamp getTimestamp(int columnIndex)
                                throws ColumnNotFoundException
Gets the value of the specified column as a Timestamp.

Specified by:
getTimestamp in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getBigDecimal

public java.math.BigDecimal getBigDecimal(int columnIndex)
                                   throws ColumnNotFoundException
Gets the value of the specified column as a BigDecimal. It is the recommended Java mapping for the JDBC type NUMERIC(,DECIMAL).

Specified by:
getBigDecimal in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getBlob

public java.sql.Blob getBlob(int columnIndex)
                      throws ColumnNotFoundException
Gets the value of the specified column as an Blob.

Specified by:
getBlob in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getClob

public java.sql.Clob getClob(int columnIndex)
                      throws ColumnNotFoundException
Gets the value of the specified column as an Clob.

Specified by:
getClob in interface Tuple
Parameters:
columnIndex - the first column is 0, the second is 1, ...
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column number is out of bounds

getObject

public java.lang.Object getObject(TupleMetadata metadata,
                                  java.lang.String columnName)
                           throws ColumnNotFoundException
Gets the object of a specified column name of the tuple.

Specified by:
getObject in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the object of a specified column name of the tuple name
Throws:
ColumnNotFoundException - raised if the column name does not exist

getBoolean

public boolean getBoolean(TupleMetadata metadata,
                          java.lang.String columnName)
                   throws ColumnNotFoundException
Gets the value of the specified column as a boolean.

Specified by:
getBoolean in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is false
Throws:
ColumnNotFoundException - raised if the column name does not exist

getFloat

public float getFloat(TupleMetadata metadata,
                      java.lang.String columnName)
               throws ColumnNotFoundException
Gets the value of the specified column as a float.

Specified by:
getFloat in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column name does not exist

getInt

public int getInt(TupleMetadata metadata,
                  java.lang.String columnName)
           throws ColumnNotFoundException
Gets the value of the specified column as an int.

Specified by:
getInt in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column name does not exist

getLong

public long getLong(TupleMetadata metadata,
                    java.lang.String columnName)
             throws ColumnNotFoundException
Gets the value of the specified column as a long.

Specified by:
getLong in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column name does not exist

getString

public java.lang.String getString(TupleMetadata metadata,
                                  java.lang.String columnName)
                           throws ColumnNotFoundException
Gets the value of the specified column as a String.

Specified by:
getString in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column name does not exist

getChar

public char getChar(TupleMetadata metadata,
                    java.lang.String columnName)
             throws ColumnNotFoundException
Gets the value of the specified column as a char.

Specified by:
getChar in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column name does not exist

getDouble

public double getDouble(TupleMetadata metadata,
                        java.lang.String columnName)
                 throws ColumnNotFoundException
Gets the value of the specified column as a double.

Specified by:
getDouble in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column name does not exist

getShort

public short getShort(TupleMetadata metadata,
                      java.lang.String columnName)
               throws ColumnNotFoundException
Gets the value of the specified column as a short.

Specified by:
getShort in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is 0
Throws:
ColumnNotFoundException - raised if the column name does not exist

getFile

public java.io.File getFile(TupleMetadata metadata,
                            java.lang.String columnName)
                     throws ColumnNotFoundException
Gets the value of the specified column as a File.

Specified by:
getFile in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column name does not exist

getDate

public java.sql.Date getDate(TupleMetadata metadata,
                             java.lang.String columnName)
                      throws ColumnNotFoundException
Gets the value of the specified column as a Date.

Specified by:
getDate in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column name does not exist

getTime

public java.sql.Time getTime(TupleMetadata metadata,
                             java.lang.String columnName)
                      throws ColumnNotFoundException
Gets the value of the specified column as a Time.

Specified by:
getTime in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column name does not exist

getTimestamp

public java.sql.Timestamp getTimestamp(TupleMetadata metadata,
                                       java.lang.String columnName)
                                throws ColumnNotFoundException
Gets the value of the specified column as a Timestamp.

Specified by:
getTimestamp in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column name does not exist

getBigDecimal

public java.math.BigDecimal getBigDecimal(TupleMetadata metadata,
                                          java.lang.String columnName)
                                   throws ColumnNotFoundException
Gets the value of the specified column as a BigDecimal.

Specified by:
getBigDecimal in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column name does not exist

getBlob

public java.sql.Blob getBlob(TupleMetadata metadata,
                             java.lang.String columnName)
                      throws ColumnNotFoundException
Gets the value of the specified column as a Blob.

Specified by:
getBlob in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column name does not exist

getClob

public java.sql.Clob getClob(TupleMetadata metadata,
                             java.lang.String columnName)
                      throws ColumnNotFoundException
Gets the value of the specified column as a java.sql.Clob.

Specified by:
getClob in interface Tuple
Parameters:
metadata - metadata describing the tuple.
columnName - the column name
Returns:
the column value, if the value is SQL NULL, the value returned is null
Throws:
ColumnNotFoundException - raised if the column name does not exist

wasNull

public boolean wasNull()
Reports whether the last column read had a value of SQL NULL. Note that you must first call one of the getter methods on a column to try to read its value and then call the method wasNull to see if the value read was SQL NULL.

Specified by:
wasNull in interface Tuple
Returns:
true if the last column value read was SQL NULL and false otherwise

toString

public java.lang.String toString()
Auxiliary method to see the output of the Tuple Overrides the usual java toString() method.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of an Tuple

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object