messif.operations.query
Class GetObjectsByLocatorsOperation

java.lang.Object
  extended by messif.operations.AbstractOperation
      extended by messif.operations.QueryOperation<RankedAbstractObject>
          extended by messif.operations.RankingQueryOperation
              extended by messif.operations.query.GetObjectsByLocatorsOperation
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Clearable

public class GetObjectsByLocatorsOperation
extends RankingQueryOperation

This operation returns objects with given locators.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class messif.operations.AbstractOperation
AbstractOperation.DataEqualOperation, AbstractOperation.OperationConstructor, AbstractOperation.OperationName
 
Field Summary
protected  java.util.Set<java.lang.String> locators
          The locators of the desired objects
protected  LocalAbstractObject queryObjectForDistances
          The object to compute distances to; if null, UNKNOWN_DISTANCE will be used in answer
 
Fields inherited from class messif.operations.QueryOperation
answerType
 
Fields inherited from class messif.operations.AbstractOperation
errValue, operID, suppData
 
Constructor Summary
GetObjectsByLocatorsOperation()
          Create a new instance of GetObjectsByLocatorsOperation with an empty locators set.
GetObjectsByLocatorsOperation(java.util.Collection<java.lang.String> locators)
          Create a new instance of GetObjectsByLocatorsOperation with the specified locators.
GetObjectsByLocatorsOperation(java.util.Collection<java.lang.String> locators, LocalAbstractObject queryObjectForDistances)
          Create a new instance of GetObjectsByLocatorsOperation with the specified locators.
GetObjectsByLocatorsOperation(java.util.Collection<java.lang.String> locators, LocalAbstractObject queryObjectForDistances, AnswerType answerType)
          Create a new instance of GetObjectsByLocatorsOperation with the specified locators.
GetObjectsByLocatorsOperation(java.util.Collection<java.lang.String> locators, LocalAbstractObject queryObjectForDistances, AnswerType answerType, int maxAnswerSize)
          Create a new instance of GetObjectsByLocatorsOperation with the specified locators.
GetObjectsByLocatorsOperation(LocalAbstractObject queryObjectForDistances, AnswerType answerType)
          Create a new instance of GetObjectsByLocatorsOperation with empty locators set.
GetObjectsByLocatorsOperation(LocalAbstractObject queryObjectForDistances, AnswerType answerType, int maxAnswerCount)
          Create a new instance of GetObjectsByLocatorsOperation with empty locators set.
GetObjectsByLocatorsOperation(LocalAbstractObject queryObjectForDistances, int maxAnswerCount)
          Create a new instance of GetObjectsByLocatorsOperation with empty locators set.
 
Method Summary
 void addLocator(java.lang.String locator)
          Add a locator to this query.
 void clearSurplusData()
          Clear non-messif data stored in operation.
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.Class<? extends RankedAbstractObject> getAnswerClass()
          Returns the class of objects this operation stores in its answer.
 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.
 java.util.Set<java.lang.String> getLocators()
          Returns the object locators this query searches for.
 LocalAbstractObject getQueryObject()
          Returns the object the distance to which is used for the answer rank.
 boolean hasLocator(java.lang.String locator)
          Check whether the set of locators contains given locator.
 void setLocators(java.util.Collection<java.lang.String> locators)
          Replace the current locators of this query with the provided collection.
 
Methods inherited from class messif.operations.RankingQueryOperation
addToAnswer, addToAnswer, clone, getAnswer, getAnswer, getAnswerCount, getAnswerDistance, getAnswerObjects, getAnswerThreshold, getLastAnswer, isAnswerFull, isStoringMetaDistances, resetAnswer, setAnswerCollection, 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
 

Field Detail

locators

protected final java.util.Set<java.lang.String> locators
The locators of the desired objects


queryObjectForDistances

protected final LocalAbstractObject queryObjectForDistances
The object to compute distances to; if null, UNKNOWN_DISTANCE will be used in answer

Constructor Detail

GetObjectsByLocatorsOperation

public GetObjectsByLocatorsOperation(java.util.Collection<java.lang.String> locators,
                                     LocalAbstractObject queryObjectForDistances,
                                     AnswerType answerType,
                                     int maxAnswerSize)
Create a new instance of GetObjectsByLocatorsOperation with the specified locators.

Parameters:
locators - the collection of locators to be found
queryObjectForDistances - the query object to use for computing distances
answerType - the type of objects this operation stores in its answer
maxAnswerSize - the limit for the number of objects kept in this operation's answer

GetObjectsByLocatorsOperation

public GetObjectsByLocatorsOperation(java.util.Collection<java.lang.String> locators,
                                     LocalAbstractObject queryObjectForDistances,
                                     AnswerType answerType)
Create a new instance of GetObjectsByLocatorsOperation with the specified locators.

Parameters:
locators - the collection of locators to be found
queryObjectForDistances - the query object to use for computing distances
answerType - the type of objects this operation stores in its answer

GetObjectsByLocatorsOperation

public GetObjectsByLocatorsOperation(java.util.Collection<java.lang.String> locators,
                                     LocalAbstractObject queryObjectForDistances)
Create a new instance of GetObjectsByLocatorsOperation with the specified locators.

Parameters:
locators - the collection of locators to be found
queryObjectForDistances - the query object to use for computing distances

GetObjectsByLocatorsOperation

public GetObjectsByLocatorsOperation(java.util.Collection<java.lang.String> locators)
Create a new instance of GetObjectsByLocatorsOperation with the specified locators.

Parameters:
locators - the collection of locators to search for

GetObjectsByLocatorsOperation

public GetObjectsByLocatorsOperation()
Create a new instance of GetObjectsByLocatorsOperation with an empty locators set.


GetObjectsByLocatorsOperation

public GetObjectsByLocatorsOperation(LocalAbstractObject queryObjectForDistances,
                                     AnswerType answerType,
                                     int maxAnswerCount)
Create a new instance of GetObjectsByLocatorsOperation with empty locators set.

Parameters:
queryObjectForDistances - the query object to use for computing distances
answerType - the type of objects this operation stores in its answer
maxAnswerCount - the limit for the number of objects kept in this operation's answer

GetObjectsByLocatorsOperation

public GetObjectsByLocatorsOperation(LocalAbstractObject queryObjectForDistances,
                                     AnswerType answerType)
Create a new instance of GetObjectsByLocatorsOperation with empty locators set.

Parameters:
queryObjectForDistances - the query object to use for computing distances
answerType - the type of objects this operation stores in its answer

GetObjectsByLocatorsOperation

public GetObjectsByLocatorsOperation(LocalAbstractObject queryObjectForDistances,
                                     int maxAnswerCount)
Create a new instance of GetObjectsByLocatorsOperation with empty locators set.

Parameters:
queryObjectForDistances - the query object to use for computing distances
maxAnswerCount - the limit for the number of objects kept in this operation's answer
Method Detail

getArgument

public java.lang.Object getArgument(int index)
                             throws java.lang.IndexOutOfBoundsException
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 - 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()
Returns number of arguments that were passed while constructing this instance.

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

getQueryObject

public LocalAbstractObject getQueryObject()
Returns the object the distance to which is used for the answer rank.

Returns:
the query object of this ranking query

getLocators

public java.util.Set<java.lang.String> getLocators()
Returns the object locators this query searches for.

Returns:
the object locators this query searches for

addLocator

public void addLocator(java.lang.String locator)
Add a locator to this query.

Parameters:
locator - the locator to be added

setLocators

public void setLocators(java.util.Collection<java.lang.String> locators)
Replace the current locators of this query with the provided collection.

Parameters:
locators - the new collection of locators

hasLocator

public boolean hasLocator(java.lang.String locator)
Check whether the set of locators contains given locator.

Parameters:
locator - the locator to be checked
Returns:
true if the set of locators to be found contains the given locator

evaluate

public int evaluate(AbstractObjectIterator<? extends LocalAbstractObject> objects)
Evaluate this query on a given set of objects. The objects found by this evaluation are added to answer of this query via RankingQueryOperation.addToAnswer(messif.objects.LocalAbstractObject, messif.objects.LocalAbstractObject, float).

Specified by:
evaluate in class QueryOperation<RankedAbstractObject>
Parameters:
objects - the collection of objects on which to evaluate this query
Returns:
number of objects satisfying the query
Throws:
java.lang.IllegalArgumentException - if the object cannot be added to the answer, e.g. because it cannot be clonned

getAnswerClass

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

Overrides:
getAnswerClass in class RankingQueryOperation
Returns:
the class of objects this operation stores in its answer

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 RankingQueryOperation

dataEqualsImpl

protected boolean dataEqualsImpl(AbstractOperation obj)
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()
Returns a hash code value for the data of this operation.

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