Stellent
HowToComponents
JavaDoc

intradoc.data
Class DataResultSet

java.lang.Object
  |
  +--intradoc.data.DataResultSet
All Implemented Interfaces:
ResultSet
Direct Known Subclasses:
AdditionalRenditions, AliasData, ArchiveCollections, ArchiveData, ComponentClassFactory, IsoJavaEncodingMap, LogInfo, MetaFieldData, RoleDefinitions, SearchCollections, Users, WfStepData, WorkflowData, WorkflowTemplates

public class DataResultSet
extends java.lang.Object
implements ResultSet

This class is used as the database independent representation of a table. It implements the intradoc.data.ResultSet interface so that database queries and internal application tables can be handled through the same interface.


Field Summary
protected  boolean m_copyAborted
          Flag to indicate whether a copy has been prematurely aborted.
protected  int m_currentRow
          The currently selected row.
protected  IdcDateFormat[] m_dateFormat
           
protected  java.util.Vector m_fieldList
          Vector containing the field or column information in the order in which they appear.
protected  java.util.Hashtable m_fieldMapping
          Mapping of field name to field information.
protected  boolean m_isMutable
           
protected  int m_numRows
          Number of rows in the result set.
protected  java.util.Vector m_values
          Vector containing the values for each row in the result set.
 
Constructor Summary
DataResultSet()
          Default constructor.
DataResultSet(java.lang.String[] fieldNames)
          Used to create a simple in memory data result set.
 
Method Summary
 void addRow(java.util.Vector vect)
          Appends the specified row to the result set.
 void appendFields(java.util.Vector finfo)
          Appends columns to the result set.
 void closeInternals()
          Closes the result set.
 void copy(ResultSet rset)
          Copies all the rows in the specified result set.
 void copy(ResultSet rset, int maxRows)
          Copies a given result set into this result set up to the maximum number of rows (if non-zero).
 void copyEx(ResultSet rset, int maxRows, boolean useDbFormat)
           
 void copyFieldInfo(ResultSet rset)
          Copy only the field information of the specified result set into this result set.
 void copyFiltered(ResultSet rset, java.lang.String key, ResultSetFilter filter)
          Copy only the rows that match the criteria as specified by the passed in filter.
 void copyFilteredEx(ResultSet rset, java.lang.String key, ResultSetFilter filter, boolean startAtFirst)
          Copies a the rows of a specifed result set that match the filter.
 void copySimpleFiltered(ResultSet rset, java.lang.String key, java.lang.String val)
          Copy only the rows matching the simple criteria where a specified field must equal a specified value.
 java.util.Vector createEmptyRow()
          Creates an empty row for the result set.
 ResultSetFilter createMaxNumResultSetFilter(int maxnum)
          Creates a filter that limits the number of rows to copy.
 java.util.Vector createRow(Parameters params)
          Creates a row from the passed in values
 ResultSetFilter createSimpleResultSetFilter(java.lang.String lookupVal)
          Creates a result set filter based on a look up value.
 boolean deleteCurrentRow()
          Deletes the current row.
 void deleteRow(int index)
          Deletes the specified row.
 java.util.Vector findRow(int colIndex, java.lang.String val)
          Finds the row whose field value at the given index is equal to the given value.
 boolean first()
          Sets the result set to the first row.
 int getCurrentRow()
          Returns the index of the current row.
 java.util.Properties getCurrentRowProps()
          Returns the current row as a properties.
 java.util.Vector getCurrentRowValues()
          Returns the current row values.
 IdcDateFormat getDateFormat()
          Gets the IdcDateFormat object for this ResultSet.
 java.util.Date getDateValue(int index)
          Gets the field value as a date, only works for fields which are actually dates.
 boolean getFieldInfo(java.lang.String fieldName, FieldInfo fieldInfo)
          Gets field information for a particular field.
 java.lang.String getFieldName(int index)
          Gets the name of field located at a particular field index (from 0 to getNumFields() - 1).
 void getIndexFieldInfo(int index, FieldInfo fieldInfo)
          Gets field information for a particular field at a specified index.
 int getNumFields()
          Returns number of fields.
 int getNumRows()
          Returns the number of rows in the result set.
protected  java.util.Vector getResultSetValues(ResultSet rset, int numFields)
          Gets the result set values from the result set at the current row.
protected  java.util.Vector getResultSetValuesEx(ResultSet rset, int numFields, boolean useDbFormat)
           
 java.util.Vector getRowValues(int index)
          Returns the row at the given index.
 java.lang.String getStringValue(int index)
          Gets the value for a current field as a string for the currently loaded resultset row.
 Workspace getWorkspace()
          Returns null.
 boolean hasRawObjects()
          Returns true if this ResultSet contains real objects, not String representations of the data.
 void init(java.io.Reader reader, DataDecode decoder)
          Initialize the result set from a stream.
 boolean init(Table tble)
          Initialize a result set using a table to constuct its fields.
 void initEx(java.io.Reader reader, DataDecode decoder, boolean isHeaderOnly)
          Initializes the result set from a stream.
 void initShallow(DataResultSet rset)
          Makes a shallow copy of one data result set into another.
 void insertRowAt(java.util.Vector vect, int i)
          Inserts the specified row at the specified index.
 boolean isCopyAborted()
          Indicates whether or not the copy was aborted.
 boolean isEmpty()
          Checks to see if result set is empty.
 boolean isMutable()
          Returns true if it is legal for someone to mutate the contents of this ResultSet.
 boolean isRowPresent()
          Checks to see if we have gone past last valid record.
 boolean last()
          Advances to the last row.
 void merge(java.lang.String colKey, ResultSet rset, boolean replaceOnly)
          This method merges a result set into this object.
 void mergeDelete(java.lang.String colKey, ResultSet rset, boolean isCaseSensitive)
          This method removes the rows from this result set where the colunn value matches a column value in the passed in result set.
 void mergeFields(DataResultSet rset)
          Appends a field to the result set making sure that it is not a duplicate.
 boolean next()
          Advances to the next row.
 boolean previous()
          Sets the result set to the previous row.
 int readHeader(java.io.BufferedReader bReader, DataDecode decoder)
          Parses the column information for the result set from a character stream
 void readSimple(java.io.BufferedReader bReader, DataDecode decoder, boolean isHeaderOnly)
          Parses a result set from a character stream.
 void removeAll()
          Removes all rows from the result set.
 void removeFields(java.lang.String[] fieldNames)
          Removes fields from a DataResulSet.
 boolean renameField(java.lang.String from, java.lang.String to)
          Renames a field from a DataResultSet.
 void reset()
          Resets the result set back to an empty result set, i.e.
 void setCurrentRow(int currentRow)
          Sets the current row to the specified index.
 void setCurrentValue(int index, java.lang.String val)
          Sets the current row values.
 void setDateFormat(IdcDateFormat fmt)
          Sets the IdcDateFormat object for this ResultSet.
 void setRowValues(java.util.Vector vect, int i)
          Sets the specified row values.
 DataResultSet shallowClone()
          Creates a shallow clone of the result set.
 int skip(int numRows)
          Skip number of rows.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_dateFormat

protected IdcDateFormat[] m_dateFormat

m_isMutable

protected boolean m_isMutable

m_fieldMapping

protected java.util.Hashtable m_fieldMapping
Mapping of field name to field information.

See Also:
FieldInfo

m_fieldList

protected java.util.Vector m_fieldList
Vector containing the field or column information in the order in which they appear.

See Also:
FieldInfo

m_values

protected java.util.Vector m_values
Vector containing the values for each row in the result set.


m_currentRow

protected int m_currentRow
The currently selected row.


m_numRows

protected int m_numRows
Number of rows in the result set.


m_copyAborted

protected boolean m_copyAborted
Flag to indicate whether a copy has been prematurely aborted. This is done intentionally and at the request of the user of the result set to stop a copy of a large number of rows. This is primarily used for presentation where a large number of rows would swamp the user interface.

Constructor Detail

DataResultSet

public DataResultSet()
Default constructor.


DataResultSet

public DataResultSet(java.lang.String[] fieldNames)
Used to create a simple in memory data result set.

Parameters:
fieldNames - an array of strings from which the fields/columns will be generated.
Method Detail

isMutable

public boolean isMutable()
Description copied from interface: ResultSet
Returns true if it is legal for someone to mutate the contents of this ResultSet.

Specified by:
isMutable in interface ResultSet

hasRawObjects

public boolean hasRawObjects()
Description copied from interface: ResultSet
Returns true if this ResultSet contains real objects, not String representations of the data. If true, users of this object can directly change things like the date format and the ResultSet will magically change the String representations to match. If false, to change things like the date format the user MUST iterate through the ResultSet and reformat the date values to match the new format. Note that if isMutable() and hasRawObjects() both return false, you CANNOT change the localization of values in this ResultSet. Make a copy into a DataResultSet and change it there.

Specified by:
hasRawObjects in interface ResultSet

setDateFormat

public void setDateFormat(IdcDateFormat fmt)
Description copied from interface: ResultSet
Sets the IdcDateFormat object for this ResultSet. String representations of dates should be in this format.

Specified by:
setDateFormat in interface ResultSet

getDateFormat

public IdcDateFormat getDateFormat()
Description copied from interface: ResultSet
Gets the IdcDateFormat object for this ResultSet.

Specified by:
getDateFormat in interface ResultSet

init

public boolean init(Table tble)
Initialize a result set using a table to constuct its fields.

Parameters:
tble - Table containing column information
Returns:
true if successful.
See Also:
Table

init

public void init(java.io.Reader reader,
                 DataDecode decoder)
          throws java.io.IOException
Initialize the result set from a stream. This is used for serialization.

Parameters:
reader - Character stream containing result set definition and values.
decoder - Mechanism used for parsing escaped characters.
java.io.IOException
See Also:
initEx(java.io.Reader, intradoc.data.DataDecode, boolean), DataDecode, Reader

initEx

public void initEx(java.io.Reader reader,
                   DataDecode decoder,
                   boolean isHeaderOnly)
            throws java.io.IOException
Initializes the result set from a stream.

Parameters:
reader - Character stream containing result set definition and values.
decoder - Mechanism used for parsing escaped characters.
isHeaderOnly - If set to true, reads only the field information and not the values. Useful for determining the definition of a result set.
java.io.IOException
See Also:
readSimple(java.io.BufferedReader, intradoc.data.DataDecode, boolean), DataDecode, Reader

shallowClone

public DataResultSet shallowClone()
Creates a shallow clone of the result set.


initShallow

public void initShallow(DataResultSet rset)
Makes a shallow copy of one data result set into another. In particular, this result set can have an independent iterator and can be independently sorted. But field listings and actual values should will changed the values of the shared copy.


copy

public void copy(ResultSet rset,
                 int maxRows)
Copies a given result set into this result set up to the maximum number of rows (if non-zero). The field variable m_copyAborted is set to true, if the maximum number of rows is reached.

Parameters:
rset - Result set to copy from.
maxRows - If non-zero, indicates the maximum number of rows to copy. Otherwise all rows are copied.

copyEx

public void copyEx(ResultSet rset,
                   int maxRows,
                   boolean useDbFormat)

getResultSetValues

protected java.util.Vector getResultSetValues(ResultSet rset,
                                              int numFields)
Gets the result set values from the result set at the current row.

Parameters:
rset - Result set containing row values.
numFields - The number of field values to copy over.
Returns:
Vector containing the field values.

getResultSetValuesEx

protected java.util.Vector getResultSetValuesEx(ResultSet rset,
                                                int numFields,
                                                boolean useDbFormat)

copy

public void copy(ResultSet rset)
Copies all the rows in the specified result set.

Parameters:
rset - Result set to copy.
See Also:
copy(intradoc.data.ResultSet, int)

copyFiltered

public void copyFiltered(ResultSet rset,
                         java.lang.String key,
                         ResultSetFilter filter)
Copy only the rows that match the criteria as specified by the passed in filter.

Parameters:
rset - Result set to copy.
key - Field name to use for filter.
filter - Filter that determines the criteria a row must match to be copied.
See Also:
ResultSetFilter, copyFilteredEx(intradoc.data.ResultSet, java.lang.String, intradoc.data.ResultSetFilter, boolean), copy(intradoc.data.ResultSet, int)

copySimpleFiltered

public void copySimpleFiltered(ResultSet rset,
                               java.lang.String key,
                               java.lang.String val)
Copy only the rows matching the simple criteria where a specified field must equal a specified value.

Parameters:
rset - Result set to copy
key - Field for simple filter
val - Value for simple filter, i.e. the field value must equal val for the row to be match the filter and be copied.
See Also:
copyFilteredEx(intradoc.data.ResultSet, java.lang.String, intradoc.data.ResultSetFilter, boolean)

createSimpleResultSetFilter

public ResultSetFilter createSimpleResultSetFilter(java.lang.String lookupVal)
Creates a result set filter based on a look up value.

Parameters:
lookupVal - Value to use for lookup.
Returns:
ResultSetFilter
See Also:
SimpleResultSetFilter, ResultSetFilter

createMaxNumResultSetFilter

public ResultSetFilter createMaxNumResultSetFilter(int maxnum)
Creates a filter that limits the number of rows to copy.

Parameters:
maxnum - Maximum number of rows to copy.
Returns:
MaxNumResultSetFilter
See Also:
MaxNumResultSetFilter, ResultSetFilter, copyFiltered(intradoc.data.ResultSet, java.lang.String, intradoc.data.ResultSetFilter)

copyFilteredEx

public void copyFilteredEx(ResultSet rset,
                           java.lang.String key,
                           ResultSetFilter filter,
                           boolean startAtFirst)
Copies a the rows of a specifed result set that match the filter.

Parameters:
rset - Result set to copy from.
key - Column used by filter. The column value will be passed to the filter for each row.
filter - The criteria that a row must match to be copied.
startAtFirst - Flag indicates whether the copied result set will be set to the first row.
See Also:
copy(intradoc.data.ResultSet, int)

isCopyAborted

public boolean isCopyAborted()
Indicates whether or not the copy was aborted. A copy will be aborted when the maximum number of rows has been reached.


copyFieldInfo

public void copyFieldInfo(ResultSet rset)
Copy only the field information of the specified result set into this result set.

Parameters:
rset - Result set to copy from.
See Also:
FieldInfo

merge

public void merge(java.lang.String colKey,
                  ResultSet rset,
                  boolean replaceOnly)
           throws DataException
This method merges a result set into this object. A column with unique entries must be chosen to figure out which rows are copied over and which rows are appended. If no column is specified, then all rows will be appended.

Parameters:
colKey - Column to merge on if non-null. Otherwise all rows in rset will be merged in.
rset - Result set to merge from
replaceOnly - Specifies if this will only do a replace of the existing rows, where existence is determined by colKey. If replaceOnly if false, then rows will be appended.
Throws:
DataException - If the non-null colKey does not exist in either the from or to result set.

mergeDelete

public void mergeDelete(java.lang.String colKey,
                        ResultSet rset,
                        boolean isCaseSensitive)
                 throws DataException
This method removes the rows from this result set where the colunn value matches a column value in the passed in result set.

Parameters:
colKey - Column to use to test for matches.
rset - Result set that should be used as source of rows to remove.
isCaseSensitive - Specifies whether the colunm values should be tested in a case sensitive fashion.
Throws:
DataException - If the colKey does not exist in either the from or to result set.

createEmptyRow

public java.util.Vector createEmptyRow()
Creates an empty row for the result set. This row is not added to the result set.

Returns:
Vector An allocated row with an empty string placed in each field.

findRow

public java.util.Vector findRow(int colIndex,
                                java.lang.String val)
Finds the row whose field value at the given index is equal to the given value.

Parameters:
colIndex - Column index for lookup.
val - Value the column must match.
Returns:
Vector returns the first row whose column matches the value. Otherwise returns null.

appendFields

public void appendFields(java.util.Vector finfo)
Appends columns to the result set.

Parameters:
finfo - Vector containing the field information for the new columns.
See Also:
FieldInfo

mergeFields

public void mergeFields(DataResultSet rset)
Appends a field to the result set making sure that it is not a duplicate. When using this function be careful with localization issues on dates and messages.

Parameters:
rset - Result set containing the fields to append.

removeFields

public void removeFields(java.lang.String[] fieldNames)
Removes fields from a DataResulSet.


renameField

public boolean renameField(java.lang.String from,
                           java.lang.String to)
Renames a field from a DataResultSet. When using this function be careful with localization issues and the DataBinder object (it may not know about the change in the name of this field).

Parameters:
from - Previous name of field.
to - New name of field.
Returns:
Whether the rename succeeded or not.

reset

public void reset()
Resets the result set back to an empty result set, i.e. containing no columns or rows.


removeAll

public void removeAll()
Removes all rows from the result set.


readSimple

public void readSimple(java.io.BufferedReader bReader,
                       DataDecode decoder,
                       boolean isHeaderOnly)
                throws java.io.IOException
Parses a result set from a character stream.

Parameters:
decoder - Mechanism used for parsing escaped characters.
isHeaderOnly - If set to true, reads only the field information and not the values. Useful for determining the definition of a result set.
java.io.IOException
See Also:
DataDecode, BufferedReader

readHeader

public int readHeader(java.io.BufferedReader bReader,
                      DataDecode decoder)
               throws java.io.IOException
Parses the column information for the result set from a character stream

Parameters:
bReader - Character stream containing the result set information
decoder - Mechanism used for parsing escaped characters.
Returns:
The number of fields in the parsed result set.
Throws:
java.io.IOException - If an I/O error occurs.

getCurrentRow

public int getCurrentRow()
Returns the index of the current row.


setCurrentRow

public void setCurrentRow(int currentRow)
Sets the current row to the specified index.


getNumRows

public int getNumRows()
Returns the number of rows in the result set.


getRowValues

public java.util.Vector getRowValues(int index)
Returns the row at the given index.


getCurrentRowValues

public java.util.Vector getCurrentRowValues()
Returns the current row values.


getCurrentRowProps

public java.util.Properties getCurrentRowProps()
Returns the current row as a properties.


setRowValues

public void setRowValues(java.util.Vector vect,
                         int i)
Sets the specified row values.


setCurrentValue

public void setCurrentValue(int index,
                            java.lang.String val)
                     throws DataException
Sets the current row values.

Throws:
DataException - If row does not exist or column index is not valid.

deleteRow

public void deleteRow(int index)
Deletes the specified row.


deleteCurrentRow

public boolean deleteCurrentRow()
Deletes the current row.


addRow

public void addRow(java.util.Vector vect)
Appends the specified row to the result set.


insertRowAt

public void insertRowAt(java.util.Vector vect,
                        int i)
Inserts the specified row at the specified index.


createRow

public java.util.Vector createRow(Parameters params)
                           throws DataException
Creates a row from the passed in values

Parameters:
params - Mapping of columns and values for the new row.
Throws:
DataException - If a column is not found in the params.
See Also:
Parameters

getWorkspace

public Workspace getWorkspace()
Returns null. Implementation of the ResultSet interface

See Also:
ResultSet

getNumFields

public int getNumFields()
Returns number of fields. Implementation of the ResultSet interface.

Specified by:
getNumFields in interface ResultSet
Returns:
Number of fields in result set.
See Also:
ResultSet

isEmpty

public boolean isEmpty()
Checks to see if result set is empty. Implementation of the ResultSet interface.

Specified by:
isEmpty in interface ResultSet
Returns:
True if result set has no rows.
See Also:
ResultSet

isRowPresent

public boolean isRowPresent()
Checks to see if we have gone past last valid record. Implementation of the ResultSet interface.

Specified by:
isRowPresent in interface ResultSet
Returns:
True if on a row with data in it.
See Also:
ResultSet

getFieldName

public java.lang.String getFieldName(int index)
Gets the name of field located at a particular field index (from 0 to getNumFields() - 1). Implementation of the ResultSet interface.

Specified by:
getFieldName in interface ResultSet
Parameters:
index - Index into array of fields associated with this result set.
Returns:
Name of field at this index.
See Also:
ResultSet

getFieldInfo

public boolean getFieldInfo(java.lang.String fieldName,
                            FieldInfo fieldInfo)
Gets field information for a particular field. Returns false if no field information was present. Implementation of the ResultSet interface.

Specified by:
getFieldInfo in interface ResultSet
Parameters:
fieldName - Name of field being looked up.
fieldInfo - Holds information about the field after this method is called. Note: fieldInfo.m_index will hold the field index usable as a parameter to the calls 'getStringValue' and 'getDateValue'.
Returns:
True if field information was found, false otherwise.
See Also:
ResultSet

getIndexFieldInfo

public void getIndexFieldInfo(int index,
                              FieldInfo fieldInfo)
Gets field information for a particular field at a specified index. Implementation of the ResultSet interface.

Specified by:
getIndexFieldInfo in interface ResultSet
Parameters:
index - Index into array of fields assocated with this result set.
fieldInfo - Holds information about the field after this method is called.
See Also:
ResultSet

getStringValue

public java.lang.String getStringValue(int index)
Gets the value for a current field as a string for the currently loaded resultset row. Implementation of the ResultSet interface.

Specified by:
getStringValue in interface ResultSet
Parameters:
index - Index into array of fields assocated with this result set.
Returns:
Value of field as a Unicode string.
See Also:
ResultSet

getDateValue

public java.util.Date getDateValue(int index)
Gets the field value as a date, only works for fields which are actually dates. A date does not as easily convert from a string and back again as the other data types. Implementation of the ResultSet interface.

Specified by:
getDateValue in interface ResultSet
Parameters:
index - Index into array of fields assocated with this result set.
Returns:
Value of field as a Date object.
See Also:
ResultSet

next

public boolean next()
Advances to the next row. Returns false if there is no next row. Implementation of the ResultSet interface.

Specified by:
next in interface ResultSet
Returns:
True if there was a next row after this one, false otherwise.
See Also:
ResultSet

previous

public boolean previous()
Sets the result set to the previous row. Returns false if it is on the first row.


first

public boolean first()
Sets the result set to the first row. Implementation of the ResultSet interface.

Specified by:
first in interface ResultSet
Returns:
Returns false if the result set is empty.
See Also:
ResultSet

last

public boolean last()
Advances to the last row. Returns false if there are no rows.


skip

public int skip(int numRows)
Skip number of rows. Note, since this is bi-directional ResultSet. Skipping does not remove these rows from the ResultSet.

Specified by:
skip in interface ResultSet
Returns:
Returns number of row skipped.

closeInternals

public void closeInternals()
Closes the result set. Because of bugs with implementations of result sets (specifically JDBC), we may need to close the internal objects early. Implementation of the ResultSet interface.

Specified by:
closeInternals in interface ResultSet
See Also:
ResultSet

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


(c) 1996-2005  All rights reserved.  Stellent, Inc.