Package org.apache.openjpa.kernel
Class AbstractPCResultObjectProvider
- java.lang.Object
-
- org.apache.openjpa.kernel.AbstractPCResultObjectProvider
-
- All Implemented Interfaces:
PCResultObjectProvider
,ResultObjectProvider
,Closeable
public abstract class AbstractPCResultObjectProvider extends java.lang.Object implements PCResultObjectProvider
Abstract implementation ofPCResultObjectProvider
that implementsResultObjectProvider.getResultObject()
by assembling the necessary information about the object to be loaded.- Author:
- Patrick Linskey
-
-
Field Summary
Fields Modifier and Type Field Description protected StoreContext
ctx
TheStoreContext
that this result object provider will load objects into.
-
Constructor Summary
Constructors Constructor Description AbstractPCResultObjectProvider(StoreContext ctx)
Create a new provider for loading PC objects from the input intoctx
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
absolute(int pos)
Override if desired.void
close()
Override if desired.StoreContext
getContext()
Return the context this provider was constructed with.protected abstract java.lang.Object
getObjectId(ClassMetaData meta)
Implement this method to extract the object id value from the current record of the input.protected abstract java.lang.Class
getPCType()
Implement this method to extract the type of the pc stored in the current record of the input.java.lang.Object
getResultObject()
Instantiate the current result object.void
handleCheckedException(java.lang.Exception e)
Throws aStoreException
by default.void
initialize(OpenJPAStateManager sm, PCState state, FetchConfiguration fetch)
Initializes the state manager.protected abstract void
load(OpenJPAStateManager sm, FetchConfiguration fetch)
Load data from the current input record into the given state manager.abstract boolean
next()
Implement this method to advance the input.void
open()
Override if desired.void
reset()
Override if desired.int
size()
Override if desired.boolean
supportsRandomAccess()
Override if desired.
-
-
-
Field Detail
-
ctx
protected final StoreContext ctx
TheStoreContext
that this result object provider will load objects into.
-
-
Constructor Detail
-
AbstractPCResultObjectProvider
public AbstractPCResultObjectProvider(StoreContext ctx)
Create a new provider for loading PC objects from the input intoctx
.
-
-
Method Detail
-
getContext
public StoreContext getContext()
Return the context this provider was constructed with.
-
initialize
public void initialize(OpenJPAStateManager sm, PCState state, FetchConfiguration fetch) throws java.lang.Exception
Description copied from interface:PCResultObjectProvider
Initializes the state manager.- Specified by:
initialize
in interfacePCResultObjectProvider
- Throws:
java.lang.Exception
- See Also:
StoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
-
getResultObject
public java.lang.Object getResultObject() throws java.lang.Exception
Description copied from interface:ResultObjectProvider
Instantiate the current result object. This method will only be called afterResultObjectProvider.next()
orResultObjectProvider.absolute(int)
.- Specified by:
getResultObject
in interfaceResultObjectProvider
- Throws:
java.lang.Exception
-
getObjectId
protected abstract java.lang.Object getObjectId(ClassMetaData meta) throws java.lang.Exception
Implement this method to extract the object id value from the current record of the input.- Throws:
java.lang.Exception
-
getPCType
protected abstract java.lang.Class getPCType() throws java.lang.Exception
Implement this method to extract the type of the pc stored in the current record of the input.- Throws:
java.lang.Exception
-
load
protected abstract void load(OpenJPAStateManager sm, FetchConfiguration fetch) throws java.lang.Exception
Load data from the current input record into the given state manager. Remember to callOpenJPAStateManager.setVersion(java.lang.Object)
to set the optimistic versioning information, if it has any.- Throws:
java.lang.Exception
-
open
public void open() throws java.lang.Exception
Override if desired. Does nothing by default.- Specified by:
open
in interfaceResultObjectProvider
- Throws:
java.lang.Exception
-
supportsRandomAccess
public boolean supportsRandomAccess()
Override if desired. Returns false by default.- Specified by:
supportsRandomAccess
in interfaceResultObjectProvider
- See Also:
ResultObjectProvider.supportsRandomAccess()
-
next
public abstract boolean next() throws java.lang.Exception
Implement this method to advance the input.- Specified by:
next
in interfaceResultObjectProvider
- Throws:
java.lang.Exception
- See Also:
ResultObjectProvider.next()
-
absolute
public boolean absolute(int pos) throws java.lang.Exception
Override if desired. Throws an exception by default.- Specified by:
absolute
in interfaceResultObjectProvider
- Throws:
java.lang.Exception
- See Also:
ResultObjectProvider.absolute(int)
-
size
public int size() throws java.lang.Exception
Override if desired. ReturnsInteger.MAX_VALUE
by default.- Specified by:
size
in interfaceResultObjectProvider
- Throws:
java.lang.Exception
- See Also:
ResultObjectProvider.size()
-
reset
public void reset() throws java.lang.Exception
Override if desired. Throws an exception by default.- Specified by:
reset
in interfaceResultObjectProvider
- Throws:
java.lang.Exception
- See Also:
ResultObjectProvider.reset()
-
close
public void close() throws java.lang.Exception
Override if desired. Does nothing by default.- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceResultObjectProvider
- Throws:
java.lang.Exception
- See Also:
ResultObjectProvider.close()
-
handleCheckedException
public void handleCheckedException(java.lang.Exception e)
Throws aStoreException
by default.- Specified by:
handleCheckedException
in interfaceResultObjectProvider
-
-