issrg.pba.rbac.xmlpolicy.ifstatement
Class OperationNode

java.lang.Object
  extended by issrg.pba.rbac.xmlpolicy.PolicyXMLNode
      extended by issrg.pba.rbac.xmlpolicy.ifstatement.TermNode
          extended by 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

Field Summary
protected  Interpreter interpreter
           
protected  java.lang.String type
           
 
Fields inherited from class issrg.pba.rbac.xmlpolicy.ifstatement.TermNode
maxOperand, minOperand, terms
 
Fields inherited from class issrg.pba.rbac.xmlpolicy.PolicyXMLNode
attributes, children, name, nodeStr
 
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 issrg.pba.rbac.xmlpolicy.ifstatement.TermNode
getInterpretersForNode, registerInterpreterForNode
 
Methods inherited from class issrg.pba.rbac.xmlpolicy.PolicyXMLNode
addChild, addString, getAttributes, getChildren, getName, getString, toString, toXML, toXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected java.lang.String type

interpreter

protected Interpreter interpreter
Constructor Detail

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 represents
attrs - - the attributes of this XML element
maxOperandCount - - the maximum acceptable number of operands; if "-1", any number of operands is acceptable
minOperandCount - - the minimum acceptable number of operands
Method Detail

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