org.datanucleus.store.rdbms.query
Class ForwardQueryResult

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList
          extended by org.datanucleus.store.query.AbstractQueryResult
              extended by org.datanucleus.store.rdbms.query.AbstractRDBMSQueryResult
                  extended by org.datanucleus.store.rdbms.query.ForwardQueryResult
All Implemented Interfaces:
Serializable, Iterable, Collection, List, org.datanucleus.store.query.QueryResult

public final class ForwardQueryResult
extends AbstractRDBMSQueryResult
implements Serializable

Lazy collection results from a Query with the ResultSet in a forward direction. In general the actual result elements are only loaded when accessed with the exception of non-transactional or optimistic contexts that load the elements at initialisation.

If the query had a range defined and this was not handled in the datastore query then this QueryResult will skip the unrequired records and just return the range requested.

See Also:
Serialized Form

Field Summary
protected  boolean moreResultSetRows
          Whether there are still more rows to be processed in the ResultSet.
protected  List resultIds
           
protected  List resultObjs
          The Result Objects.
 
Fields inherited from class org.datanucleus.store.rdbms.query.AbstractRDBMSQueryResult
rof, rs
 
Fields inherited from class org.datanucleus.store.query.AbstractQueryResult
closed, connectionListeners, loadResultsAtCommit, LOCALISER, query, resultSizeMethod, size
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ForwardQueryResult(org.datanucleus.store.query.Query query, org.datanucleus.store.query.ResultObjectFactory rof, ResultSet rs, Collection candidates)
          Constructor of the result from a Query.
 
Method Summary
 void close()
          Method to close the results, making the results unusable thereafter.
protected  void closeResults()
          Internal method to close the ResultSet.
protected  void closingConnection()
          Method called to inform the query result that the connection is being closed so perform any required operations now, or rest in peace.
 boolean contains(Object o)
          Method to check if the specified object is contained in this result.
 boolean containsAll(Collection c)
          Method to check if all of the specified objects are contained here.
 boolean equals(Object o)
          Equality operator for QueryResults.
 Object get(int index)
          Method to retrieve a particular element from the list.
protected  int getSizeUsingMethod()
          Method to get the size using the "resultSizeMethod".
 boolean isEmpty()
          Accessor for whether there are any results.
 Iterator iterator()
          Accessor for an iterator for the results.
 ListIterator listIterator()
          Accessor for an iterator for the results.
protected  Object nextResultSetElement()
          Accessor for the next object from the ResultSet.
 Object[] toArray()
          Method to return the results as an array.
 Object[] toArray(Object[] a)
          Method to return the results as an array.
protected  Object writeReplace()
          Handle serialisation by returning a java.util.ArrayList of all of the results for this query after disconnecting the query which has the consequence of enforcing the load of all objects.
 
Methods inherited from class org.datanucleus.store.rdbms.query.AbstractRDBMSQueryResult
disconnect, hashCode
 
Methods inherited from class org.datanucleus.store.query.AbstractQueryResult
add, add, addAll, addConnectionListener, assertIsOpen, clear, indexOf, isOpen, lastIndexOf, remove, set, size, subList
 
Methods inherited from class java.util.AbstractList
listIterator, removeRange
 
Methods inherited from class java.util.AbstractCollection
addAll, remove, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
addAll, remove, removeAll, retainAll
 
Methods inherited from interface java.util.List
addAll, remove, removeAll, retainAll
 

Field Detail

moreResultSetRows

protected boolean moreResultSetRows
Whether there are still more rows to be processed in the ResultSet.


resultObjs

protected List resultObjs
The Result Objects.


resultIds

protected List resultIds
Constructor Detail

ForwardQueryResult

public ForwardQueryResult(org.datanucleus.store.query.Query query,
                          org.datanucleus.store.query.ResultObjectFactory rof,
                          ResultSet rs,
                          Collection candidates)
                   throws SQLException
Constructor of the result from a Query.

Parameters:
query - The Query
rof - The factory to retrieve results from
rs - The ResultSet from the Query Statement
candidates - Candidate elements
Throws:
SQLException - if can't read ResultSet
Method Detail

nextResultSetElement

protected Object nextResultSetElement()
Accessor for the next object from the ResultSet.

Returns:
The next element from the ResultSet.

closeResults

protected void closeResults()
Internal method to close the ResultSet.

Overrides:
closeResults in class AbstractRDBMSQueryResult

close

public void close()
Method to close the results, making the results unusable thereafter.

Specified by:
close in interface org.datanucleus.store.query.QueryResult
Overrides:
close in class AbstractRDBMSQueryResult

closingConnection

protected void closingConnection()
Method called to inform the query result that the connection is being closed so perform any required operations now, or rest in peace.

Specified by:
closingConnection in class org.datanucleus.store.query.AbstractQueryResult

iterator

public Iterator iterator()
Accessor for an iterator for the results.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface List
Specified by:
iterator in class org.datanucleus.store.query.AbstractQueryResult
Returns:
The iterator

listIterator

public ListIterator listIterator()
Accessor for an iterator for the results.

Specified by:
listIterator in interface List
Specified by:
listIterator in class org.datanucleus.store.query.AbstractQueryResult
Returns:
The iterator

contains

public boolean contains(Object o)
Method to check if the specified object is contained in this result.

Specified by:
contains in interface Collection
Specified by:
contains in interface List
Overrides:
contains in class org.datanucleus.store.query.AbstractQueryResult
Parameters:
o - The object
Returns:
Whether it is contained here.

containsAll

public boolean containsAll(Collection c)
Method to check if all of the specified objects are contained here.

Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface List
Overrides:
containsAll in class org.datanucleus.store.query.AbstractQueryResult
Parameters:
c - The collection of objects
Returns:
Whether they are all contained here.

equals

public boolean equals(Object o)
Equality operator for QueryResults. Overrides the AbstractList implementation since that uses size() and iterator() and that would cause problems when closed.

Specified by:
equals in interface Collection
Specified by:
equals in interface List
Specified by:
equals in class org.datanucleus.store.query.AbstractQueryResult
Parameters:
o - The object to compare against
Returns:
Whether they are equal

get

public Object get(int index)
Method to retrieve a particular element from the list.

Specified by:
get in interface List
Specified by:
get in class org.datanucleus.store.query.AbstractQueryResult
Parameters:
index - The index of the element
Returns:
The element at index

isEmpty

public boolean isEmpty()
Accessor for whether there are any results.

Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface List
Overrides:
isEmpty in class org.datanucleus.store.query.AbstractQueryResult
Returns:
true if these results are empty.

getSizeUsingMethod

protected int getSizeUsingMethod()
Method to get the size using the "resultSizeMethod". This implementation supports "LAST" method. Override this in subclasses to implement other methods.

Overrides:
getSizeUsingMethod in class org.datanucleus.store.query.AbstractQueryResult
Returns:
The size

toArray

public Object[] toArray()
Method to return the results as an array.

Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
Overrides:
toArray in class org.datanucleus.store.query.AbstractQueryResult
Returns:
The array.

toArray

public Object[] toArray(Object[] a)
Method to return the results as an array.

Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
Overrides:
toArray in class org.datanucleus.store.query.AbstractQueryResult
Parameters:
a - The array to copy into.
Returns:
The array.

writeReplace

protected Object writeReplace()
                       throws ObjectStreamException
Handle serialisation by returning a java.util.ArrayList of all of the results for this query after disconnecting the query which has the consequence of enforcing the load of all objects.

Returns:
The object to serialise
Throws:
ObjectStreamException


Copyright © 2012. All Rights Reserved.