Class MatchQuery

  extended bynet.sourceforge.javamatch.query.MatchQuery
Direct Known Subclasses:
BooleanEquals, NotQuery, NumericQuery, QuerySet, StringQuery

public abstract class MatchQuery
extends java.lang.Object

Class MatchQuery is extended by classes that can execute match queries on objects, and return a value based on how good the match is. A query may be single-pass or two-pass. The default query is single-pass

Constructor Summary
Method Summary
abstract  float getMatchValue(java.lang.Object targetObject)
          Returns the match value of this match query, when executed on the given object.
protected  java.lang.Object getObjectValue(java.lang.Object srcObject, java.lang.String memberName)
          Returns the value of the member with the given name, in the given object
 boolean isTwoPass()
          Returns if this MatchQuery is two-pass.
 void prePass(java.lang.Object matchedObject)
          Performs the pre-pass of a two-pass query.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public MatchQuery()
Method Detail


public abstract float getMatchValue(java.lang.Object targetObject)
                             throws MatchException
Returns the match value of this match query, when executed on the given object. Note to implementers: The returned value must be a floating point number between 0 and 1, or the match engine will throw an exception

targetObject - the object agains which the query is executed
A value between 0 and 1, both inclusive, that indicates how good the object matches this query. 0 means a mismatch, 1 means a full match
MatchException - when the value could not be retrieved


public boolean isTwoPass()
Returns if this MatchQuery is two-pass. When the query is two-pass, a call to prePass will be made for every object, before the matchValue is requested

false if the query is single-pass, true if the query is two-pass


public void prePass(java.lang.Object matchedObject)
             throws MatchException
Performs the pre-pass of a two-pass query. By default, throws an exception, as this is only called on two-pass queries

matchedObject - the object theat is currently matched
MatchException - when the prePass failed


protected java.lang.Object getObjectValue(java.lang.Object srcObject,
                                          java.lang.String memberName)
                                   throws MatchException
Returns the value of the member with the given name, in the given object

srcObject - the object of which the member value is retrieved
memberName - the name of the member that is retrieved
the value that is returned by the member, wrapped into an object if the member returned a primitive type
MatchException - when the execution of the member failed

Hosted by