koala.dynamicjava.interpreter
Class InterpreterUtilities

java.lang.Object
  |
  +--koala.dynamicjava.interpreter.InterpreterUtilities

public class InterpreterUtilities
extends java.lang.Object

This class contains a collection of utility methods for interpretation


Inner Class Summary
protected static class InterpreterUtilities.AddOperation
          To encapsulate +
protected static class InterpreterUtilities.BinaryArithmeticOperation
          To encapsulate a binary operator
protected static class InterpreterUtilities.BinaryPredicate
          To encapsulate a boolean binary operator
protected static class InterpreterUtilities.BitAndOperation
          To encapsulate &
protected static class InterpreterUtilities.BitOrOperation
          To encapsulate |
protected static class InterpreterUtilities.BitwiseOperation
          To encapsulate a bitwise operator
protected static class InterpreterUtilities.DivideOperation
          To encapsulate /
protected static class InterpreterUtilities.EqualToPredicate
          To encapsulate ==
protected static class InterpreterUtilities.GreaterOrEqualOperation
          To encapsulate >=
protected static class InterpreterUtilities.GreaterThanOperation
          To encapsulate >
protected static class InterpreterUtilities.LessOrEqualOperation
          To encapsulate <=
protected static class InterpreterUtilities.LessThanOperation
          To encapsulate <
protected static class InterpreterUtilities.MinusOperation
          To encapulate -
protected static class InterpreterUtilities.MultiplyOperation
          To encapsulate *
protected static class InterpreterUtilities.NotEqualToPredicate
          To encapsulate !=
protected static class InterpreterUtilities.PlusOperation
          To encapulate +
protected static class InterpreterUtilities.RelationalOperation
          To encapsulate a relational operation
protected static class InterpreterUtilities.RemainderOperation
          To encapsulate %
protected static class InterpreterUtilities.ShiftLeftOperation
          To encapsulate <<
protected static class InterpreterUtilities.ShiftOperation
          To encapsulate a shift operator
protected static class InterpreterUtilities.ShiftRightOperation
          To encapsulate >>
protected static class InterpreterUtilities.SubtractOperation
          To encapsulate -
protected static class InterpreterUtilities.UnaryOperation
          To encapsulate an unary operator
protected static class InterpreterUtilities.UnsignedShiftRightOperation
          To encapsulate >>>
protected static class InterpreterUtilities.XOrOperation
          To encapsulate ^
 
Field Summary
static java.lang.Byte ONE
           
 
Constructor Summary
protected InterpreterUtilities()
          This class contains only static methods, so it is not useful to create instances of it.
 
Method Summary
static java.lang.Object add(java.lang.Class c, java.lang.Object l, java.lang.Object r)
          Returns the value of an addition
protected static java.lang.Object binaryArithmeticOperation(java.lang.Class c, java.lang.Object l, java.lang.Object r, InterpreterUtilities.BinaryArithmeticOperation o)
          Returns the value of a binary arithmetic operation
static java.lang.Object bitAnd(java.lang.Class c, java.lang.Object l, java.lang.Object r)
          Returns the value of a bit and operation
static java.lang.Object bitOr(java.lang.Class c, java.lang.Object l, java.lang.Object r)
          Returns the value of a bit or operation
protected static java.lang.Object bitwiseOperation(java.lang.Class c, java.lang.Object l, java.lang.Object r, InterpreterUtilities.BitwiseOperation o)
          Returns the value of a bitwise operation
static java.lang.Object divide(java.lang.Class c, java.lang.Object l, java.lang.Object r)
          Returns the value of a division
protected static java.lang.Object equalityOperation(java.lang.Class lc, java.lang.Class rc, java.lang.Object l, java.lang.Object r, InterpreterUtilities.BinaryPredicate p)
          Returns the value of an equality operation
static java.lang.Object equalTo(java.lang.Class lc, java.lang.Class rc, java.lang.Object l, java.lang.Object r)
          Returns the value of an equal to operation
static java.lang.Class getDeclaringClass(java.lang.Class c)
          Returns the declaring class of the given class
static java.lang.reflect.Field getOuterField(java.lang.Class cl, java.lang.String name)
          Returns a field with the given name declared in one of the outer classes of the given class
static java.lang.Object greaterOrEqual(java.lang.Object l, java.lang.Object r)
          Returns the value of a greater or equal operation
static java.lang.Object greaterThan(java.lang.Object l, java.lang.Object r)
          Returns the value of a greater than operation
static boolean isValidAssignment(java.lang.Class lc, java.lang.Object val)
           
static java.lang.Object lessOrEqual(java.lang.Object l, java.lang.Object r)
          Returns the value of a less or equal operation
static java.lang.Object lessThan(java.lang.Object l, java.lang.Object r)
          Returns the value of a less than operation
static java.lang.reflect.Method lookupOuterMethod(java.lang.Class cl, java.lang.String name, java.lang.Class[] ac)
          Looks up for a method in an outer classes of this class.
static java.lang.Object minus(java.lang.Class c, java.lang.Object o)
          Returns the value of an unary - operation
static java.lang.Object multiply(java.lang.Class c, java.lang.Object l, java.lang.Object r)
          Returns the value of a product
static java.lang.Object notEqualTo(java.lang.Class lc, java.lang.Class rc, java.lang.Object l, java.lang.Object r)
          Returns the value of a not equal to operation
static java.lang.Object plus(java.lang.Class c, java.lang.Object o)
          Returns the value of an unary + operation
protected static java.lang.Object relationalOperation(java.lang.Object l, java.lang.Object r, InterpreterUtilities.RelationalOperation o)
          Returns the value of a relational operation
static java.lang.Object remainder(java.lang.Class c, java.lang.Object l, java.lang.Object r)
          Returns the value of remainder of a division
static java.lang.Object shiftLeft(java.lang.Class c, java.lang.Object l, java.lang.Object r)
          Returns the value of a shift left operation
protected static java.lang.Object shiftOperation(java.lang.Class c, java.lang.Object l, java.lang.Object r, InterpreterUtilities.ShiftOperation o)
          Returns the value of a shift operation
static java.lang.Object shiftRight(java.lang.Class c, java.lang.Object l, java.lang.Object r)
          Returns the value of a shift right operation
static java.lang.Object subtract(java.lang.Class c, java.lang.Object l, java.lang.Object r)
          Returns the value of a subtraction
static java.lang.Object unaryOperation(java.lang.Class c, java.lang.Object o, InterpreterUtilities.UnaryOperation u)
          Returns the value of an unary operation
static java.lang.Object unsignedShiftRight(java.lang.Class c, java.lang.Object l, java.lang.Object r)
          Returns the value of an unsigned shift right operation
static java.lang.Object xOr(java.lang.Class c, java.lang.Object l, java.lang.Object r)
          Returns the value of a xor operation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONE

public static final java.lang.Byte ONE
Constructor Detail

InterpreterUtilities

protected InterpreterUtilities()
This class contains only static methods, so it is not useful to create instances of it.
Method Detail

equalTo

public static java.lang.Object equalTo(java.lang.Class lc,
                                       java.lang.Class rc,
                                       java.lang.Object l,
                                       java.lang.Object r)
Returns the value of an equal to operation
Parameters:
lc - the class of the left operand
rc - the class of the right operand
l - the left operand
r - the right operand

notEqualTo

public static java.lang.Object notEqualTo(java.lang.Class lc,
                                          java.lang.Class rc,
                                          java.lang.Object l,
                                          java.lang.Object r)
Returns the value of a not equal to operation
Parameters:
lc - the class of the left operand
rc - the class of the right operand
l - the left operand
r - the right operand

equalityOperation

protected static java.lang.Object equalityOperation(java.lang.Class lc,
                                                    java.lang.Class rc,
                                                    java.lang.Object l,
                                                    java.lang.Object r,
                                                    InterpreterUtilities.BinaryPredicate p)
Returns the value of an equality operation
Parameters:
lc - the class of the left operand
rc - the class of the right operand
l - the left operand
r - the right operand
p - the predicate to use

add

public static java.lang.Object add(java.lang.Class c,
                                   java.lang.Object l,
                                   java.lang.Object r)
Returns the value of an addition
Parameters:
c - the class of the result
l - the left operand
r - the right operand

subtract

public static java.lang.Object subtract(java.lang.Class c,
                                        java.lang.Object l,
                                        java.lang.Object r)
Returns the value of a subtraction
Parameters:
c - the class of the result
l - the left operand
r - the right operand

multiply

public static java.lang.Object multiply(java.lang.Class c,
                                        java.lang.Object l,
                                        java.lang.Object r)
Returns the value of a product
Parameters:
c - the class of the result
l - the left operand
r - the right operand

divide

public static java.lang.Object divide(java.lang.Class c,
                                      java.lang.Object l,
                                      java.lang.Object r)
Returns the value of a division
Parameters:
c - the class of the result
l - the left operand
r - the right operand

remainder

public static java.lang.Object remainder(java.lang.Class c,
                                         java.lang.Object l,
                                         java.lang.Object r)
Returns the value of remainder of a division
Parameters:
c - the class of the result
l - the left operand
r - the right operand

binaryArithmeticOperation

protected static java.lang.Object binaryArithmeticOperation(java.lang.Class c,
                                                            java.lang.Object l,
                                                            java.lang.Object r,
                                                            InterpreterUtilities.BinaryArithmeticOperation o)
Returns the value of a binary arithmetic operation
Parameters:
c - the class of the result
l - the left operand
r - the right operand
o - the operation

lessThan

public static java.lang.Object lessThan(java.lang.Object l,
                                        java.lang.Object r)
Returns the value of a less than operation
Parameters:
l - the left operand
r - the right operand

lessOrEqual

public static java.lang.Object lessOrEqual(java.lang.Object l,
                                           java.lang.Object r)
Returns the value of a less or equal operation
Parameters:
l - the left operand
r - the right operand

greaterThan

public static java.lang.Object greaterThan(java.lang.Object l,
                                           java.lang.Object r)
Returns the value of a greater than operation
Parameters:
l - the left operand
r - the right operand

greaterOrEqual

public static java.lang.Object greaterOrEqual(java.lang.Object l,
                                              java.lang.Object r)
Returns the value of a greater or equal operation
Parameters:
l - the left operand
r - the right operand

relationalOperation

protected static java.lang.Object relationalOperation(java.lang.Object l,
                                                      java.lang.Object r,
                                                      InterpreterUtilities.RelationalOperation o)
Returns the value of a relational operation
Parameters:
l - the left operand
r - the right operand
o - the operation

bitAnd

public static java.lang.Object bitAnd(java.lang.Class c,
                                      java.lang.Object l,
                                      java.lang.Object r)
Returns the value of a bit and operation
Parameters:
c - the class of the result
l - the left operand
r - the right operand

xOr

public static java.lang.Object xOr(java.lang.Class c,
                                   java.lang.Object l,
                                   java.lang.Object r)
Returns the value of a xor operation
Parameters:
c - the class of the result
l - the left operand
r - the right operand

bitOr

public static java.lang.Object bitOr(java.lang.Class c,
                                     java.lang.Object l,
                                     java.lang.Object r)
Returns the value of a bit or operation
Parameters:
c - the class of the result
l - the left operand
r - the right operand

bitwiseOperation

protected static java.lang.Object bitwiseOperation(java.lang.Class c,
                                                   java.lang.Object l,
                                                   java.lang.Object r,
                                                   InterpreterUtilities.BitwiseOperation o)
Returns the value of a bitwise operation
Parameters:
c - the class of the result
l - the left operand
r - the right operand
o - the operation

shiftLeft

public static java.lang.Object shiftLeft(java.lang.Class c,
                                         java.lang.Object l,
                                         java.lang.Object r)
Returns the value of a shift left operation
Parameters:
c - the class of the result
l - the left operand
r - the right operand

shiftRight

public static java.lang.Object shiftRight(java.lang.Class c,
                                          java.lang.Object l,
                                          java.lang.Object r)
Returns the value of a shift right operation
Parameters:
c - the class of the result
l - the left operand
r - the right operand

unsignedShiftRight

public static java.lang.Object unsignedShiftRight(java.lang.Class c,
                                                  java.lang.Object l,
                                                  java.lang.Object r)
Returns the value of an unsigned shift right operation
Parameters:
c - the class of the result
l - the left operand
r - the right operand

shiftOperation

protected static java.lang.Object shiftOperation(java.lang.Class c,
                                                 java.lang.Object l,
                                                 java.lang.Object r,
                                                 InterpreterUtilities.ShiftOperation o)
Returns the value of a shift operation
Parameters:
c - the class of the result
l - the left operand
r - the right operand
o - the operation

plus

public static java.lang.Object plus(java.lang.Class c,
                                    java.lang.Object o)
Returns the value of an unary + operation
Parameters:
c - the class of the result
o - the operand

minus

public static java.lang.Object minus(java.lang.Class c,
                                     java.lang.Object o)
Returns the value of an unary - operation
Parameters:
c - the class of the result
o - the operand

unaryOperation

public static java.lang.Object unaryOperation(java.lang.Class c,
                                              java.lang.Object o,
                                              InterpreterUtilities.UnaryOperation u)
Returns the value of an unary operation
Parameters:
c - the class of the result
o - the operand
u - the operation

getDeclaringClass

public static java.lang.Class getDeclaringClass(java.lang.Class c)
Returns the declaring class of the given class

getOuterField

public static java.lang.reflect.Field getOuterField(java.lang.Class cl,
                                                    java.lang.String name)
                                             throws java.lang.NoSuchFieldException,
                                                    AmbiguousFieldException
Returns a field with the given name declared in one of the outer classes of the given class
Parameters:
cl - the inner class
name - the name of the field

lookupOuterMethod

public static java.lang.reflect.Method lookupOuterMethod(java.lang.Class cl,
                                                         java.lang.String name,
                                                         java.lang.Class[] ac)
                                                  throws java.lang.NoSuchMethodException
Looks up for a method in an outer classes of this class.
Parameters:
cl - the inner class
name - the name of the method
ac - the arguments classes (possibly not the exact declaring classes)

isValidAssignment

public static boolean isValidAssignment(java.lang.Class lc,
                                        java.lang.Object val)


Copyright © 2001 Stephane Hillion. All Rights Reserved.