|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.objectwave.persist.objectConstruction.ProcessResultSet
A utitlity class that converts a database result set into a collection of objects.
processResults(java.lang.Object[], java.sql.ResultSet, com.objectwave.persist.SQLQuery, com.objectwave.persist.sqlConstruction.SQLSelect, com.objectwave.persist.CollectionAdapter)
Nested Class Summary | |
static class |
ProcessResultSet.Test
Unit tests. |
Constructor Summary | |
ProcessResultSet()
|
Method Summary | |
protected boolean |
buildAttributes(Persistence obj,
RDBPersistence refObj,
RDBPersistence originalObject,
RDBPersistence orgRef,
java.lang.Object[] record)
Set all of the attribute values that were found from the query. |
void |
buildCollectionProxies(Persistence obj,
RDBPersistence refObj,
RDBPersistence origObj,
RDBPersistence orgRef)
Create a SQLQuery object that will find the elements in this collection. |
Persistence |
buildFkProxy(AttributeTypeColumn col,
java.lang.Object[] joinValues,
Persistence obj,
RDBPersistence pObj,
RDBPersistence refObj)
Build proxy for ForeignKey references. |
protected void |
buildForeignKeyObjects(Persistence obj,
RDBPersistence refObj,
RDBPersistence origObj,
RDBPersistence orgRef,
java.lang.Object[] record)
Fill all the foreign key instance variables in obj as defined in the foreign key map. |
protected void |
buildInstanceLinkObjects(Persistence obj,
RDBPersistence refObj,
RDBPersistence origObj,
RDBPersistence orgRef,
java.lang.Object[] record)
Fill all the instance link instance variables in obj as defined in the instance link map. |
Persistence |
buildObject(RDBPersistence refObj,
RDBPersistence origObj,
RDBPersistence origRef,
java.lang.Object[] dataRow)
Builds a new object from the data in record. |
Persistence |
buildProxy(AttributeTypeColumn col,
java.lang.Object primaryKeyField,
RDBPersistence pObj,
RDBPersistence refObj)
Build a proxy for an instance link. |
protected Persistence |
checkObjectPool(Persistence obj,
RDBPersistence refObj,
RDBPersistence originalObject,
RDBPersistence orgRef,
java.lang.Object[] record)
See if we can find the Obj in the object pool. |
protected Persistence |
createNewObject(RDBPersistence refObj,
RDBPersistence pObj,
RDBPersistence origRef,
java.lang.Object[] dataRow)
Create a new object of the correct class. |
protected Persistence |
determineAndCreateInstance(RDBPersistence refObj,
RDBExtendablePersistentAdapter origObj,
java.lang.Object[] dataRow)
The first data element should be the type id of the class. |
protected java.lang.Object |
determinePrimaryKey(java.lang.Object primaryKey,
AttributeTypeColumn col)
Ignore primary keys that are blank or zero. |
protected int |
getAttributeCount(RDBPersistence pObj,
java.lang.Object refObj)
Convience method to count the number of pObj attributeColumns. |
protected java.lang.Object[] |
getAttributeData(java.lang.Object[] objArrays,
java.lang.Object[] record,
int size,
int start)
Deprecated. No long used. |
static ProcessResultSet |
getInstance(java.lang.String instanceType)
We don't want singleton instances. |
protected Persistence |
getNewInstance(AttributeTypeColumn column,
RDBPersistence refObj)
|
ObjectPool |
getObjectPool()
|
protected int |
getPrimaryKeyCount(RDBPersistence pObj,
java.lang.Object refObj)
Convience method to count the number of pObj primaryKeyColumns. |
protected boolean |
isDifferentType(Persistence oneObject,
RDBPersistence secondObject)
If the class of oneObject is the same as the class of secondObject.getDomainObject() then return false, otherwise return true. |
protected boolean |
isMatch(AttributeTypeColumn col,
RDBPersistence refObj,
java.lang.Object[] values)
A foreign key attribute type column has found a reference object, our values may point to this instance. |
protected boolean |
isPrimitiveZero(java.lang.String pkString,
AttributeTypeColumn col)
is a primitive and value is zero |
protected void |
populateJoinFields(JoinField[] fields,
java.lang.Object[] data,
Persistence newObject,
RDBPersistence adapter)
Fill in the fields on the other object with the correct values |
static void |
println(java.lang.String str)
Utility method to assist with migration to logger interface. |
CollectionAdapter |
processResults(java.lang.Object[] objArrays,
java.sql.ResultSet set,
SQLQuery obj,
SQLSelect sqlObj,
CollectionAdapter adapt)
Main entry point for this class. |
void |
setBrokerProperty(BrokerPropertyIF b)
|
void |
setObjectFormatter(ObjectFormatter of)
An object formatter is used to convert data from one type to another. |
void |
setObjectPool(ObjectPool p)
|
protected boolean |
setVals(AttributeTypeColumn[] allCols,
JoinField[] fields,
java.lang.Object[] data,
Persistence newObject)
|
void |
updateBackReferences(Persistence obj,
RDBPersistence origObj,
RDBPersistence refObj)
This is used only be objects generated by the createInstance() method of RDBExtendablePersitentAdapter objects. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ProcessResultSet()
Method Detail |
public static ProcessResultSet getInstance(java.lang.String instanceType)
instanceType
-
public static void println(java.lang.String str)
str
- public void setObjectFormatter(ObjectFormatter of)
of
- The formatter this class is to use.public void setBrokerProperty(BrokerPropertyIF b)
b
- The new BrokerProperty valuepublic void setObjectPool(ObjectPool p)
p
- The new ObjectPool valueprotected boolean setVals(AttributeTypeColumn[] allCols, JoinField[] fields, java.lang.Object[] data, Persistence newObject)
allCols
- The new Vals valuefields
- The new Vals valuedata
- The new Vals valuenewObject
- The new Vals value
public ObjectPool getObjectPool()
protected boolean isDifferentType(Persistence oneObject, RDBPersistence secondObject)
oneObject
- secondObject
-
protected boolean isPrimitiveZero(java.lang.String pkString, AttributeTypeColumn col)
pkString
- A string retrieved from the databasecol
-
protected int getAttributeCount(RDBPersistence pObj, java.lang.Object refObj)
pObj
- refObj
-
protected int getPrimaryKeyCount(RDBPersistence pObj, java.lang.Object refObj)
pObj
- refObj
-
protected java.lang.Object[] getAttributeData(java.lang.Object[] objArrays, java.lang.Object[] record, int size, int start)
objArrays
- Object [] of cached Object arrays. This is to minimize
allocation and deallocation of Object arrays.record
- size
- start
-
protected Persistence getNewInstance(AttributeTypeColumn column, RDBPersistence refObj) throws java.lang.InstantiationException, java.lang.IllegalAccessException
column
- refObj
-
java.lang.InstantiationException
java.lang.IllegalAccessException
protected boolean isMatch(AttributeTypeColumn col, RDBPersistence refObj, java.lang.Object[] values)
col
- refObj
- values
-
public void buildCollectionProxies(Persistence obj, RDBPersistence refObj, RDBPersistence origObj, RDBPersistence orgRef) throws java.lang.InstantiationException, java.lang.IllegalAccessException
obj
- Persistence The object we are buliding.refObj
- origObj
- orgRef
-
java.lang.InstantiationException
java.lang.IllegalAccessException
public Persistence buildObject(RDBPersistence refObj, RDBPersistence origObj, RDBPersistence origRef, java.lang.Object[] dataRow) throws java.lang.InstantiationException, java.lang.IllegalAccessException
refObj
- is the object that was retrieved and build because of the
presence of orgRef. It must reference the new object in the new object
structure and the new object may have to reference it back.origObj
- origRef
- dataRow
-
java.lang.InstantiationException
java.lang.IllegalAccessException
public Persistence buildFkProxy(AttributeTypeColumn col, java.lang.Object[] joinValues, Persistence obj, RDBPersistence pObj, RDBPersistence refObj) throws java.lang.InstantiationException, java.lang.IllegalAccessException
obj
- The Persistence object being built.pObj
- The RDBPersistent adapter for the object being built.col
- The column on the object being built that is to contain the
proxy.refObj
- If I'm part of a Join, this is the object from which this
build process has begunjoinValues
-
java.lang.InstantiationException
java.lang.IllegalAccessException
public Persistence buildProxy(AttributeTypeColumn col, java.lang.Object primaryKeyField, RDBPersistence pObj, RDBPersistence refObj) throws java.lang.InstantiationException, java.lang.IllegalAccessException
col
- primaryKeyField
- pObj
- refObj
-
java.lang.InstantiationException
java.lang.IllegalAccessException
public CollectionAdapter processResults(java.lang.Object[] objArrays, java.sql.ResultSet set, SQLQuery obj, SQLSelect sqlObj, CollectionAdapter adapt) throws java.sql.SQLException, java.lang.InstantiationException, java.lang.IllegalAccessException
adapt
- CollectionAdapter The adapter to use in place of the default
adapter.objArrays
- Only two methods actually use the objArrays. This one to
contain the full result set of data. buildAttributes to contain the
converted data values.set
- obj
- sqlObj
-
java.sql.SQLException
java.lang.InstantiationException
java.lang.IllegalAccessException
public void updateBackReferences(Persistence obj, RDBPersistence origObj, RDBPersistence refObj)
obj
- com.objectwave.persist.PersistenceorigObj
- com.objectwave.persist.RDBPersistencerefObj
- protected void populateJoinFields(JoinField[] fields, java.lang.Object[] data, Persistence newObject, RDBPersistence adapter)
fields
- data
- newObject
- adapter
- protected Persistence determineAndCreateInstance(RDBPersistence refObj, RDBExtendablePersistentAdapter origObj, java.lang.Object[] dataRow) throws java.lang.InstantiationException, java.lang.IllegalAccessException
origObj
- refObj
- dataRow
-
java.lang.InstantiationException
java.lang.IllegalAccessException
protected boolean buildAttributes(Persistence obj, RDBPersistence refObj, RDBPersistence originalObject, RDBPersistence orgRef, java.lang.Object[] record)
obj
- refObj
- originalObject
- orgRef
- record
-
protected void buildForeignKeyObjects(Persistence obj, RDBPersistence refObj, RDBPersistence origObj, RDBPersistence orgRef, java.lang.Object[] record) throws java.lang.InstantiationException, java.lang.IllegalAccessException
orgRef
- The object from the search object that was referencing
originalObject. It is needed to retrieve the same maps as we did when
the select statement was build.refObj
- The object that was retrieved and build because of the
presence of orgRef. It must reference obj in the new object structure
and obj may have to reference it back.obj
- origObj
- record
-
java.lang.InstantiationException
java.lang.IllegalAccessException
protected void buildInstanceLinkObjects(Persistence obj, RDBPersistence refObj, RDBPersistence origObj, RDBPersistence orgRef, java.lang.Object[] record) throws java.lang.InstantiationException, java.lang.IllegalAccessException
obj
- refObj
- origObj
- orgRef
- record
-
java.lang.InstantiationException
java.lang.IllegalAccessException
- @ param orgRef The object from the search
object that was referencing originalObject. It is needed to retrieve
the same maps as we did when the select statement was build. @ param
refObj The object that was retrieved and build because of the presence
of orgRef. It must reference obj in the new object structure and obj
may have to reference it back.protected Persistence checkObjectPool(Persistence obj, RDBPersistence refObj, RDBPersistence originalObject, RDBPersistence orgRef, java.lang.Object[] record)
obj
- refObj
- originalObject
- orgRef
- record
-
protected Persistence createNewObject(RDBPersistence refObj, RDBPersistence pObj, RDBPersistence origRef, java.lang.Object[] dataRow) throws java.lang.InstantiationException, java.lang.IllegalAccessException
refObj
- is the object that was retrieved and build because of the
presence of orgRef. It must reference the new object in the new object
structure and the new object may have to reference it back.pObj
- origRef
- dataRow
-
java.lang.InstantiationException
java.lang.IllegalAccessException
protected java.lang.Object determinePrimaryKey(java.lang.Object primaryKey, AttributeTypeColumn col)
primaryKey
- The original value for the primary key.col
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |