messif.operations.query
Class GetRandomObjectsQueryOperation

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

public class GetRandomObjectsQueryOperation
extends ListingQueryOperation

Operation for retriving a list of random objects.

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
GetRandomObjectsQueryOperation(int count)
          Creates a new instance of GetRandomObjecstQueryOperation.
GetRandomObjectsQueryOperation(int count, AnswerType answerType)
          Creates a new instance of GetRandomObjectsQueryOperation.
 
Method Summary
 boolean addToAnswer(AbstractObject object)
          Add an object to the answer.
protected  boolean dataEqualsImpl(AbstractOperation obj)
          Indicates whether some other operation has the same data as this one.
 int dataHashCode()
          Returns a hash code value for the data of this operation.
 int evaluate(AbstractObjectIterator<? extends LocalAbstractObject> objects)
          Evaluate this query on a given set of objects.
 java.lang.Object getArgument(int index)
          Returns argument that was passed while constructing instance.
 int getArgumentCount()
          Returns number of arguments that were passed while constructing this instance.
 
Methods inherited from class messif.operations.ListingQueryOperation
clearSurplusData, clone, getAnswer, getAnswer, getAnswerClass, getAnswerCount, getAnswerObjects, resetAnswer, updateFrom, updateFrom, updateFrom, updateFrom
 
Methods inherited from class messif.operations.QueryOperation
appendErrorCode, endOperation, getAnswerType, wasSuccessful
 
Methods inherited from class messif.operations.AbstractOperation
appendArguments, createOperation, dataEquals, endOperation, equals, getAnnotatedConstructor, getAnnotatedConstructor, 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

GetRandomObjectsQueryOperation

public GetRandomObjectsQueryOperation(int count)
Creates a new instance of GetRandomObjecstQueryOperation. AnswerType.NODATA_OBJECTS will be returned in the result.

Parameters:
count - the number of random objects to retrieve

GetRandomObjectsQueryOperation

public GetRandomObjectsQueryOperation(int count,
                                      AnswerType answerType)
Creates a new instance of GetRandomObjectsQueryOperation.

Parameters:
count - the number of random objects to retrieve
answerType - the type of objects this operation stores in its answer
Method Detail

getArgument

public java.lang.Object getArgument(int index)
                             throws java.lang.IndexOutOfBoundsException
Description copied from class: AbstractOperation
Returns argument that was passed while constructing instance. If the argument is not stored within operation, null is returned.

Overrides:
getArgument in class AbstractOperation
Parameters:
index - zero-based index of an argument passed to constructor
Returns:
argument that was passed while constructing instance
Throws:
java.lang.IndexOutOfBoundsException - if index parameter is out of range

getArgumentCount

public int getArgumentCount()
Description copied from class: AbstractOperation
Returns number of arguments that were passed while constructing this instance. Negative number is returned if this operation doesn't support construction argument retrieval.

Overrides:
getArgumentCount in class AbstractOperation
Returns:
number of arguments that were passed while constructing this instance

evaluate

public int evaluate(AbstractObjectIterator<? extends LocalAbstractObject> objects)
Description copied from class: QueryOperation
Evaluate this query on a given set of objects. The objects found by this evaluation are added to the answer of the particular query.

Specified by:
evaluate in class QueryOperation<AbstractObject>
Parameters:
objects - the collection of objects on which to evaluate this query
Returns:
number of objects satisfying the query

addToAnswer

public boolean addToAnswer(AbstractObject object)
                    throws java.lang.IllegalArgumentException
Description copied from class: ListingQueryOperation
Add an object to the answer. The object is updated according to QueryOperation.answerType.

Overrides:
addToAnswer in class ListingQueryOperation
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

dataEqualsImpl

protected boolean dataEqualsImpl(AbstractOperation obj)
Description copied from class: AbstractOperation
Indicates whether some other operation has the same data as this one.

Specified by:
dataEqualsImpl in class AbstractOperation
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object has the same data as the obj argument; false otherwise.

dataHashCode

public int dataHashCode()
Description copied from class: AbstractOperation
Returns a hash code value for the data of this operation. Override this method if the operation has its own data.

Specified by:
dataHashCode in class AbstractOperation
Returns:
a hash code value for the data of this operation