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:
java.io.Serializable, java.lang.Iterable, java.util.Collection, java.util.List, org.datanucleus.store.query.QueryResult

public final class ForwardQueryResult
extends AbstractRDBMSQueryResult

Lazy collection results from a Query with the ResultSet in a forwards 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.

See Also:
Serialized Form

Field Summary
protected  boolean moreResultSetRows
          Whether there are still more rows to be processed in the ResultSet.
protected  java.util.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, java.sql.ResultSet rs, java.util.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 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(java.lang.Object o)
          Method to check if the specified object is contained in this result.
 boolean containsAll(java.util.Collection c)
          Method to check if all of the specified objects are contained here.
 boolean equals(java.lang.Object o)
          Equality operator for QueryResults.
 java.lang.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()
          Returns true if this collection contains no elements.
 java.util.Iterator iterator()
          Accessor for an iterator for the results.
 java.util.ListIterator listIterator()
          Accessor for an iterator for the results.
protected  java.lang.Object nextResultSetElement()
          Accessor for the next object from the ResultSet.
 java.lang.Object[] toArray()
          Method to return the results as an array.
 java.lang.Object[] toArray(java.lang.Object[] a)
          Method to return the results as an array.
 
Methods inherited from class org.datanucleus.store.rdbms.query.AbstractRDBMSQueryResult
closeResults, disconnect, getSizeUsingCount, 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 java.util.List resultObjs
The Result Objects.

Constructor Detail

ForwardQueryResult

public ForwardQueryResult(org.datanucleus.store.query.Query query,
                          org.datanucleus.store.query.ResultObjectFactory rof,
                          java.sql.ResultSet rs,
                          java.util.Collection candidates)
                   throws java.sql.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. Pass this argument only when distinct = false
Throws:
java.sql.SQLException - if can't read ResultSet
Method Detail

nextResultSetElement

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

Returns:
The next element from the ResultSet.

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 java.util.Iterator iterator()
Accessor for an iterator for the results.

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

listIterator

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

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

contains

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

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

containsAll

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

Specified by:
containsAll in interface java.util.Collection
Specified by:
containsAll in interface java.util.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(java.lang.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 java.util.Collection
Specified by:
equals in interface java.util.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 java.lang.Object get(int index)
Method to retrieve a particular element from the list.

Specified by:
get in interface java.util.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()
Returns true if this collection contains no elements.

This implementation check if the result is empty.

Specified by:
isEmpty in interface java.util.Collection
Specified by:
isEmpty in interface java.util.List
Overrides:
isEmpty in class org.datanucleus.store.query.AbstractQueryResult
Returns:
true if this collection contains no elements.

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 java.lang.Object[] toArray()
Method to return the results as an array.

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

toArray

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

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


Copyright © 2009. All Rights Reserved.