issrg.pba.rbac.xmlpolicy.ifstatement
Class StringInterpreter

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

public class StringInterpreter
extends java.lang.Object
implements Interpreter

This is the interpreter for comparisons of strings in the IF-statements. It provides the following semantics:

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
           
static int SUBSTRINGS_MODE
           
 
Constructor Summary
protected StringInterpreter()
           
protected StringInterpreter(int mode)
          This is the constructor used to build the interpreter for different types of comparison operation: an interpreter for Substrings, 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.STRING_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, SubstringsNode.
 
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

SUBSTRINGS_MODE

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

StringInterpreter

protected StringInterpreter()

StringInterpreter

protected StringInterpreter(int mode)
This is the constructor used to build the interpreter for different types of comparison operation: an interpreter for Substrings, 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 SUBSTRINGS_MODE, 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, SubstringsNode. The interpreter provides the conventional semantics of vocabulary order of strings for those operations, as explained above.


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.STRING_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.STRING_TYPE
Returns:
java.lang.Boolean object that contains the boolean result of evaluation, as determined by the mode provided at construction time
Throws:
EvaluationException