|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.iplanet.jato.model.DefaultModel | +--com.iplanet.jato.model.sql.ResultSetModelBase
Model base class that provides significant functionality to cope with the vagaries of JDBC result sets as a model data stores. This primary value this class adds is in caching of result set data, thus providing bidirectional and repeatable access to that data. This implementation caches result set data for two reasons. First, basic JDBC drivers only provide unidirectional reading of result set data. Additionally, such drivers don't allow multiple reads of result set data. Both of these factors amount to significant difficulty when developing with vanilla JDBC. Second, the result set may not be available for the entire life of this model, but the data may be needed for the life of this model. This model attempts to be as efficient as possible in its operation, including in its implementation of data caching. By specifying detailed operation information via execution contexts, users of this model can specify exactly how they want data to be fetched and cached.
Inner classes inherited from class com.iplanet.jato.model.DefaultModel |
DefaultModel.Context, DefaultModel.RowValueArrayList |
Field Summary | |
protected static boolean |
DEBUG_NEXTROW
|
protected static boolean |
DEBUG_POS_RESULTSET
|
protected static boolean |
DEBUG_SYNCROW
|
protected static boolean |
DEBUG_UPDATE_MODEL
|
protected static boolean |
OPTION_COERCE_CACHED_RESULT_SET_VALUES
|
protected static boolean |
OPTION_COERCE_VALUE_TYPES
|
protected static int |
SYNCROW_ALREADY_SYNCHRONIZED
|
protected static int |
SYNCROW_FOUND_DATA
|
protected static int |
SYNCROW_NO_MORE_DATA
|
Fields inherited from class com.iplanet.jato.model.DefaultModel |
DEFAULT_CONTEXT_NAME, UNDEFINED_ROW_INDEX |
Constructor Summary | |
ResultSetModelBase()
Default constructor |
|
ResultSetModelBase(QueryFieldSchema schema)
Create an instance with the specified field schema |
Method Summary | |
void |
beforeFirst()
Moves the internal location iterator to a special position such that a call to next() will position the location at the first row (if
available). |
void |
clear()
Clears all values (from all rows) in this model |
protected void |
clearResultSet()
|
boolean |
first()
Moves the internal location iterator to the first available row. |
java.lang.Class |
getFieldClass(java.lang.String name)
|
QueryFieldSchema |
getFieldSchema()
Returns the field schema used to resolve logical field references to physical field references |
int |
getLocation()
Returns the current row index |
int |
getLocationOffset()
Returns the offset of the first row of data |
java.sql.ResultSet |
getResultSet()
Returns the current result set |
int |
getSize()
Depending on the circumstances under which this model was executed (as specified by the execution context), returns the number of rows of data available from the result set. |
protected java.util.Map |
getValueMap(int row)
Returns the value map for the specified row. |
boolean |
hasMoreResults()
|
boolean |
hasPreviousResults()
|
boolean |
hasValue(java.lang.String name)
Returns whether a value exists for the specified name |
boolean |
last()
Moves the internal location iterator to the last available row. |
boolean |
next()
Moves the internal location iterator to the next available row |
protected void |
positionResultSet(DatasetModelExecutionContext context)
This method is only intended to be called after a SELECT query has been executed and the new result set has been cached. |
protected void |
positionResultSet(int offset,
int numRows)
This method is only intended to be called after a SELECT query has been executed and the new result set has been cached. |
boolean |
previous()
Moves the internal location iterator to the previous available row |
protected void |
resolveResultSetColumnSet()
|
void |
setFieldSchema(QueryFieldSchema value)
Sets the field schema used to resolve logical field references to physical field references |
void |
setLocation(int location)
Sets the current row index |
protected void |
setLocationOffset(int value)
|
protected void |
setMoreResults(boolean value)
|
protected void |
setPreviousResults(boolean value)
|
void |
setResultSet(java.sql.ResultSet value)
Sets the current result set |
void |
setSize(int value)
Because this model uses a result set as a backing data store, this method cannot be used in this class. |
void |
setValue(java.lang.String name,
java.lang.Object value)
Sets a named value in this model. |
void |
setValues(java.lang.String name,
java.lang.Object[] values)
Sets a named set of values in this model |
protected int |
synchronizeRow(int row)
This method copies data from the ResultSet to the model. |
protected void |
updateModel()
Reads the data from the current result set row into the model's cache. |
Methods inherited from class com.iplanet.jato.model.DefaultModel |
addContext, appendRow, checkRowIndex, clearModelData, createValueMap, dumpValues, dumpValues, ensureRow, getContext, getContextNames, getCurrentContext, getCurrentContextName, getDefaultValue, getDefaultValueMap, getDefaultValues, getName, getNumRows, getRowIndex, getRowList, getValue, getValueMap, getValues, initializeDefaultContext, insertRow, isDefaultContext, isUseDefaultValues, removeContext, selectContext, selectDefaultContext, setDefaultValue, setDefaultValues, setName, setNumRows, setRowIndex, setRowList, setUseDefaultValues |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final int SYNCROW_NO_MORE_DATA
protected static final int SYNCROW_ALREADY_SYNCHRONIZED
protected static final int SYNCROW_FOUND_DATA
protected static final boolean OPTION_COERCE_VALUE_TYPES
protected static final boolean OPTION_COERCE_CACHED_RESULT_SET_VALUES
protected static final boolean DEBUG_UPDATE_MODEL
protected static final boolean DEBUG_SYNCROW
protected static final boolean DEBUG_NEXTROW
protected static final boolean DEBUG_POS_RESULTSET
Constructor Detail |
public ResultSetModelBase()
public ResultSetModelBase(QueryFieldSchema schema)
Method Detail |
public java.sql.ResultSet getResultSet()
public void setResultSet(java.sql.ResultSet value)
protected void resolveResultSetColumnSet() throws java.sql.SQLException
public QueryFieldSchema getFieldSchema()
public void setFieldSchema(QueryFieldSchema value)
public int getSize() throws ModelControlException
Very unfortunately, JDBC doesn't give us a way to determine the number of rows a query returned. Therefore, this method can only return the actual number of rows of data returned by a query if the entire result set is read and cached after execution. If a query is executed using the incremental fetch directive, the number of rows will not be available. In this case, this method simply returns -1.
getSize
in class DefaultModel
com.iplanet.jato.model.DefaultModel
ModelControlException
- Thrown if an error occurrs determining the number of rowspublic void setSize(int value) throws ModelControlException
ModelControlException
if called.setSize
in class DefaultModel
com.iplanet.jato.model.DefaultModel
ModelControlException
- Thrown if an error occurrs setting the number of rowspublic int getLocation() throws ModelControlException
DefaultModel
getLocation
in class DefaultModel
com.iplanet.jato.model.DefaultModel
ModelControlException
- Thrown if an error occurrs determining the current locationpublic void setLocation(int location) throws ModelControlException
DefaultModel
setLocation
in class DefaultModel
com.iplanet.jato.model.DefaultModel
ModelControlException
- Thrown if an error occurrs setting the current locationprotected int synchronizeRow(int row) throws java.sql.SQLException
row
- The row number up to which to cache result set datapublic void beforeFirst() throws ModelControlException
DefaultModel
next()
will position the location at the first row (if
available). Normally, a call to getLocation()
after this method
is called should return negative one (-1).beforeFirst
in class DefaultModel
com.iplanet.jato.model.DefaultModel
ModelControlException
- Thrown if an error occurrs setting the location to this special
positionpublic boolean first() throws ModelControlException
DefaultModel
getLocation()
after this method is called should return zero
(0).first
in class DefaultModel
com.iplanet.jato.model.DefaultModel
ModelControlException
- Thrown if an error occurrs moving to the first datasetpublic boolean last() throws ModelControlException
DefaultModel
getLocation()
after this method is called should return
getSize()-1
.last
in class DefaultModel
com.iplanet.jato.model.DefaultModel
ModelControlException
- Thrown if an error occurrs moving to the last rowpublic boolean next() throws ModelControlException
DefaultModel
next
in class DefaultModel
com.iplanet.jato.model.DefaultModel
ModelControlException
- Thrown if an error occurrs positioning at the next rowpublic boolean previous() throws ModelControlException
DefaultModel
previous
in class DefaultModel
com.iplanet.jato.model.DefaultModel
ModelControlException
- Thrown if an error occurrs positioning at the previous rowpublic java.lang.Class getFieldClass(java.lang.String name)
public boolean hasValue(java.lang.String name)
DefaultModel
hasValue
in class DefaultModel
com.iplanet.jato.model.DefaultModel
The
- name of the value to testpublic void setValue(java.lang.String name, java.lang.Object value)
DefaultModel
setValue
in class DefaultModel
com.iplanet.jato.model.DefaultModel
name
- The name of the value to setvalue
- The value to set in this modelpublic void setValues(java.lang.String name, java.lang.Object[] values)
DefaultModel
setValues
in class DefaultModel
com.iplanet.jato.model.DefaultModel
name
- The name of the value set to set in the modelvalues
- The set of values to set in this modelpublic void clear()
DefaultModel
clear
in class DefaultModel
protected void clearResultSet()
public int getLocationOffset()
DefaultModel
getLocationOffset
in class DefaultModel
com.iplanet.jato.model.DefaultModel
protected void setLocationOffset(int value)
protected void positionResultSet(DatasetModelExecutionContext context) throws java.sql.SQLException
protected void positionResultSet(int offset, int numRows) throws java.sql.SQLException
public boolean hasPreviousResults()
true
if there are additional results
available before the beginning of the current datasetprotected void setPreviousResults(boolean value)
public boolean hasMoreResults()
true
if there are additional results
available beyond the end of the current datasetprotected void setMoreResults(boolean value)
protected java.util.Map getValueMap(int row)
DefaultModel
getValueMap
in class DefaultModel
protected void updateModel() throws java.sql.SQLException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |