org.modeshape.search.lucene.query
Class CompareLengthQuery

java.lang.Object
  extended by org.apache.lucene.search.Query
      extended by org.modeshape.search.lucene.query.CompareQuery<Integer>
          extended by org.modeshape.search.lucene.query.CompareLengthQuery
All Implemented Interfaces:
Serializable, Cloneable

public class CompareLengthQuery
extends CompareQuery<Integer>

A Lucene Query implementation that is used to apply a Length constraint against a string field. This query implementation works by using the weight and scorer of the wrapped query to score (and return) only those documents with string fields that satisfy the constraint.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.modeshape.search.lucene.query.CompareQuery
CompareQuery.CompareScorer, CompareQuery.CompareWeight, CompareQuery.Evaluator<ValueType>
 
Field Summary
protected static CompareQuery.Evaluator<Integer> EQUAL_TO
           
protected static CompareQuery.Evaluator<Integer> IS_GREATER_THAN
           
protected static CompareQuery.Evaluator<Integer> IS_GREATER_THAN_OR_EQUAL_TO
           
protected static CompareQuery.Evaluator<Integer> IS_LESS_THAN
           
protected static CompareQuery.Evaluator<Integer> IS_LESS_THAN_OR_EQUAL_TO
           
protected static CompareQuery.Evaluator<Integer> NOT_EQUAL_TO
           
 
Fields inherited from class org.modeshape.search.lucene.query.CompareQuery
constraintValue, evaluator, fieldName, fieldSelector, stringFactory, valueTypeFactory
 
Constructor Summary
protected CompareLengthQuery(String fieldName, Integer constraintValue, ValueFactory<String> stringFactory, CompareQuery.Evaluator<Integer> evaluator)
          Construct a Query implementation that scores nodes according to the supplied comparator.
 
Method Summary
 Object clone()
          
static CompareLengthQuery createQueryForNodesWithFieldEqualTo(Integer constraintValue, String fieldName, ValueFactories factories)
          Construct a Query implementation that scores documents with a field length that is equal to the supplied constraint value.
static CompareLengthQuery createQueryForNodesWithFieldGreaterThan(Integer constraintValue, String fieldName, ValueFactories factories)
          Construct a Query implementation that scores documents with a field length that is greater than the supplied constraint value.
static CompareLengthQuery createQueryForNodesWithFieldGreaterThanOrEqualTo(Integer constraintValue, String fieldName, ValueFactories factories)
          Construct a Query implementation that scores documents with a field length that is greater than or equal to the supplied constraint value.
static CompareLengthQuery createQueryForNodesWithFieldLessThan(Integer constraintValue, String fieldName, ValueFactories factories)
          Construct a Query implementation that scores documents with a field length that is less than the supplied constraint value.
static CompareLengthQuery createQueryForNodesWithFieldLessThanOrEqualTo(Integer constraintValue, String fieldName, ValueFactories factories)
          Construct a Query implementation that scores documents with a field length that is less than or equal to the supplied constraint value.
static CompareLengthQuery createQueryForNodesWithFieldNotEqualTo(Integer constraintValue, String fieldName, ValueFactories factories)
          Construct a Query implementation that scores documents with a field length that is not equal to the supplied constraint value.
protected  Integer readFromDocument(org.apache.lucene.index.IndexReader reader, int docId)
          
 
Methods inherited from class org.modeshape.search.lucene.query.CompareQuery
createWeight, toString
 
Methods inherited from class org.apache.lucene.search.Query
combine, equals, extractTerms, getBoost, getSimilarity, hashCode, mergeBooleanQueries, rewrite, setBoost, toString, weight
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EQUAL_TO

protected static final CompareQuery.Evaluator<Integer> EQUAL_TO

NOT_EQUAL_TO

protected static final CompareQuery.Evaluator<Integer> NOT_EQUAL_TO

IS_LESS_THAN

protected static final CompareQuery.Evaluator<Integer> IS_LESS_THAN

IS_LESS_THAN_OR_EQUAL_TO

protected static final CompareQuery.Evaluator<Integer> IS_LESS_THAN_OR_EQUAL_TO

IS_GREATER_THAN

protected static final CompareQuery.Evaluator<Integer> IS_GREATER_THAN

IS_GREATER_THAN_OR_EQUAL_TO

protected static final CompareQuery.Evaluator<Integer> IS_GREATER_THAN_OR_EQUAL_TO
Constructor Detail

CompareLengthQuery

protected CompareLengthQuery(String fieldName,
                             Integer constraintValue,
                             ValueFactory<String> stringFactory,
                             CompareQuery.Evaluator<Integer> evaluator)
Construct a Query implementation that scores nodes according to the supplied comparator.

Parameters:
fieldName - the name of the document field containing the value; may not be null
constraintValue - the constraint value; may not be null
stringFactory - the string factory that can be used during the scoring; may not be null
evaluator - the CompareQuery.Evaluator implementation that returns whether the node path satisfies the constraint; may not be null
Method Detail

createQueryForNodesWithFieldEqualTo

public static CompareLengthQuery createQueryForNodesWithFieldEqualTo(Integer constraintValue,
                                                                     String fieldName,
                                                                     ValueFactories factories)
Construct a Query implementation that scores documents with a field length that is equal to the supplied constraint value.

Parameters:
constraintValue - the constraint value; may not be null
fieldName - the name of the document field containing the value; may not be null
factories - the value factories that can be used during the scoring; may not be null
Returns:
the query; never null

createQueryForNodesWithFieldNotEqualTo

public static CompareLengthQuery createQueryForNodesWithFieldNotEqualTo(Integer constraintValue,
                                                                        String fieldName,
                                                                        ValueFactories factories)
Construct a Query implementation that scores documents with a field length that is not equal to the supplied constraint value.

Parameters:
constraintValue - the constraint value; may not be null
fieldName - the name of the document field containing the value; may not be null
factories - the value factories that can be used during the scoring; may not be null
Returns:
the query; never null

createQueryForNodesWithFieldGreaterThan

public static CompareLengthQuery createQueryForNodesWithFieldGreaterThan(Integer constraintValue,
                                                                         String fieldName,
                                                                         ValueFactories factories)
Construct a Query implementation that scores documents with a field length that is greater than the supplied constraint value.

Parameters:
constraintValue - the constraint value; may not be null
fieldName - the name of the document field containing the value; may not be null
factories - the value factories that can be used during the scoring; may not be null
Returns:
the query; never null

createQueryForNodesWithFieldGreaterThanOrEqualTo

public static CompareLengthQuery createQueryForNodesWithFieldGreaterThanOrEqualTo(Integer constraintValue,
                                                                                  String fieldName,
                                                                                  ValueFactories factories)
Construct a Query implementation that scores documents with a field length that is greater than or equal to the supplied constraint value.

Parameters:
constraintValue - the constraint value; may not be null
fieldName - the name of the document field containing the value; may not be null
factories - the value factories that can be used during the scoring; may not be null
Returns:
the query; never null

createQueryForNodesWithFieldLessThan

public static CompareLengthQuery createQueryForNodesWithFieldLessThan(Integer constraintValue,
                                                                      String fieldName,
                                                                      ValueFactories factories)
Construct a Query implementation that scores documents with a field length that is less than the supplied constraint value.

Parameters:
constraintValue - the constraint value; may not be null
fieldName - the name of the document field containing the value; may not be null
factories - the value factories that can be used during the scoring; may not be null
Returns:
the query; never null

createQueryForNodesWithFieldLessThanOrEqualTo

public static CompareLengthQuery createQueryForNodesWithFieldLessThanOrEqualTo(Integer constraintValue,
                                                                               String fieldName,
                                                                               ValueFactories factories)
Construct a Query implementation that scores documents with a field length that is less than or equal to the supplied constraint value.

Parameters:
constraintValue - the constraint value; may not be null
fieldName - the name of the document field containing the value; may not be null
factories - the value factories that can be used during the scoring; may not be null
Returns:
the query; never null

readFromDocument

protected Integer readFromDocument(org.apache.lucene.index.IndexReader reader,
                                   int docId)
                            throws IOException

Overrides:
readFromDocument in class CompareQuery<Integer>
Throws:
IOException
See Also:
CompareQuery.readFromDocument(org.apache.lucene.index.IndexReader, int)

clone

public Object clone()

Overrides:
clone in class org.apache.lucene.search.Query
See Also:
Query.clone()


Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.