Package org.apache.openjpa.lib.rop
Class RangeResultObjectProvider
- java.lang.Object
-
- org.apache.openjpa.lib.rop.RangeResultObjectProvider
-
- All Implemented Interfaces:
ResultObjectProvider,Closeable
public class RangeResultObjectProvider extends java.lang.Object implements ResultObjectProvider
Prevents a view of a given range of indices from the delegate result object provider.- Author:
- Abe White
-
-
Constructor Summary
Constructors Constructor Description RangeResultObjectProvider(ResultObjectProvider delegate, long startIdx, long endIdx)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanabsolute(int pos)Move to the given 0-based position.voidclose()Free the resources associated with this provider.ResultObjectProvidergetDelegate()java.lang.ObjectgetResultObject()Instantiate the current result object.voidhandleCheckedException(java.lang.Exception e)Any checked exceptions that are thrown will be passed to this method.booleannext()Advance the input to the next position.voidopen()Open the result.voidreset()Reset this provider.intsize()Return the number of items in the input, orInteger.MAX_VALUEif the size in unknown.booleansupportsRandomAccess()Return true if this provider supports random access.
-
-
-
Constructor Detail
-
RangeResultObjectProvider
public RangeResultObjectProvider(ResultObjectProvider delegate, long startIdx, long endIdx)
Constructor. Because this is a wrapper around some delegate, and result object providers work with int indexes, neither the start or end index can be greater than Integer.MAX_VALUE(with the exception of Long.MAX_VALUE, which is used to indicate no limit).- Parameters:
delegate- the result object provider to delegate tostartIdx- 0-based inclusive start index of the range to present; must be < Integer.MAX_VALUEendIdx- 0-based exclusive end index of the range to present; must be < Integer.MAX_VALUE, or Long.MAX_VALUE for no limit
-
-
Method Detail
-
supportsRandomAccess
public boolean supportsRandomAccess()
Description copied from interface:ResultObjectProviderReturn true if this provider supports random access.- Specified by:
supportsRandomAccessin interfaceResultObjectProvider
-
open
public void open() throws java.lang.ExceptionDescription copied from interface:ResultObjectProviderOpen the result. This will be called beforeResultObjectProvider.next(),ResultObjectProvider.absolute(int), orResultObjectProvider.size().- Specified by:
openin interfaceResultObjectProvider- Throws:
java.lang.Exception
-
getResultObject
public java.lang.Object getResultObject() throws java.lang.ExceptionDescription copied from interface:ResultObjectProviderInstantiate the current result object. This method will only be called afterResultObjectProvider.next()orResultObjectProvider.absolute(int).- Specified by:
getResultObjectin interfaceResultObjectProvider- Throws:
java.lang.Exception
-
next
public boolean next() throws java.lang.ExceptionDescription copied from interface:ResultObjectProviderAdvance the input to the next position. Returntrueif there is more data; otherwisefalse.- Specified by:
nextin interfaceResultObjectProvider- Throws:
java.lang.Exception
-
absolute
public boolean absolute(int pos) throws java.lang.ExceptionDescription copied from interface:ResultObjectProviderMove to the given 0-based position. This method is only called for providers that support random access. Returntrueif there is data at this position; otherwisefalse. This may be invoked in place ofResultObjectProvider.next().- Specified by:
absolutein interfaceResultObjectProvider- Throws:
java.lang.Exception
-
size
public int size() throws java.lang.ExceptionDescription copied from interface:ResultObjectProviderReturn the number of items in the input, orInteger.MAX_VALUEif the size in unknown.- Specified by:
sizein interfaceResultObjectProvider- Throws:
java.lang.Exception
-
reset
public void reset() throws java.lang.ExceptionDescription copied from interface:ResultObjectProviderReset this provider. This is an optional operation. If supported, it should move the position of the provider to before the first element. Non-random-access providers may be able to support this method by re-acquiring all resources as if the result were just opened.- Specified by:
resetin interfaceResultObjectProvider- Throws:
java.lang.Exception
-
close
public void close() throws java.lang.ExceptionDescription copied from interface:ResultObjectProviderFree the resources associated with this provider.- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceResultObjectProvider- Throws:
java.lang.Exception
-
handleCheckedException
public void handleCheckedException(java.lang.Exception e)
Description copied from interface:ResultObjectProviderAny checked exceptions that are thrown will be passed to this method. The provider should re-throw the exception as an appropriate unchecked exception.- Specified by:
handleCheckedExceptionin interfaceResultObjectProvider
-
getDelegate
public ResultObjectProvider getDelegate()
-
-