|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jdmf.data.output.AbstractRuleElementEvaluable
net.sf.jdmf.data.output.RuleElement
public class RuleElement
A single rule element that consists of an item, a logical operator that links this element to other elements within a rule; alternatively, a rule element may contain a list of subelements. The simplest rule element consists of a single item:
(first_colour = 'red')Rule elements define how items and logical operators are grouped within a rule and evaluated. Example:
(first_colour = 'red') AND (second_colour = 'blue' OR second_colour = 'cyan')There are two rule elements here: the first defines a single item (
first_colour = 'red'
) and has no logical operator. The second
rule element does not define an item, but has a logical operator
(AND
) and a list of two subelements. The first subelement
defines a single item (second_colour = 'blue'
) and has no
logical operator, while the second subelement also defines a single item
(second_colour = 'cyan'
) and a logical operator
(OR
).
Grouping is quite important if we are not satisfied with the default
evaluation mode (from left to right; all logical operators are equally
important here).
Classes: Rule
and RuleElement
offer a few helpful
methods allowing developers to define rules like sentences. As long as those
methods are used to define rules, there is no need to worry about
implementation details (and when it comes to the details - it is worth
mentioning that the logical operator is always defined in the same element as
the right operand of the operator). Subelements need to be defined separately
and added to the parent rule element explicitly.
Rule
,
AbstractRuleElementEvaluable
,
Item
Constructor Summary | |
---|---|
RuleElement()
|
|
RuleElement(Item item)
|
|
RuleElement(Item item,
LogicalOperator logicalOperator)
|
Method Summary | |
---|---|
void |
addSubElement(RuleElement subElement)
|
RuleElement |
and(Rule parentRule)
Appends a new rule element using the AND operator. |
RuleElement |
attribute(java.lang.String attributeName)
Defines the attribute name of an item. |
RuleElement |
doesNotEqual(java.lang.Comparable attributeValue)
Defines the relation between the attribute name and value within an item. |
RuleElement |
equals(java.lang.Comparable attributeValue)
Defines the relation between the attribute name and value within an item. |
boolean |
equals(java.lang.Object obj)
|
boolean |
evaluate(Instance instance)
|
Item |
getItem()
|
LogicalOperator |
getLogicalOperator()
|
RuleElement |
isGreaterThan(java.lang.Comparable attributeValue)
Defines the relation between the attribute name and value within an item. |
RuleElement |
isGreaterThanOrEqualTo(java.lang.Comparable attributeValue)
Defines the relation between the attribute name and value within an item. |
RuleElement |
isLowerThan(java.lang.Comparable attributeValue)
Defines the relation between the attribute name and value within an item. |
RuleElement |
isLowerThanOrEqualTo(java.lang.Comparable attributeValue)
Defines the relation between the attribute name and value within an item. |
RuleElement |
or(Rule parentRule)
Appends a new rule element using the OR operator. |
void |
setItem(Item item)
|
void |
setLogicalOperator(LogicalOperator logicalOperator)
|
java.util.Iterator<RuleElement> |
subElementsIterator()
|
java.lang.String |
toString()
|
RuleElement |
xor(Rule parentRule)
Appends a new rule element using the XOR operator. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public RuleElement()
public RuleElement(Item item)
public RuleElement(Item item, LogicalOperator logicalOperator)
Method Detail |
---|
public boolean evaluate(Instance instance)
Evaluable.evaluate(net.sf.jdmf.data.input.attribute.Instance)
public RuleElement attribute(java.lang.String attributeName)
public RuleElement equals(java.lang.Comparable attributeValue)
public RuleElement doesNotEqual(java.lang.Comparable attributeValue)
public RuleElement isGreaterThan(java.lang.Comparable attributeValue)
public RuleElement isGreaterThanOrEqualTo(java.lang.Comparable attributeValue)
public RuleElement isLowerThan(java.lang.Comparable attributeValue)
public RuleElement isLowerThanOrEqualTo(java.lang.Comparable attributeValue)
public RuleElement and(Rule parentRule)
public RuleElement or(Rule parentRule)
public RuleElement xor(Rule parentRule)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public void addSubElement(RuleElement subElement)
public java.util.Iterator<RuleElement> subElementsIterator()
public Item getItem()
public void setItem(Item item)
public LogicalOperator getLogicalOperator()
public void setLogicalOperator(LogicalOperator logicalOperator)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |