issrg.pba.rbac.xmlpolicy.ifstatement
Class IntegerInterpreter

java.lang.Object
  extended by issrg.pba.rbac.xmlpolicy.ifstatement.IntegerInterpreter
All Implemented Interfaces:
Interpreter

public class IntegerInterpreter
extends java.lang.Object
implements Interpreter

This is the interpreter for comparisons of integers in the IF-statements.

Author:
A.Otenko

Field Summary
static int EQ_MODE
           
static int GE_MODE
           
static int GT_MODE
           
static int LE_MODE
           
static int LT_MODE
           
protected  int mode
           
 
Constructor Summary
protected IntegerInterpreter()
           
protected IntegerInterpreter(int mode)
          This is the constructor used to build the interpreter for different types of comparison operation: an interpreter for GE, LE, GT, LT and EQ correspondingly.
 
Method Summary
 java.lang.String canEvaluate(Term[] t)
          This method tells whether this interpreter can evaluate the expression, which is only if there are only two Terms, and both are of type Types.INTEGER_TYPE.
 java.lang.Object evaluate(Environment env, Term[] t)
          This method evaluates the comparison expression, depending on the mode it was given at construction time.
static void register()
          Call this method to register the IntegerInterpreter with the relevant expression nodes: EqNode, GeNode, GtNode, LeNode, LtNode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mode

protected int mode

EQ_MODE

public static final int EQ_MODE
See Also:
Constant Field Values

GE_MODE

public static final int GE_MODE
See Also:
Constant Field Values

LE_MODE

public static final int LE_MODE
See Also:
Constant Field Values

GT_MODE

public static final int GT_MODE
See Also:
Constant Field Values

LT_MODE

public static final int LT_MODE
See Also:
Constant Field Values
Constructor Detail

IntegerInterpreter

protected IntegerInterpreter()

IntegerInterpreter

protected IntegerInterpreter(int mode)
This is the constructor used to build the interpreter for different types of comparison operation: an interpreter for GE, LE, GT, LT and EQ correspondingly. The evaluate method will return the comparison result corresponding to this mode.

Parameters:
mode - stands for the mode of operation; it can be one of EQ_MODE, GE_MODE, LE_MODE, GT_MODE or LT_MODE
Method Detail

register

public static void register()
Call this method to register the IntegerInterpreter with the relevant expression nodes: EqNode, GeNode, GtNode, LeNode, LtNode. The interpreter provides the conventional semantics of number comparison for those operations.


canEvaluate

public java.lang.String canEvaluate(Term[] t)
This method tells whether this interpreter can evaluate the expression, which is only if there are only two Terms, and both are of type Types.INTEGER_TYPE.

Specified by:
canEvaluate in interface Interpreter
Parameters:
t - - the array of Terms to be evaluated
Returns:
Types.BOOLEAN_TYPE, if the expression can be evaluated; null otherwise

evaluate

public java.lang.Object evaluate(Environment env,
                                 Term[] t)
                          throws EvaluationException
This method evaluates the comparison expression, depending on the mode it was given at construction time. If the expression can be evaluated, it returns a java.lang.Boolean object; otherwise a EvaluationException is thrown.

Specified by:
evaluate in interface Interpreter
Parameters:
env - - the Environment in which the evaluation occurs
t - - the array of Terms to be evaluated; should contain two and only two Terms, each of type Types.INTEGER_TYPE
Returns:
java.lang.Boolean object that contains the boolean result of evaluation, as determined by the mode provided at construction time
Throws:
EvaluationException