com.languagecomputer.api.query
Class DefaultKeyword

java.lang.Object
  extended by com.languagecomputer.api.query.DefaultKeyword
All Implemented Interfaces:
Keyword

public class DefaultKeyword
extends Object
implements Keyword

Default implementation of a Keyword. Alternatively, the Keyword interface may be implemented in order to be backed by a different mechanism (i.e., for speed and/or memory performance based on the individual system).

Since:
1.0
Author:
Kirk Roberts

Constructor Summary
DefaultKeyword()
           
 
Method Summary
 String getRawString()
          Returns the raw String (unstemmed) for this Keyword (required).
 double getWeight()
          Returns the weight for this Keyword (optional operation).
 boolean isExact()
          Indicates this Keyword should not be stemmed (optional operation).
 boolean isMandatory()
          Indicates this Keyword is mandatory (optional operation).
 void setIsExact(boolean isExact)
          Forces the DefaultKeyword to be exact or not (optional operation).
 void setIsMandatory(boolean isMandatory)
          Forces the DefaultKeyword to be mandatory or not (optional operation).
 void setRawString(String rawString)
          Sets the raw string of this DefaultKeyword.
 void setWeight(double weight)
          Sets the weight of this DefaultKeyword (optional operation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultKeyword

public DefaultKeyword()
Method Detail

setRawString

public void setRawString(String rawString)
Sets the raw string of this DefaultKeyword.

Parameters:
rawString - The non-null String representation of the keyword.
Throws:
IllegalArgumentException - If the rawString is null.

getRawString

public String getRawString()
Returns the raw String (unstemmed) for this Keyword (required).

Specified by:
getRawString in interface Keyword
Returns:
A raw String representation of this Keyword.
Throws:
IllegalStateException - If setRawString(java.lang.String) has not been called.

setWeight

public void setWeight(double weight)
Sets the weight of this DefaultKeyword (optional operation). If not called, the default weight is 1.0.

Parameters:
weight - Weight value within range (0.0-1.0].
Throws:
IllegalArgumentException - If the weight is outside the expected range.
See Also:
getWeight()

getWeight

public double getWeight()
Returns the weight for this Keyword (optional operation). The weight must be on a scale of 0.0 (exclusive) to 1.0 (inclusive). If determining keyword weights is not possible, a weight of 1.0 should be given.

Specified by:
getWeight in interface Keyword
Returns:
The (0.0-1.0] weight of this Keyword.

setIsMandatory

public void setIsMandatory(boolean isMandatory)
Forces the DefaultKeyword to be mandatory or not (optional operation). If not called, the default is that the keyword is not mandatory.

Parameters:
isMandatory - Whether or not the keyword should be mandatory.
See Also:
isMandatory

isMandatory

public boolean isMandatory()
Indicates this Keyword is mandatory (optional operation). The default should be false.

Specified by:
isMandatory in interface Keyword
Returns:
true if this Keyword must be included in any results to a Query, false otherwise.

setIsExact

public void setIsExact(boolean isExact)
Forces the DefaultKeyword to be exact or not (optional operation). If not called, the default is that the keyword is not exact (stemmable).

Parameters:
isExact - Whether or not the keyword should be exact.
See Also:
isExact

isExact

public boolean isExact()
Indicates this Keyword should not be stemmed (optional operation). The default should be false.

Specified by:
isExact in interface Keyword
Returns:
true if this Keyword should not be stemmed for searches, false otherwise.


Copyright © 2009. All Rights Reserved.