Class Condition

java.lang.Object
com.yahoo.prelude.semantics.rule.Condition
Direct Known Subclasses:
CompositeCondition, ConditionReference, EllipsisCondition, LiteralCondition, NotCondition, SuperCondition, TermCondition

public abstract class Condition extends Object
Superclass of all kinds of conditions of production rules
Author:
bratseth
  • Constructor Details

    • Condition

      public Condition()
    • Condition

      public Condition(String label)
    • Condition

      public Condition(String label, String context)
  • Method Details

    • setContextName

      public void setContextName(String contextName)
      Sets the name whatever is matched by this condition can be refered as, or null to make it nonreferable
    • getContextName

      public String getContextName()
      Returns the name whatever is matched by this condition can be referred as, or null if it is unreferable
    • isReferable

      protected boolean isReferable()
      Returns whether this is referable, returns context!=null by default
    • getLabel

      public String getLabel()
      Sets the label of this. Set to null to use the default
    • setLabel

      public void setLabel(String label)
      Returns the label of this, or null if none (the default)
    • getNameSpace

      public String getNameSpace()
      Returns the name of the namespace of this, or null if default (query)
    • setNameSpace

      public void setNameSpace(String nameSpace)
      Sets the name of the namespace of this
    • getParent

      public CompositeCondition getParent()
      Returns the condition this is nested within, or null if it is not nested
    • setAnchor

      public void setAnchor(Condition.Anchor anchor)
      Sets a positional constraint on this condition
    • getAnchor

      public Condition.Anchor getAnchor()
      Returns the positional constraint on this anchor. This is never null
    • matches

      public final boolean matches(RuleEvaluation e)
      Returns whether this condition matches the given evaluation at the current location of the evaluation. Calls the doesMatch method of each condition subtype.
    • matchesStartAnchor

      protected boolean matchesStartAnchor(RuleEvaluation e)
      Check start anchor. Trace level 4 if no match
    • matchesEndAnchor

      protected boolean matchesEndAnchor(RuleEvaluation e)
      Check start anchor. Trace level 4 if no match
    • traceResult

      protected void traceResult(boolean matches, RuleEvaluation e)
    • getMatchInfoString

      protected String getMatchInfoString(RuleEvaluation e)
    • preMatchHook

      protected void preMatchHook(RuleEvaluation e)
      Called when match is called, before anything else. Always call super.preMatchHook when overriding.
    • postMatchHook

      protected void postMatchHook(RuleEvaluation e)
      Called just before match returns, on any return condition including exceptions. Always call super.postMatchHook when overriding
    • getMatchInfo

      protected String getMatchInfo(RuleEvaluation e)
      Override this to return a string describing what this condition has matched in this evaluation. Will only be called when this condition is actually matched in this condition
      Returns:
      info about what is matched, or null if there is no info to return (default)
    • doesMatch

      protected abstract boolean doesMatch(RuleEvaluation e)
      Returns whether this condition matches the given evaluation at the current location of the evaluation. If there is a match, the evaluation must be advanced to the location beyond the matching item(s) before this method returns.
    • hasOpenChoicepoint

      protected boolean hasOpenChoicepoint(RuleEvaluation e)
      Returns whether there is an open choice in this or any of its subconditions. Returns false by default, must be overriden by conditions which may generate choices open accross multiple calls to matches, or contain such conditions.
    • makeReferences

      public void makeReferences(RuleBase rules)
      Override if references needs to be set in this condition of its children
    • getLabelString

      protected String getLabelString()
    • labelMatches

      protected boolean labelMatches(RuleEvaluation e)
      Whether the label matches the current item, true if there is no current item
    • labelMatches

      protected boolean labelMatches(TermItem evaluationTerm, RuleEvaluation e)
    • toInnerString

      protected abstract String toInnerString()
      All instances of this produces a parseable string output
    • isDefaultContextName

      protected boolean isDefaultContextName()
    • toString

      public String toString()
      Overrides:
      toString in class Object