its.SQL
Class ContentsData

java.lang.Object
  extended byits.SQL.ContentsData
All Implemented Interfaces:
java.io.Serializable

public class ContentsData
extends java.lang.Object
implements java.io.Serializable

Representation of a database table or "rowset". Similar in usage and concept to a JDBC ResultSet, but with the handy addition of a movable cursor. Provides a common interface to data produced in several different contexts:

  1. Data from the SDD Contents frame
  2. Data which has been "extracted" from the SDD Data frame

See Also:
Contents.readTable(java.lang.String), DataFactory.getExtractionHashtable(its.SQL.Schema, its.SQL.ContentsData, its.SQL.ContentsData), Select#getResults, ResultSet, Serialized Form

Constructor Summary
ContentsData(byte[] blob)
           
ContentsData(Table table, java.util.Vector data)
          Constructs a ContentsData object.
ContentsData(java.util.Vector vars, java.util.Vector data)
          Constructs a ContentsData object.
 
Method Summary
 void append(ContentsData cd)
          Appends a ContentsData Object to the end of the current one.
 void appendRowString(boolean commaSeparated, boolean quoteStrings, java.lang.StringBuffer sb)
           
static ContentsData createContentsDataFromBlob(byte[] data)
          Static method for constructing a single blob ContentsData instance.
 java.lang.String edit(EditRow er)
          Uses the given EditRow methods to construct a new string representation of this table, with any required changes as implemented by EditRow.
 void filter(AcceptRow ar)
          Calls the given acceptRow method for each row in the object, and removes the row if the method returns false.
 java.lang.String getColumnNames()
          Returns a string containing the column names in this table, separated by commas
 double getDouble(int ind)
           
 double getDouble(java.lang.String name)
           
 float getFloat(int ind)
           
 float getFloat(java.lang.String name)
           
 int getInt(int ind)
           
 int getInt(java.lang.String name)
           
 java.lang.Object getItem(int ind)
          Gets the data from the specified column and the current row cursor
 java.lang.Object getItem(java.lang.String name)
          Gets the data from the specified column and the current row cursor
 java.lang.Object getItem(Variable var)
          Gets the data from the specified column and the current row cursor
 long getLong(int ind)
           
 long getLong(java.lang.String name)
           
 int getNumberOfColumns()
           
 int getNumberOfRows()
           
 java.lang.Object[] getRowArray()
          Returns all data values on the current row, as an array of Objects.
 java.lang.Object[] getRowArray(int ind)
          Returns all data values on the specified row, as an array of Objects.
 int getRowIndex()
           
 java.lang.String getRowString()
          Returns all data values on the current row, separated by spaces in a single string.
 java.lang.String getRowString(boolean commaSeparated, boolean quoteStrings)
           
 java.lang.String getRowString(int ind)
          Returns all data values on the specified row, separated by spaces in a single string.
 short getShort(int ind)
           
 short getShort(java.lang.String name)
           
 java.lang.String getString(int ind)
           
 java.lang.String getString(java.lang.String name)
           
 Variable getVariable(java.lang.String name)
          Gets the Variable object that describes the specified column
 java.util.Vector getVariables()
          Gets a list of Variable objects that describe the columns in this rowset.
 boolean hasColumn(java.lang.String name)
           
 java.util.Hashtable hashBy(int ind)
          Allows easy filtering of a ContentsData object for a particular value in a particular column.
 java.util.Hashtable hashBy(java.lang.String name)
          Allows easy filtering of a ContentsData object for a particular value in a particular column.
 java.util.Hashtable hashBy(Variable var)
          Allows easy filtering of a ContentsData object for a particular value in a particular column.
 boolean isValid(java.lang.String name)
           
 boolean next()
          Increments the current row cursor index to its next value.
 void resetRowIndex()
          Resets row cursor index to before the first row.
 void setRowIndex(int ind)
          Sets the row cursor index to the specified value.
 java.lang.String toString(java.lang.String tableName)
          An SDD operator can use this method to write the data contained in the ContentsData object to a string, in the SDD Contents language.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentsData

public ContentsData(java.util.Vector vars,
                    java.util.Vector data)
Constructs a ContentsData object.

Parameters:
vars - a list of Variables that specify the type of each data column
data - a list containing entries of type Object[], each of which contains the values for a given row.

ContentsData

public ContentsData(Table table,
                    java.util.Vector data)
Constructs a ContentsData object.

Parameters:
table - the Table object that defines the data types for each column
data - a list containing entries of type Object[], each of which contains the values for a given row.

ContentsData

public ContentsData(byte[] blob)
Method Detail

createContentsDataFromBlob

public static ContentsData createContentsDataFromBlob(byte[] data)
Static method for constructing a single blob ContentsData instance. The data column in this ContentsData object is assumed to be of type its.Variable.RAW with name "data."

Parameters:
data - a byte[] array containing a single blob instance

hasColumn

public boolean hasColumn(java.lang.String name)
Parameters:
name - the name of a column
Returns:
true if the specified column exists in this object

next

public boolean next()
Increments the current row cursor index to its next value.

Returns:
true if the new cursor position points to a new data row, false if all data has been seen.

getVariable

public Variable getVariable(java.lang.String name)
Gets the Variable object that describes the specified column

Parameters:
name - the column name
Returns:
the Variable object describing the column with the specified name
Throws:
java.lang.IllegalArgumentException - thrown if name not valid

getVariables

public java.util.Vector getVariables()
Gets a list of Variable objects that describe the columns in this rowset.

Returns:
a Vector of all the ContentsData object's meta-data Variable (column) objects

getItem

public java.lang.Object getItem(java.lang.String name)
Gets the data from the specified column and the current row cursor

Parameters:
name - the column name

getItem

public java.lang.Object getItem(int ind)
Gets the data from the specified column and the current row cursor

Parameters:
ind - the column index

getItem

public java.lang.Object getItem(Variable var)
Gets the data from the specified column and the current row cursor

Parameters:
var - the column descriptor

getDouble

public double getDouble(int ind)

getDouble

public double getDouble(java.lang.String name)

getFloat

public float getFloat(int ind)

getFloat

public float getFloat(java.lang.String name)

getInt

public int getInt(int ind)

getInt

public int getInt(java.lang.String name)

getLong

public long getLong(int ind)

getLong

public long getLong(java.lang.String name)

getShort

public short getShort(int ind)

getShort

public short getShort(java.lang.String name)

getString

public java.lang.String getString(int ind)

getString

public java.lang.String getString(java.lang.String name)

hashBy

public java.util.Hashtable hashBy(Variable var)
Allows easy filtering of a ContentsData object for a particular value in a particular column. Creates a hashtable with a key for each distinct data value in the specified column, and a corresponding value of a new ContentsData object that contains only the rows with that value.

Parameters:
var - the Variable object describing a column
Returns:
a hashtable of values from that column matched to filtered ContentsData objects

hashBy

public java.util.Hashtable hashBy(java.lang.String name)
Allows easy filtering of a ContentsData object for a particular value in a particular column. Creates a hashtable with a key for each distinct data value in the specified column, and a corresponding value of a new ContentsData object that contains only the rows with that value.

Parameters:
name - the column name
Returns:
a hashtable of values from that column matched to filtered ContentsData objects

hashBy

public java.util.Hashtable hashBy(int ind)
Allows easy filtering of a ContentsData object for a particular value in a particular column. Creates a hashtable with a key for each distinct data value in the specified column, and a corresponding value of a new ContentsData object that contains only the rows with that value.

Parameters:
ind - the column index
Returns:
a hashtable of values from that column matched to filtered ContentsData objects

isValid

public boolean isValid(java.lang.String name)
Returns:
true if the given column exists in this rowset.

getNumberOfColumns

public int getNumberOfColumns()
Returns:
number of columns in this rowset.

getNumberOfRows

public int getNumberOfRows()
Returns:
number of rows in this rowset.

getRowIndex

public int getRowIndex()
Returns:
the row currently pointed at by the cursor

setRowIndex

public void setRowIndex(int ind)
Sets the row cursor index to the specified value.

Parameters:
ind - desired index value

resetRowIndex

public void resetRowIndex()
Resets row cursor index to before the first row.


getColumnNames

public java.lang.String getColumnNames()
Returns a string containing the column names in this table, separated by commas


getRowString

public java.lang.String getRowString()
Returns all data values on the current row, separated by spaces in a single string.

Returns:
a row of data values

getRowString

public java.lang.String getRowString(boolean commaSeparated,
                                     boolean quoteStrings)

appendRowString

public void appendRowString(boolean commaSeparated,
                            boolean quoteStrings,
                            java.lang.StringBuffer sb)

getRowString

public java.lang.String getRowString(int ind)
Returns all data values on the specified row, separated by spaces in a single string.

Parameters:
ind - index
Returns:
a row of data values
Throws:
java.lang.IllegalArgumentException

getRowArray

public java.lang.Object[] getRowArray()
Returns all data values on the current row, as an array of Objects.

Returns:
a row of data values

getRowArray

public java.lang.Object[] getRowArray(int ind)
Returns all data values on the specified row, as an array of Objects.

Parameters:
ind - index
Returns:
a row of data values

append

public void append(ContentsData cd)
Appends a ContentsData Object to the end of the current one. Tests to make sure the variables are the same and verifies that the data is of the correct dimension.

Parameters:
cd - the ContentsData object to be added

filter

public void filter(AcceptRow ar)
Calls the given acceptRow method for each row in the object, and removes the row if the method returns false. Using this method will change the current row, so don't call it in the middle of an enumeration!


edit

public java.lang.String edit(EditRow er)
Uses the given EditRow methods to construct a new string representation of this table, with any required changes as implemented by EditRow. Using this method will change the current row, so don't call it in the middle of an enumeration!


toString

public java.lang.String toString(java.lang.String tableName)
An SDD operator can use this method to write the data contained in the ContentsData object to a string, in the SDD Contents language. The string can then be added to an SDD stream in a Contents or Data frame.