issrg.pba.rbac.xmlpolicy.ifstatement
Class OperationNode
java.lang.Object
issrg.pba.rbac.xmlpolicy.PolicyXMLNode
issrg.pba.rbac.xmlpolicy.ifstatement.TermNode
issrg.pba.rbac.xmlpolicy.ifstatement.OperationNode
- All Implemented Interfaces:
- Term
- Direct Known Subclasses:
- AndNode, EqNode, GeNode, GtNode, LeNode, LtNode, NotNode, OperatorNode, OrNode, PresentNode, SubstringsNode
public class OperationNode
- extends TermNode
This is an abstract class which is a base to other operations. The
sub-classes would only
need to have a valid constructor, so the XMLParser will be able to
instantiate a working
copy of it, and perhaps a static registration method to update the collection
of interpreters.
This class maintains a registry of Interpreters for each type of
operation. During evaluation time an Interpreter will be found in the
registry for the
required type of operation and it will be used to perform the evaluation.
If no Interpreter can be found for the specific set of Terms,
EvaluationException occurs.
- See Also:
Interpreter
Constructor Summary |
protected |
OperationNode()
|
|
OperationNode(java.lang.String nodeName,
org.xml.sax.Attributes attrs,
int maxOperandCount,
int minOperandCount)
This constructor builds an OperationNode given the name and the attributes
of the XML element, and the acceptable numbers of operands. |
Method Summary |
void |
construct()
The method builds a usual TermNode and then checks if an interpreter can
be found that
would agree to interpret the relevant terms (children nodes) and deliver a
definite result. |
java.lang.Object |
evaluate(Environment env)
This method evaluates the expression given the environment. |
java.lang.String |
getType()
This method returns the type of the value this term returns. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
type
protected java.lang.String type
interpreter
protected Interpreter interpreter
OperationNode
protected OperationNode()
OperationNode
public OperationNode(java.lang.String nodeName,
org.xml.sax.Attributes attrs,
int maxOperandCount,
int minOperandCount)
- This constructor builds an OperationNode given the name and the attributes
of the XML element, and the acceptable numbers of operands.
- Parameters:
nodeName
- - the name of the XML element this OperationNode representsattrs
- - the attributes of this XML elementmaxOperandCount
- - the maximum acceptable number of operands; if
"-1", any number of operands is acceptableminOperandCount
- - the minimum acceptable number of operands
construct
public void construct()
throws PolicyParsingException
- The method builds a usual TermNode and then checks if an interpreter can
be found that
would agree to interpret the relevant terms (children nodes) and deliver a
definite result.
If no such interpreter is found, a PolicyParsingException is thrown;
otherwise, the
interpreter will be used by the evaluate method, and the result type
reported by the canEvaluate
method of the interpreter will be returned by the getType method.
- Overrides:
construct
in class TermNode
- Throws:
PolicyParsingException
- if one of the above-stated conditions is
violated
getType
public java.lang.String getType()
- Description copied from interface:
Term
- This method returns the type of the value this term returns. The
types are defined by convention of the developers and RBAC policy
administrators.
- Returns:
- a case-sensitive type name as calculated at run-time
evaluate
public java.lang.Object evaluate(Environment env)
throws EvaluationException
- This method evaluates the expression given the environment. It uses the
Interpreter found during the call to construct();
- Parameters:
env
- - the Environment with the variables in it
- Returns:
- the Interpreter-specific object, guaranteed to be of type returned
by getType()
- Throws:
EvaluationException,
- if there was a problem evaluating the
expression
EvaluationException
- if the term cannot be evaluated