Stellent
HowToComponents
JavaDoc

intradoc.data
Class ResultSetUtils

java.lang.Object
  |
  +--intradoc.data.ResultSetUtils

public class ResultSetUtils
extends java.lang.Object

Utilities to simplify the retrieving and manipulation of data in result sets.


Constructor Summary
ResultSetUtils()
           
 
Method Summary
static java.util.Vector createFieldInfo(java.lang.String[] fields, int defLen)
          Creates a dummy array of FieldInfo objects each of which is set to the specified length.
static java.lang.String[][] createFilteredStringTable(ResultSet rset, java.lang.String[] keys, java.lang.String filterVal)
          Service creates a two dimensional string array based on some keys and a filter.
static FieldInfo[] createInfoList(ResultSet rset, java.lang.String[] fields, boolean mustExist)
          Returns an array of FieldInfo objects corresponding to the array of fields in the 'fields' parameter.
static DataResultSet createResultSetFromProperties(java.util.Properties props)
           
static DataResultSet createResultSetFromProperties(java.util.Properties props, java.lang.String[] keys)
           
static java.lang.String[][] createStringTable(ResultSet rset, java.lang.String[] keys)
          Service creates a two dimensional string array based on fields specified by an array of keys.
static java.lang.String findValue(ResultSet rset, java.lang.String lookupKey, java.lang.String lookupFilter, java.lang.String resultKey)
          Gets a value from a particular field from the first row that satisfies equality test criteria on another field and its value.
static java.util.Date getDateValue(ResultSet rset, java.lang.String key)
           
static int getIndexMustExist(ResultSet rset, java.lang.String key)
          Gets the field index for a field.
static java.lang.String getValue(ResultSet rset, java.lang.String key)
          Gets the value of a field for the current row of a result set.
static java.util.Vector loadValuesFromSet(ResultSet rset, java.lang.String lookupKey)
          Extracts all the values for a particular field in a result set.
static java.util.Vector loadValuesFromSetEx(ResultSet rset, java.lang.String lookupKey, boolean mustExist)
          Extracts all the values for a particular field in a result set.
static void sortResultSet(DataResultSet rset, java.lang.String[] keys)
          Sorts a result set using the values of fields in the result set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultSetUtils

public ResultSetUtils()
Method Detail

createFilteredStringTable

public static java.lang.String[][] createFilteredStringTable(ResultSet rset,
                                                             java.lang.String[] keys,
                                                             java.lang.String filterVal)
                                                      throws DataException
Service creates a two dimensional string array based on some keys and a filter. The first key is the filter key and only rows whose column identified by the first key with value equal to 'filterVal' will be returned. Only the non filter keys are returned in the table.

Parameters:
rset - The result set containing the values to be retrieved. Search starts from first row and leaves the result set after the last row.
keys - An array with the first element being the filter key and the other elements being the columns that should be returned as a row in the two dimensional string array of values extracted.
filterVal - If null, all rows are extracted. If not null, then the value of the field 'keys[0]' is compared against this parameter and if they are equal the fields 'keys[1] ... keys[keys.length - 1]' are extracted and a string array holding these values is added to the two dimensional string array being returned.
Returns:
A two dimensional array with each row in the array containing values for the specified fields.
Throws:
DataException - Thrown if one of the values in the 'keys' array is not in the result set.

createStringTable

public static java.lang.String[][] createStringTable(ResultSet rset,
                                                     java.lang.String[] keys)
                                              throws DataException
Service creates a two dimensional string array based on fields specified by an array of keys. This is a simplified version of createFilteredStringTable

Parameters:
rset - The result set containing the values to be retrieved.
keys - An array containing the columns that should be returned as a row in the two dimensional string array of values extracted. If null, all columns in order are returned.
Returns:
A two dimensional array with each row in the array containing values for the specified fields.
Throws:
DataException - Thrown if one of the fields cannot be found.
See Also:
createFilteredStringTable(intradoc.data.ResultSet, java.lang.String[], java.lang.String)

createInfoList

public static FieldInfo[] createInfoList(ResultSet rset,
                                         java.lang.String[] fields,
                                         boolean mustExist)
                                  throws DataException
Returns an array of FieldInfo objects corresponding to the array of fields in the 'fields' parameter.

Parameters:
rset - The result set holding information about the fields it contains.
fields - An array of field names for which information should be returned. If null, field values for all columns in order are returned.
mustExist - If true, throw a DataException if field is not in result set.
Returns:
Array of FieldInfo objects containing information about the fields requested.
Throws:
DataException - Thrown if 'mustExist' is true and a field was not found.

getValue

public static java.lang.String getValue(ResultSet rset,
                                        java.lang.String key)
Gets the value of a field for the current row of a result set.

Parameters:
rset - The result set that has been set to a particular row.
key - The field name of a column in the result set whose value is requested.
Returns:
The value of the field on the current row. Returns null if field is not found or not on a valid row.

getDateValue

public static java.util.Date getDateValue(ResultSet rset,
                                          java.lang.String key)

getIndexMustExist

public static int getIndexMustExist(ResultSet rset,
                                    java.lang.String key)
                             throws DataException
Gets the field index for a field.

Parameters:
rset - The result set that has been set to a particular row.
key - The field name of a column in the result set.
Returns:
The field index at which the field is located.
Throws:
DataException - Thrown if field is not in result set.

findValue

public static java.lang.String findValue(ResultSet rset,
                                         java.lang.String lookupKey,
                                         java.lang.String lookupFilter,
                                         java.lang.String resultKey)
                                  throws DataException
Gets a value from a particular field from the first row that satisfies equality test criteria on another field and its value. This method is implemented using 'createFilteredStringTable'.

Parameters:
rset - The result set being searched. Search starts from first row.
lookupKey - The field whose value should be tested.
lookupFilter - The value that the field 'lookupKey' should have before the row is deemed to have satisfied the criteria.
resultKey - The field whose value should be returned for the first row satisfying the criteria.
Throws:
DataException - Thrown if one of the fields specified is not in the result set.

loadValuesFromSetEx

public static java.util.Vector loadValuesFromSetEx(ResultSet rset,
                                                   java.lang.String lookupKey,
                                                   boolean mustExist)
                                            throws DataException
Extracts all the values for a particular field in a result set.

Parameters:
rset - Result set holding values to be extracted.
lookupKey - The field whose value is desired.
mustExist - If true, the lookupKey must exist in the result set.
Returns:
A Vector of field values, one for each row in the result set.
Throws:
DataException - Thrown if lookupKey is not a field in the result set.

loadValuesFromSet

public static java.util.Vector loadValuesFromSet(ResultSet rset,
                                                 java.lang.String lookupKey)
                                          throws DataException
Extracts all the values for a particular field in a result set.

Parameters:
rset - Result set holding values to be extracted.
lookupKey - The field whose value is desired.
Returns:
A Vector of field values, one for each row in the result set.
Throws:
DataException - Thrown if lookupKey is not a field in the result set.

sortResultSet

public static void sortResultSet(DataResultSet rset,
                                 java.lang.String[] keys)
                          throws DataException
Sorts a result set using the values of fields in the result set. The values for each row are compared in the order in the array 'keys'. If one value follows another then the one row follows the other in the sort.

Parameters:
rset - A DataResultSet whose rows are to be sorted. After the method is finished this parameter will contained the result set, but ordered by using the values of the fields listed in the parameter keys.
keys - The fields to be compared. The order of the fields determines the order of comparison.
Throws:
DataException - Thrown if one the fields is not in the result set.

createFieldInfo

public static java.util.Vector createFieldInfo(java.lang.String[] fields,
                                               int defLen)
Creates a dummy array of FieldInfo objects each of which is set to the specified length. The values of these FieldInfo objects can be filled in with additional values before being used (for example this method is sometimes used before a creating a database table).

Parameters:
fields - The field names for each of the FieldInfo objects to be created.
defLen - The default length to set for each FieldInfo object. If the length is greater than zero, then the FieldInfo 'm_isFixedLen' attribute is set to true.
Returns:
A Vector of FieldInfo objects.
See Also:
Workspace.createTable(java.lang.String, intradoc.data.FieldInfo[], java.lang.String[]), Workspace.alterTable(java.lang.String, intradoc.data.FieldInfo[], java.lang.String[], java.lang.String[])

createResultSetFromProperties

public static DataResultSet createResultSetFromProperties(java.util.Properties props)

createResultSetFromProperties

public static DataResultSet createResultSetFromProperties(java.util.Properties props,
                                                          java.lang.String[] keys)


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