Class RuleEvaluation
- java.lang.Object
-
- com.yahoo.prelude.semantics.engine.RuleEvaluation
-
public class RuleEvaluation extends Object
A particular evaluation of a particular rule.- Author:
- bratseth
-
-
Constructor Summary
Constructors Constructor Description RuleEvaluation(Evaluation owner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addItem(Item item, TermType termType)
Adds an item to the query being evaluated in a way consistent with the query typevoid
addMatch(FlattenedItem item, String replaceString)
Adds a matchFlattenedItem
currentItem()
Returns the current term item to look at, or null if there are no more elementsint
currentPosition()
Returns the position of the current itemvoid
entering(String context)
Choicepoint
getChoicepoint(Condition condition, boolean create)
Add a choice point to this evaluationString
getCurrentLabel()
Evaluation
getEvaluation()
Returns the evaluation this belongs toMatch
getNonreferencedMatch(int index)
int
getNonreferencedMatchCount()
int
getPosition()
Returns the current position into the terms this evaluates overint
getReferencedMatchCount()
ReferencedMatches
getReferencedMatches(String name)
Returns the referenced matches for a context name, or null if noneint
getTraceLevel()
Object
getValue()
Returns the last value returned by a condition in this evaluation, or nullvoid
indentTrace()
void
initialize(List<FlattenedItem> list, int startPosition)
void
insertItem(Item item, CompositeItem parent, int index, TermType termType)
Inserts an item to the query being evaluated in a way consistent with the query typeboolean
isInNegation()
Returns whether we are evaluating inside a condition which inverts the truth valueint
itemCount()
Returns the total number of items to match in this evaluationList<FlattenedItem>
items()
Returns a read-only view of the items of thisvoid
leaving(String context)
FlattenedItem
next()
Advances currentItem to the next term item and returns thatItem.FlattenedItem
previousItem()
void
removeItem(int position, Item item)
Removes an item, prefers the one at/close to the given position if there are multiple onesvoid
removeItem(Item item)
void
removeItemByIdentity(Item item)
void
removeMatches(ReferencedMatches matches)
Remove all the terms recognized by this matchString
setCurrentLabel(String currentLabel)
Sets a new current label and returns the previous onevoid
setInNegation(boolean inNegation)
sets whether we are evaluating inside a condition which inverts the truth valuevoid
setMatchReferences(Set<String> matchReferences)
void
setPosition(int position)
Sets the current positionvoid
setValue(Object value)
Sets the last value returned by a condition in this evaluatiino, or nullvoid
trace(int level, String string)
void
unindentTrace()
-
-
-
Constructor Detail
-
RuleEvaluation
public RuleEvaluation(Evaluation owner)
-
-
Method Detail
-
initialize
public void initialize(List<FlattenedItem> list, int startPosition)
-
currentItem
public FlattenedItem currentItem()
Returns the current term item to look at, or null if there are no more elements
-
previousItem
public FlattenedItem previousItem()
-
currentPosition
public int currentPosition()
Returns the position of the current item
-
setPosition
public void setPosition(int position)
Sets the current position
-
itemCount
public int itemCount()
Returns the total number of items to match in this evaluation
-
getValue
public Object getValue()
Returns the last value returned by a condition in this evaluation, or null
-
setValue
public void setValue(Object value)
Sets the last value returned by a condition in this evaluatiino, or null
-
isInNegation
public boolean isInNegation()
Returns whether we are evaluating inside a condition which inverts the truth value
-
setInNegation
public void setInNegation(boolean inNegation)
sets whether we are evaluating inside a condition which inverts the truth value
-
getPosition
public int getPosition()
Returns the current position into the terms this evaluates over
-
setCurrentLabel
public String setCurrentLabel(String currentLabel)
Sets a new current label and returns the previous one
-
getCurrentLabel
public String getCurrentLabel()
-
next
public FlattenedItem next()
Advances currentItem to the next term item and returns thatItem. If the current item before this call is the last item, this will return (and set currentItem to) null.
-
entering
public void entering(String context)
-
leaving
public void leaving(String context)
-
addMatch
public void addMatch(FlattenedItem item, String replaceString)
Adds a match- Parameters:
item
- the match to addreplaceString
- the string to replace this match by, usually the item.getIndexedValue()
-
getReferencedMatches
public ReferencedMatches getReferencedMatches(String name)
Returns the referenced matches for a context name, or null if none
-
getReferencedMatchCount
public int getReferencedMatchCount()
-
getNonreferencedMatchCount
public int getNonreferencedMatchCount()
-
getEvaluation
public Evaluation getEvaluation()
Returns the evaluation this belongs to
-
addItem
public void addItem(Item item, TermType termType)
Adds an item to the query being evaluated in a way consistent with the query type
-
removeItem
public void removeItem(Item item)
-
removeItemByIdentity
public void removeItemByIdentity(Item item)
-
removeItem
public void removeItem(int position, Item item)
Removes an item, prefers the one at/close to the given position if there are multiple ones
-
insertItem
public void insertItem(Item item, CompositeItem parent, int index, TermType termType)
Inserts an item to the query being evaluated in a way consistent with the query type- Parameters:
item
- the item to insertparent
- the parent of this item, or null to set the rootindex
- the index at which to insert this into the parenttermType
- the kind of item to index, this decides the resulting structure
-
items
public List<FlattenedItem> items()
Returns a read-only view of the items of this
-
getNonreferencedMatch
public Match getNonreferencedMatch(int index)
-
trace
public void trace(int level, String string)
-
getTraceLevel
public int getTraceLevel()
-
indentTrace
public void indentTrace()
-
unindentTrace
public void unindentTrace()
-
getChoicepoint
public Choicepoint getChoicepoint(Condition condition, boolean create)
Add a choice point to this evaluation- Parameters:
condition
- the creating conditioncreate
- true to create this choicepoint if it is missing- Returns:
- the choicepoint, or null if not present, and create is false
-
removeMatches
public void removeMatches(ReferencedMatches matches)
Remove all the terms recognized by this match
-
-