net.sourceforge.javamatch.query
Class QuerySet

java.lang.Object
  extended bynet.sourceforge.javamatch.query.MatchQuery
      extended bynet.sourceforge.javamatch.query.QuerySet

public class QuerySet
extends MatchQuery

Class QuerySet combines multiple subqueries into a single query. The subqueries in a QuerySet may be required or preferred. When an object is matched, all required subqueries must match completely, or the QuerySet reports a mismatch. When all required subqueries match, the preferred subqueries determine the match value of the matched object. Preferred subqueries may be weighted. The match value is the weighted average of all preferred subqueries.


Constructor Summary
QuerySet()
           
 
Method Summary
 void addPreferred(MatchQuery query)
          Adds a the given subquery to the list of preferred queries, with a default weight (1)
 void addPreferred(MatchQuery query, float weight)
          Adds a the given subquery to the list of preferred queries, with the given weight
 void addRequired(MatchQuery query)
          Adds a the given subquery to the list of required queries
 float getMatchValue(java.lang.Object targetObject)
          Returns the match value of this match query, when executed on 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 net.sourceforge.javamatch.query.MatchQuery
getObjectValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuerySet

public QuerySet()
Method Detail

addPreferred

public void addPreferred(MatchQuery query)
Adds a the given subquery to the list of preferred queries, with a default weight (1)

Parameters:
query - the subquery that is added to the list of preferred queries

addPreferred

public void addPreferred(MatchQuery query,
                         float weight)
Adds a the given subquery to the list of preferred queries, with the given weight

Parameters:
query - the subquery that is added to this MatchList
weight - the relative weight of this subquery

addRequired

public void addRequired(MatchQuery query)
Adds a the given subquery to the list of required queries

Parameters:
query - the subquery that is added to the list of required queries

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

Overrides:
isTwoPass in class MatchQuery
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. A MatchList is two-pass if and only if at least one of its sub-queries is two-pass.

Overrides:
prePass in class MatchQuery
Parameters:
matchedObject - the object theat is currently matched
Throws:
MatchException - when the prePass failed

getMatchValue

public float getMatchValue(java.lang.Object targetObject)
                    throws MatchException
Returns the match value of this match query, when executed on the given object.

Specified by:
getMatchValue in class MatchQuery
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

Hosted by SourceForge.net/