org.apache.jdo.query
Class BasicQueryResult

java.lang.Object
  extended by org.apache.jdo.query.BasicQueryResult
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection, QueryResult

public class BasicQueryResult
extends java.lang.Object
implements QueryResult

This class implements the basic query execution strategy. It first orders the candidate set using the query helper orderCandidates method. It then iterates over the ordered candidate collection, filtering each one, using the query helper applyFilter method and removing the objects that fail the filter. All of the methods of Collection are then delegated to the result collection.

Version:
1.0
Author:
Craig Russell

Nested Class Summary
 class BasicQueryResult.BasicQueryResultIterator
          The internal query result iterator supports all iterator methods plus close, allowing early release of resources.
 
Constructor Summary
BasicQueryResult(QueryResultHelper qrh)
          Creates new BasicQueryResult
 
Method Summary
 boolean add(java.lang.Object obj)
          This method throws UnsupportedOperationException because the collection is read-only.
 boolean addAll(java.util.Collection collection)
          This method throws UnsupportedOperationException because the collection is read-only.
 void clear()
          This method throws UnsupportedOperationException because the collection is read-only.
 void close()
          This method closes the result set, closes all open iterators, and releases all resources that might be held by the result.
 boolean contains(java.lang.Object obj)
          This method delegates to the result collection method.
 boolean containsAll(java.util.Collection collection)
          This method delegates to the result collection method.
 boolean equals(java.lang.Object obj)
          This method delegates to the result collection method.
 int hashCode()
          This method delegates to the result collection method.
 boolean isEmpty()
          This method delegates to the result collection method.
 java.util.Iterator iterator()
          This method delegates to the result collection method.
 boolean remove(java.lang.Object obj)
          This method throws UnsupportedOperationException because the collection is read-only.
 boolean removeAll(java.util.Collection collection)
          This method throws UnsupportedOperationException because the collection is read-only.
 boolean retainAll(java.util.Collection collection)
          This method throws UnsupportedOperationException because the collection is read-only.
 int size()
          This method delegates to the result collection method.
 java.lang.Object[] toArray()
          This method delegates to the result collection method.
 java.lang.Object[] toArray(java.lang.Object[] obj)
          This method delegates to the result collection method.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicQueryResult

public BasicQueryResult(QueryResultHelper qrh)
Creates new BasicQueryResult

Parameters:
qrh - the query result helper provided by the query parser.
Method Detail

close

public void close()
This method closes the result set, closes all open iterators, and releases all resources that might be held by the result.

Specified by:
close in interface QueryResult

retainAll

public boolean retainAll(java.util.Collection collection)
This method throws UnsupportedOperationException because the collection is read-only.

Specified by:
retainAll in interface java.util.Collection
Parameters:
collection - ignored.
Returns:
never.

contains

public boolean contains(java.lang.Object obj)
This method delegates to the result collection method.

Specified by:
contains in interface java.util.Collection
Parameters:
obj - the object to be tested.
Returns:
true if the result collection contains the parameter object.

toArray

public java.lang.Object[] toArray(java.lang.Object[] obj)
This method delegates to the result collection method.

Specified by:
toArray in interface java.util.Collection
Parameters:
obj - an array into which to place the objects from the result collection.
Returns:
an array of all objects in the result collection that are of the runtime type of the parameter array.

iterator

public java.util.Iterator iterator()
This method delegates to the result collection method.

Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Returns:
an iterator over the result collection.

toArray

public java.lang.Object[] toArray()
This method delegates to the result collection method.

Specified by:
toArray in interface java.util.Collection
Returns:
the result collection as an array.

removeAll

public boolean removeAll(java.util.Collection collection)
This method throws UnsupportedOperationException because the collection is read-only.

Specified by:
removeAll in interface java.util.Collection
Parameters:
collection - ignored.
Returns:
never.

remove

public boolean remove(java.lang.Object obj)
This method throws UnsupportedOperationException because the collection is read-only.

Specified by:
remove in interface java.util.Collection
Parameters:
obj - ignored.
Returns:
never.

clear

public void clear()
This method throws UnsupportedOperationException because the collection is read-only.

Specified by:
clear in interface java.util.Collection

addAll

public boolean addAll(java.util.Collection collection)
This method throws UnsupportedOperationException because the collection is read-only.

Specified by:
addAll in interface java.util.Collection
Parameters:
collection - ignored.
Returns:
never.

size

public int size()
This method delegates to the result collection method.

Specified by:
size in interface java.util.Collection
Returns:
the size of the results.

containsAll

public boolean containsAll(java.util.Collection collection)
This method delegates to the result collection method.

Specified by:
containsAll in interface java.util.Collection
Parameters:
collection - a collection of elements to be tested.
Returns:
true if the result collection contains all of the elements in the parameter collection.

add

public boolean add(java.lang.Object obj)
This method throws UnsupportedOperationException because the collection is read-only.

Specified by:
add in interface java.util.Collection
Parameters:
obj - ignored.
Returns:
never.

isEmpty

public boolean isEmpty()
This method delegates to the result collection method.

Specified by:
isEmpty in interface java.util.Collection
Returns:
true if the result collection is empty.

equals

public boolean equals(java.lang.Object obj)
This method delegates to the result collection method.

Specified by:
equals in interface java.util.Collection
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to which to compare this object.
Returns:
true if the result collection is equal to the parameter collection.

hashCode

public int hashCode()
This method delegates to the result collection method.

Specified by:
hashCode in interface java.util.Collection
Overrides:
hashCode in class java.lang.Object
Returns:
the hashCode of the result collection.


Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.