net.sourceforge.javamatch.query
Class MatchQuery

java.lang.Object
  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
MatchQuery()
           
 
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

MatchQuery

public MatchQuery()
Method Detail

getMatchValue

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

Parameters:
targetObject - the object agains which the query is executed
Returns:
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
Throws:
MatchException - when the value could not be retrieved

isTwoPass

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

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

prePass

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

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

getObjectValue

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

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

Hosted by SourceForge.net/