Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.RuntimeCollective.search.bean
Class SearchCriterion  view SearchCriterion download SearchCriterion.java

java.lang.Object
  extended bycom.RuntimeCollective.search.bean.SearchCriterion

public class SearchCriterion
extends java.lang.Object

One criterion to search by. Construct a new Criterion, giving the string to search for, e.g. "fish rubbish goat". Enclose sentences in quotes. You add criteria to a Search, before calling Search's getResults() method.

Version:
$Id: SearchCriterion.java,v 1.16 2003/09/30 15:12:57 joe Exp $

Field Summary
protected  java.lang.String criterion
           
protected static int DEFAULT_WEIGHT
           
protected  java.lang.String field
           
protected  boolean findAllWords
           
static char[] SPECIAL_CHARACTERS
          These are the current reserved characters used by Lucene.
protected  int weight
           
 
Constructor Summary
SearchCriterion(java.lang.String criterion)
          Make a new SearchCriterion, searching for any of criterion
SearchCriterion(java.lang.String criterion, boolean findAllWords)
          Make a new SearchCriterion
SearchCriterion(java.lang.String criterion, boolean findAllWords, java.lang.String field)
          Make a new SearchCriterion
SearchCriterion(java.lang.String criterion, boolean findAllWords, java.lang.String field, int weight)
          Make a new SearchCriterion
SearchCriterion(java.lang.String criterion, java.lang.String field)
          Make a new SearchCriterion
 
Method Summary
static java.lang.String cleanCriterion(java.lang.String criterion)
          Replaces +, -, :, ( and ) with a space in the given String, using Oro regular expressions
 java.lang.String getCriterion()
          Get the keywords, or phrase, to search for
 java.lang.String getField()
          Get the Field to limit this criterion to (optional)
 boolean getFindAllWords()
          Get Whether to search for all of these words (true), or any of them (false)
 java.lang.String getQuery()
          Returns a Lucene query string for searching for the given criteria
 int getWeight()
          Get the Weight, default to DEFAULT_WEIGHT
static void main(java.lang.String[] args)
           
private static int numberOfDoubleQuotes(java.lang.String string)
           
 void setCriterion(java.lang.String criterion)
          Set the keywords, or phrase, to search for.
 void setField(java.lang.String field)
          Set the Field to limit this criterion to (optional)
 void setFindAllWords(boolean findAllWords)
          Set Whether to search for all of these words (true), or any of them (false)
 void setWeight(int weight)
          Set the Weight, default to DEFAULT_WEIGHT
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPECIAL_CHARACTERS

public static final char[] SPECIAL_CHARACTERS
These are the current reserved characters used by Lucene. Any search term containing these will cause a problem. Therefore every character listed below gets escaped ('\' is placed infront of it). It is important that '\' comes at the beginning of the array otherwise the '\' used to escaped the other characters will themselves get escaped, which is not the desired behaviour.


criterion

protected java.lang.String criterion

findAllWords

protected boolean findAllWords

field

protected java.lang.String field

weight

protected int weight

DEFAULT_WEIGHT

protected static final int DEFAULT_WEIGHT
See Also:
Constant Field Values
Constructor Detail

SearchCriterion

public SearchCriterion(java.lang.String criterion)
Make a new SearchCriterion, searching for any of criterion


SearchCriterion

public SearchCriterion(java.lang.String criterion,
                       boolean findAllWords)
Make a new SearchCriterion


SearchCriterion

public SearchCriterion(java.lang.String criterion,
                       java.lang.String field)
Make a new SearchCriterion


SearchCriterion

public SearchCriterion(java.lang.String criterion,
                       boolean findAllWords,
                       java.lang.String field)
Make a new SearchCriterion


SearchCriterion

public SearchCriterion(java.lang.String criterion,
                       boolean findAllWords,
                       java.lang.String field,
                       int weight)
Make a new SearchCriterion

Method Detail

getCriterion

public java.lang.String getCriterion()
Get the keywords, or phrase, to search for


setCriterion

public void setCriterion(java.lang.String criterion)
Set the keywords, or phrase, to search for. Also cleans the given criterion of disallowed characters - see cleanCriterion


getFindAllWords

public boolean getFindAllWords()
Get Whether to search for all of these words (true), or any of them (false)


setFindAllWords

public void setFindAllWords(boolean findAllWords)
Set Whether to search for all of these words (true), or any of them (false)


getField

public java.lang.String getField()
Get the Field to limit this criterion to (optional)


setField

public void setField(java.lang.String field)
Set the Field to limit this criterion to (optional)


getWeight

public int getWeight()
Get the Weight, default to DEFAULT_WEIGHT


setWeight

public void setWeight(int weight)
Set the Weight, default to DEFAULT_WEIGHT


getQuery

public java.lang.String getQuery()
Returns a Lucene query string for searching for the given criteria


cleanCriterion

public static java.lang.String cleanCriterion(java.lang.String criterion)
Replaces +, -, :, ( and ) with a space in the given String, using Oro regular expressions


numberOfDoubleQuotes

private static int numberOfDoubleQuotes(java.lang.String string)

main

public static void main(java.lang.String[] args)