org.edg.info.sqlutil.rdb
Class Tuple

java.lang.Object
  extended byorg.edg.info.sqlutil.rdb.Tuple

public class Tuple
extends java.lang.Object

A relational tuple (row in a table). This consists of a set of column names (as String objects) and a set of column values, each of which is a String, Integer/Double or null, representing STRING, NUMERIC and NULL Constant types.


Constructor Summary
Tuple()
          Creates a new empty Tuple.
Tuple(java.util.List columnNames)
          Creates a new tuple, given it's column names.
Tuple(java.lang.String[] columnNames)
          Creates a new Tuple object.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 int getAttIndex(java.lang.String name)
          Return the index of the attribute corresponding to the name
 java.lang.String getAttName(int index)
          Return the name of the attribute corresponding to the index
 java.lang.Object getAttValue(int index)
          Return the value of the attribute corresponding to the index
 java.lang.Object getAttValue(java.lang.String name)
          Return the value of the attribute whith the given name
 java.lang.String[] getColumnNames()
          Gets the array of column names as Strings.
 java.util.List getColumnValues()
          Gets the column values as a List of Double, Integer or String objects.
 java.lang.String[] getColumnValuesAsStrings()
          Gets the column values as an array of Strings.
 long getEstimatedSize()
          Get an estimate for the amount of memory required to store this tuple.
 int getNumAtt()
          Return the number of attributes in the tuple.
 int hashCode()
           
 boolean isAttribute(java.lang.String attrName)
          To know if an attributes is already defined
 Tuple project(java.util.Vector map)
          Projects this Tuple according to the given SELECT map.
 void setAtt(java.lang.String name, java.lang.Object value)
          Set the value of the given attribute name
 void setRow(java.util.List row)
          Set the current tuple's column values.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tuple

public Tuple()
Creates a new empty Tuple.


Tuple

public Tuple(java.util.List columnNames)
Creates a new tuple, given it's column names.

Parameters:
columnNames - List of column names.

Tuple

public Tuple(java.lang.String[] columnNames)
Creates a new Tuple object.

Parameters:
columnNames - DOCUMENT ME!
Method Detail

getEstimatedSize

public long getEstimatedSize()
Get an estimate for the amount of memory required to store this tuple. This estimate is not guaranteed to be accurate!

Returns:
Estimated size in bytes.

setAtt

public void setAtt(java.lang.String name,
                   java.lang.Object value)
Set the value of the given attribute name

Parameters:
name - the string representing the attribute name
value - the Object representing the attribute value

getAttIndex

public int getAttIndex(java.lang.String name)
Return the index of the attribute corresponding to the name

Parameters:
name - integer giving the index of the attribute
Returns:
the index as an int, -1 if name is not an attribute

getAttName

public java.lang.String getAttName(int index)
Return the name of the attribute corresponding to the index

Parameters:
index - integer giving the index of the attribute
Returns:
a String

getAttValue

public java.lang.Object getAttValue(int index)
                             throws java.sql.SQLException
Return the value of the attribute corresponding to the index

Parameters:
index - integer giving the index of the attribute
Returns:
an Object or null.
Throws:
java.sql.SQLException - If the index is out of bounds.

getAttValue

public java.lang.Object getAttValue(java.lang.String name)
                             throws java.sql.SQLException
Return the value of the attribute whith the given name

Parameters:
name - Attribute name.
Returns:
an Object or null.
Throws:
java.sql.SQLException - If the name does not exist in this tuple.

isAttribute

public boolean isAttribute(java.lang.String attrName)
To know if an attributes is already defined

Parameters:
attrName - the name of the attribute
Returns:
true if there, else false

getColumnNames

public java.lang.String[] getColumnNames()
Gets the array of column names as Strings.

Returns:
An array of column names.

getColumnValuesAsStrings

public java.lang.String[] getColumnValuesAsStrings()
Gets the column values as an array of Strings.

Returns:
An array of column values.

getColumnValues

public java.util.List getColumnValues()
Gets the column values as a List of Double, Integer or String objects.

Returns:
A List of Double or String objects.

getNumAtt

public int getNumAtt()
Return the number of attributes in the tuple.

Returns:
The number of attributes

setRow

public void setRow(java.util.List row)
Set the current tuple's column values.

Parameters:
row - A vector of column values.

equals

public boolean equals(java.lang.Object obj)
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
See Also:
Object.hashCode()

toString

public java.lang.String toString()
See Also:
Object.toString()

project

public Tuple project(java.util.Vector map)
              throws java.sql.SQLException
Projects this Tuple according to the given SELECT map.

Parameters:
map - Vector of SelectItem objects.
Returns:
A new Tuple which is the projection of map on this Tuple.
Throws:
java.sql.SQLException - If the projection can not be completed.