| java.lang.Object org.osbl.agent.model.condition.Operator
All known Subclasses: org.osbl.agent.model.condition.BinaryOperator, org.osbl.agent.model.condition.MethodOperator,
Operator | abstract public class Operator (Code) | | This class represents an operator which can be used in Conditions to evaluate the
operands specified in them.
It is defined abstract to allow different kinds of operators.
At the time of evaluation the concrete class of the operator has to provide a valid
Java expression by overriding
Operator.getExpression(String,String) . For constructing
such expression, the implementation can (and generally will) use whatever is stored
in the operatorCode.
For presentation purposes (for example when adding it to a ComboBox) it is possible
to assign a descriptive user friendly label to the operator.
author: Sebastian Nozzi. |
Constructor Summary | |
public | Operator() Instantiates a new operator. | public | Operator(String operatorString) Instantiates a new operator with a given String, serving both for code and for label. | public | Operator(String label, String operatorCode) Instantiates a new operator, specifying label and code. |
Method Summary | |
public boolean | equals(Object obj) Two operators are equal if their classes match and their internal code matches (which
is used in constructing the evaluating expression and therefor is a vital and
differentiating part of an operator). | public boolean | evaluate(String leftExpression, String rightExpression, RuleContext context) Perform the defined evaluation in this operator. | abstract protected String | getExpression(String left, String right) Subclasses override and implement this method, in which they should return a valid
Java (actually OGNL) expression that is then evaluated.
The implementation uses the given left and right parts and most certainly also
the stored operatorCode (that defines more or less the nature of the operation).
Parameters: left - the left part of the expression. Parameters: right - the right part of the expression. | public String | getLabel() Gets the a descriptive label of the operator. | public String | getOperatorCode() Gets the operator code. | public boolean | isNegated() Checks if the result of the evaluation will be negated. | public void | setLabel(String label) Sets a descriptive label for the operator. | public void | setNegated(boolean negated) Sets wether the result of the evaluation via this operator will be negated or not. | public void | setOperatorCode(String operatorCode) Sets the operator code, which aids the operator class to construct its evaluating expression. | public String | toString() Uses the specified label to return a friendly String version. |
Operator | public Operator()(Code) | | Instantiates a new operator.
|
Operator | public Operator(String operatorString)(Code) | | Instantiates a new operator with a given String, serving both for code and for label.
Parameters: operatorString - the operator string. |
Operator | public Operator(String label, String operatorCode)(Code) | | Instantiates a new operator, specifying label and code.
Parameters: label - the label. Parameters: operatorCode - the operator code. |
equals | public boolean equals(Object obj)(Code) | | Two operators are equal if their classes match and their internal code matches (which
is used in constructing the evaluating expression and therefor is a vital and
differentiating part of an operator).
If the classes don't match, the default implementation is used.
Parameters: obj - the obj true, if equals See Also: java.lang.Object.equals(java.lang.Object) |
evaluate | public boolean evaluate(String leftExpression, String rightExpression, RuleContext context)(Code) | | Perform the defined evaluation in this operator. The passed parameters left and rightExpression
are also implementation dependant. They would be typically the left and right operands.
A "root object" also has to be specified, for which all references to methods and/or
fields are relative to.
Parameters: leftExpression - the left expression, or operand Parameters: rightExpression - the right expression, or operand Parameters: context - the context the boolean result if the evaluation was successful, false in case of error. |
getExpression | abstract protected String getExpression(String left, String right)(Code) | | Subclasses override and implement this method, in which they should return a valid
Java (actually OGNL) expression that is then evaluated.
The implementation uses the given left and right parts and most certainly also
the stored operatorCode (that defines more or less the nature of the operation).
Parameters: left - the left part of the expression. Parameters: right - the right part of the expression. the expression as suitable for the concrete implemented operator. |
getLabel | public String getLabel()(Code) | | Gets the a descriptive label of the operator.
the label |
getOperatorCode | public String getOperatorCode()(Code) | | Gets the operator code.
the operator code. |
isNegated | public boolean isNegated()(Code) | | Checks if the result of the evaluation will be negated.
true, if result will be negated. |
setLabel | public void setLabel(String label)(Code) | | Sets a descriptive label for the operator.
Parameters: label - the new label. |
setNegated | public void setNegated(boolean negated)(Code) | | Sets wether the result of the evaluation via this operator will be negated or not.
Parameters: negated - true, if it should be negated, false if not. |
setOperatorCode | public void setOperatorCode(String operatorCode)(Code) | | Sets the operator code, which aids the operator class to construct its evaluating expression.
Parameters: operatorCode - the new operator code. |
|
|