messif.operations
Class ListingQueryOperation

java.lang.Object
  extended by messif.operations.AbstractOperation
      extended by messif.operations.QueryOperation<AbstractObject>
          extended by messif.operations.ListingQueryOperation
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Clearable
Direct Known Subclasses:
GetAllObjectsQueryOperation, GetRandomObjectsQueryOperation

public abstract class ListingQueryOperation
extends QueryOperation<AbstractObject>

The base class for query operations that return unsorted collections of objects. These are, for example, operations that access objects from a bucket.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class messif.operations.AbstractOperation
AbstractOperation.DataEqualOperation, AbstractOperation.OperationConstructor, AbstractOperation.OperationName
 
Field Summary
 
Fields inherited from class messif.operations.QueryOperation
answerType
 
Fields inherited from class messif.operations.AbstractOperation
errValue, operID, suppData
 
Constructor Summary
protected ListingQueryOperation()
          Creates a new instance of ListingQueryOperation.
protected ListingQueryOperation(AnswerType answerType)
          Creates a new instance of ListingQueryOperation.
protected ListingQueryOperation(AnswerType answerType, java.util.List<AbstractObject> answer)
          Creates a new instance of ListingQueryOperation.
 
Method Summary
 boolean addToAnswer(AbstractObject object)
          Add an object to the answer.
 void clearSurplusData()
          Clear non-messif data stored in operation.
 ListingQueryOperation clone()
          Create a duplicate of this operation.
 java.util.Iterator<AbstractObject> getAnswer()
          Returns an iterator over all objects in the answer to this query.
 java.util.Iterator<AbstractObject> getAnswer(int skip, int count)
          Returns an iterator over all objects in the answer skipping the first skip items and returning only count elements.
 java.lang.Class<? extends AbstractObject> getAnswerClass()
          Returns the class of objects this operation stores in its answer.
 int getAnswerCount()
          Returns the number of objects in this query answer.
 java.util.Iterator<AbstractObject> getAnswerObjects()
          Returns an iterator over all AbstractObjects in the answer to this query.
 void resetAnswer()
          Reset the current query answer.
 void updateFrom(AbstractOperation operation)
          Update the error code and answer of this operation from another operation.
protected  void updateFrom(ListingQueryOperation operation)
          Update the answer of this operation from a ListingQueryOperation.
protected  void updateFrom(RankingQueryOperation operation)
          Update the answer of this operation from a RankingQueryOperation.
protected  void updateFrom(SingletonQueryOperation operation)
          Update the answer of this operation from a SingletonQueryOperation.
 
Methods inherited from class messif.operations.QueryOperation
appendErrorCode, endOperation, evaluate, getAnswerType, wasSuccessful
 
Methods inherited from class messif.operations.AbstractOperation
appendArguments, createOperation, dataEquals, dataEqualsImpl, dataHashCode, endOperation, equals, getAnnotatedConstructor, getAnnotatedConstructor, getArgument, getArgumentCount, getConstructorArgumentDescriptions, getConstructorArgumentDescriptions, getConstructorArguments, getConstructorArguments, getConstructorDescription, getErrorCode, getName, getName, getOperationID, hashCode, isFinished, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListingQueryOperation

protected ListingQueryOperation()
Creates a new instance of ListingQueryOperation. An instance of ArrayList is used to store the answer. Objects added to answer are cleared and clonned.


ListingQueryOperation

protected ListingQueryOperation(AnswerType answerType)
Creates a new instance of ListingQueryOperation. An instance of ArrayList is used to store the answer.

Parameters:
answerType - the type of objects this operation stores in its answer

ListingQueryOperation

protected ListingQueryOperation(AnswerType answerType,
                                java.util.List<AbstractObject> answer)
Creates a new instance of ListingQueryOperation.

Parameters:
answerType - the type of objects this operation stores in its answer
answer - the collection used for storing the answer
Method Detail

clone

public ListingQueryOperation clone()
                            throws java.lang.CloneNotSupportedException
Create a duplicate of this operation. The answer of the query is not clonned.

Overrides:
clone in class AbstractOperation
Returns:
a clone of this operation
Throws:
java.lang.CloneNotSupportedException - if the operation instance cannot be cloned

getAnswerClass

public java.lang.Class<? extends AbstractObject> getAnswerClass()
Returns the class of objects this operation stores in its answer.

Specified by:
getAnswerClass in class QueryOperation<AbstractObject>
Returns:
the class of objects this operation stores in its answer

getAnswerCount

public int getAnswerCount()
Returns the number of objects in this query answer.

Specified by:
getAnswerCount in class QueryOperation<AbstractObject>
Returns:
the number of objects in this query answer

getAnswer

public java.util.Iterator<AbstractObject> getAnswer()
Returns an iterator over all objects in the answer to this query.

Specified by:
getAnswer in class QueryOperation<AbstractObject>
Returns:
an iterator over all objects in the answer to this query

getAnswer

public java.util.Iterator<AbstractObject> getAnswer(int skip,
                                                    int count)
Description copied from class: QueryOperation
Returns an iterator over all objects in the answer skipping the first skip items and returning only count elements. If count is less than or equal to zero, all objects from the answer (except for skip) are returned.

Specified by:
getAnswer in class QueryOperation<AbstractObject>
Parameters:
skip - number of answer objects to skip
count - number of answer objects to iterate (maximally, actual number of results can be smaller)
Returns:
an iterator over the objects in the answer to this query

getAnswerObjects

public java.util.Iterator<AbstractObject> getAnswerObjects()
Description copied from class: QueryOperation
Returns an iterator over all AbstractObjects in the answer to this query. This method unwraps the objects from the results.

Specified by:
getAnswerObjects in class QueryOperation<AbstractObject>
Returns:
an iterator over all AbstractObjects in the answer to this query

addToAnswer

public boolean addToAnswer(AbstractObject object)
                    throws java.lang.IllegalArgumentException
Add an object to the answer. The object is updated according to QueryOperation.answerType.

Parameters:
object - the object to add
Returns:
true if the object has been added to the answer. Otherwise false.
Throws:
java.lang.IllegalArgumentException - if the object cannot be added to the answer, e.g. because it cannot be clonned

resetAnswer

public void resetAnswer()
Reset the current query answer. All objects from the answer are deleted, getAnswerCount() will return zero.

Specified by:
resetAnswer in class QueryOperation<AbstractObject>

updateFrom

public final void updateFrom(AbstractOperation operation)
                      throws java.lang.IllegalArgumentException
Update the error code and answer of this operation from another operation.

Overrides:
updateFrom in class AbstractOperation
Parameters:
operation - the source operation from which to get the update
Throws:
java.lang.IllegalArgumentException - if the answer of the specified operation is incompatible with this one

updateFrom

protected void updateFrom(SingletonQueryOperation operation)
Update the answer of this operation from a SingletonQueryOperation.

Parameters:
operation - the source operation from which to get the update

updateFrom

protected void updateFrom(ListingQueryOperation operation)
Update the answer of this operation from a ListingQueryOperation.

Parameters:
operation - the source operation from which to get the update

updateFrom

protected void updateFrom(RankingQueryOperation operation)
Update the answer of this operation from a RankingQueryOperation.

Parameters:
operation - the source operation from which to get the update

clearSurplusData

public void clearSurplusData()
Clear non-messif data stored in operation. This method is intended to be called whenever the operation is sent back to client in order to minimize problems with unknown classes after deserialization.

Specified by:
clearSurplusData in interface Clearable
Overrides:
clearSurplusData in class AbstractOperation