com.iphrase.runtime.query.constraint
Class Constraint

java.lang.Object
  |
  +--com.iphrase.runtime.query.Feature
        |
        +--com.iphrase.runtime.query.constraint.Constraint
Direct Known Subclasses:
Bool, DateTime, DateTime.Range, Enumerated, Example, Mentions, Null, Numeric, Numeric.Range, Taxonomy, Text, Within

public abstract class Constraint
extends Feature

Abstract base class for all atomic constraints.


Inner Class Summary
static interface Constraint.Flags
          Define Constraint feature flag values.
 
Method Summary
 void clearExplicit()
          Remove the "Explicit" flag.
 void clearHidden()
          Reveal the constraint, i.e.
 void clearNew()
          Specify that the constraint is carried over from past queries.
 void clearNotSerialized()
          Specify that the constraint applies after IR pruning, i.e., make it 'not prepruned'.
 void clearPrePruned()
          Specify that the constraint applies after IR pruning, i.e., make it 'not prepruned'.
 void clearRequired()
          Optionalize the constraint, i.e.
 void clearState(int state)
          Clear the custom state
 boolean equals(java.lang.Object o)
          Determine whether this Constraint is equivalent to another, passed as an Object because this method overrides Object.equals(java.lang.Object).
 java.lang.String getConstraintLabel()
          Gets the (optional) constraint label.
abstract  java.lang.String getConstraintSubType()
           
 java.lang.String getDisplayPrefix()
          Returns constraint display prefix.
 boolean getIsMentions()
          Determine if this constraint is an instance of type Mentions.
 boolean getState(int state)
          Determine if the custom state is set.
 java.lang.String getType()
           
abstract  java.lang.Object getValue()
          Get the value associated with this constraint.
 boolean isExplicit()
          Determine if the constraint is 'Explicit'.
 boolean isHidden()
          Determine if the constraint is 'hidden'.
 boolean isMentions()
          Determine if this constraint is an instance of type Mentions.
 boolean isNew()
          Determine if the constraint is 'new'.
 boolean isNotSerialized()
          Determine if the constraint is 'prepruned'.
 boolean isPrePruned()
          Determine if the constraint is 'prepruned'.
static boolean isRangeConstraintType(java.lang.String type)
          Determine whether a String constraint type represents a range constraint.
 boolean isRequired()
          Determine if the constraint is 'required'.
 boolean matches(Constraint c)
          Determine whether this constraint matches another.
static Constraint newInstance(java.lang.String state)
          Create a new Constraint from a OneStep serialization String.
static Constraint newInstance(java.lang.String type, java.lang.String op, java.lang.String feature, java.lang.Object value)
          Create a new Constraint from (drill-down) tally tree data.
static Constraint newInstance(java.lang.String type, java.lang.String op, java.lang.String feature, java.lang.Object value, java.lang.String label)
          Create a new Constraint from (drill-down) tally tree data.
 void setExplicit()
          Specify that the constraint explicitly set by user.
 void setHidden()
          Hide the constraint, i.e.
 void setHidden(boolean isNotSerialized)
          Hide the constraint and set its serialization state.
 void setNew()
          Specify that the current query has just added this constraint.
 void setNotSerialized()
          Specify that the constraint applies before IR pruning, i.e., make it 'prepruned'.
 void setPrePruned()
          Specify that the constraint applies before IR pruning, i.e., make it 'prepruned'.
 void setRequired()
          Require the constraint, i.e.
 void setState(int state)
          Set the custom state
 
Methods inherited from class com.iphrase.runtime.query.Feature
getId
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getValue

public abstract java.lang.Object getValue()
Get the value associated with this constraint. This method must be overridden by each constraint subclass.
Returns:
Object value associated with this constraint

isMentions

public boolean isMentions()
Determine if this constraint is an instance of type Mentions. This predicate is useful for contexts like JSTL, where instanceof is not available.
Returns:
true if instanceof Mentions, otherwise false

getIsMentions

public boolean getIsMentions()
Determine if this constraint is an instance of type Mentions. Identical to isMentions(), but starts with 'get' in order to expose bean property to JSP/JSTL.
Returns:
true if instance of Mentions, otherwise false

isHidden

public boolean isHidden()
Determine if the constraint is 'hidden'. A hidden constraint is invisible and not serialized.
Returns:
true if the constraint is 'hidden', else false.

setHidden

public void setHidden()
Hide the constraint, i.e. make it hidden.
See Also:
isHidden()

clearHidden

public void clearHidden()
Reveal the constraint, i.e. make it non-hidden.
See Also:
isHidden()

getState

public boolean getState(int state)
Determine if the custom state is set.
Parameters:
state - bitmask
Returns:
true if the custom state is set, else false

setState

public void setState(int state)
Set the custom state
Parameters:
state - bitmask
See Also:
getState(int)

clearState

public void clearState(int state)
Clear the custom state
Parameters:
state - bitmask
See Also:
getState(int)

setHidden

public void setHidden(boolean isNotSerialized)
Hide the constraint and set its serialization state.
Parameters:
isNotSerialized - specifies either the constraint is serialized or not
See Also:
setHidden()

isRequired

public boolean isRequired()
Determine if the constraint is 'required'. A required constraint should not be relaxed (removed).
Returns:
true if the constraint is 'required', else false.

setRequired

public void setRequired()
Require the constraint, i.e. make it required.
See Also:
isRequired()

clearRequired

public void clearRequired()
Optionalize the constraint, i.e. make it non-required.
See Also:
isRequired()

isPrePruned

public boolean isPrePruned()
Determine if the constraint is 'prepruned'. A prepruned constraint is applied before IR pruning.
Returns:
true if the constraint is 'prepruned', else false.

setPrePruned

public void setPrePruned()
Specify that the constraint applies before IR pruning, i.e., make it 'prepruned'.
See Also:
isPrePruned()

clearPrePruned

public void clearPrePruned()
Specify that the constraint applies after IR pruning, i.e., make it 'not prepruned'.
See Also:
isPrePruned()

isExplicit

public boolean isExplicit()
Determine if the constraint is 'Explicit'. This can affect how the feature is rendered and preference during backoff (non-EXPLICIT features are relaxed first)
Returns:
true if the constraint is 'Explicit', else false.

setExplicit

public void setExplicit()
Specify that the constraint explicitly set by user.
See Also:
isExplicit()

clearExplicit

public void clearExplicit()
Remove the "Explicit" flag.
See Also:
isExplicit()

isNew

public boolean isNew()
Determine if the constraint is 'new'. Constraint that was carried over from past queries have this flag cleared.
Returns:
true if the constraint is 'new', else false.

setNew

public void setNew()
Specify that the current query has just added this constraint.
See Also:
isNew()

clearNew

public void clearNew()
Specify that the constraint is carried over from past queries.
See Also:
isNew()

isNotSerialized

public boolean isNotSerialized()
Determine if the constraint is 'prepruned'. A prepruned constraint is applied before IR pruning.
Returns:
true if the constraint is 'prepruned', else false.

setNotSerialized

public void setNotSerialized()
Specify that the constraint applies before IR pruning, i.e., make it 'prepruned'.
See Also:
isPrePruned()

clearNotSerialized

public void clearNotSerialized()
Specify that the constraint applies after IR pruning, i.e., make it 'not prepruned'.
See Also:
isPrePruned()

matches

public boolean matches(Constraint c)
Determine whether this constraint matches another. Most subclasses will override this version, but call it to weed out cases where the type or feature id don't match.
Parameters:
c - Constraint to be matched against this
Returns:
true if the two constraints are of the same type and have identical fields except for their flags, else false.

equals

public boolean equals(java.lang.Object o)
Determine whether this Constraint is equivalent to another, passed as an Object because this method overrides Object.equals(java.lang.Object).
Overrides:
equals in class java.lang.Object
Parameters:
o - another constraint
Returns:
true if the two constraints are of the same type and have identical fields, else false.

getDisplayPrefix

public java.lang.String getDisplayPrefix()
Returns constraint display prefix.
Returns:
one of the following values: "in", "nin", "neq", "<", ">", "<=", ">=", "ssl", "ssr", "ss", "nssl", "nss", ""

getConstraintSubType

public abstract java.lang.String getConstraintSubType()
Returns:
constraint subType

getType

public java.lang.String getType()
Returns:
constraint type

newInstance

public static Constraint newInstance(java.lang.String type,
                                     java.lang.String op,
                                     java.lang.String feature,
                                     java.lang.Object value)
                              throws ArgumentError
Create a new Constraint from (drill-down) tally tree data.
Parameters:
type - String constraint type
op - String constraint op (sub-type)
feature - String feature id
value - Object feature value
Returns:
new Constraint instance

newInstance

public static Constraint newInstance(java.lang.String type,
                                     java.lang.String op,
                                     java.lang.String feature,
                                     java.lang.Object value,
                                     java.lang.String label)
                              throws ArgumentError
Create a new Constraint from (drill-down) tally tree data.
Parameters:
type - String constraint type
op - String constraint op (sub-type)
feature - String feature id
value - Object feature value
label - String optional label
Returns:
new Constraint instance

newInstance

public static Constraint newInstance(java.lang.String state)
                              throws ArgumentError
Create a new Constraint from a OneStep serialization String.
Parameters:
state - OneStep serialization String
Returns:
deserialized Constraint instance
Throws:
ArgumentError -  

getConstraintLabel

public java.lang.String getConstraintLabel()
Gets the (optional) constraint label.
Returns:
constraintLabel property

isRangeConstraintType

public static boolean isRangeConstraintType(java.lang.String type)
Determine whether a String constraint type represents a range constraint.
Parameters:
type - String constraint type
Returns:
true if range constraint type, else false

© Copyright 2005, 2006. IBM Corporation. All rights reserved.