edu.mit.ai.psg.jevaES
Class PrimitiveOperations

java.lang.Object
  |
  +--edu.mit.ai.psg.jevaES.PrimitiveOperations

public class PrimitiveOperations
extends Object

Binary Operations on Primitive types (numbers and booleans) represented by their wrapper types (e.g., int represented by Integer). Numbers are widened when number types are mismatched [JavaLangSpec 1.0 sec 5.6.2]. Operations throw IllegalArgumentException.

Author:
CarlManning, caroma@ai.mit.edu
Copyright (c) 1997, 1998 Massachusetts Institute of Technology
.   Operations:
.      multiplicative:  *, /, %             
.      additive:        -, +   (on numbers) 
.      comparitors:     <, >, <=, >=
.      equality:        ==, != 
.      boolean/bitwise: &, |, ^
.      bitwise:         ~, <<, >>, >>>
.      primitive casts

Method Summary
static Object add(Object oX, Object oY)
          Additive +
static Object and(Object oX, Object oY)
          Logical and Bitwise &
static Object bitwiseComplement(Object oX)
          Bitwise ~
static Object castPrimitive(Class castType, Object value)
          Throws ClassCastException, though primitive type mismatches are compile time errors, not runtime errors, so caller may want to catch the ClassCastException and throw an IllegalTypeException instead.
static Object defaultValue(Class storeType)
          [JavaLangSpec1.0sec4.5.4]
static Object divide(Object oX, Object oY)
          Multiplicative / promotes to Integer [JavaLangSpec1.0sec15.16]
static Boolean equals(Object oX, Object oY)
          Numerical Equality ==
static Boolean greaterThan(Object oX, Object oY)
          Relational >
static Boolean greaterThanOrEqualTo(Object oX, Object oY)
          Relational >=
static boolean isNumericValue(Object obj)
          true for Number or Character
static Object leftShift(Object oX, Object oY)
          Bitwise <<
static Boolean lessThan(Object oX, Object oY)
          Relational <
static Boolean lessThanOrEqualTo(Object oX, Object oY)
          Relational <=
static Object multiply(Object oX, Object oY)
          Multiplicative * promotes to Integer [JavaLangSpec1.0sec15.16]
static Object negate(Object obj)
          Unary - promotes byte, short, char to Integer [15.14.4 Unary Minus]
static Boolean notEquals(Object oX, Object oY)
          Numerical InEquality !=
static Object or(Object oX, Object oY)
          Logical and Bitwise |
static Object remainder(Object oX, Object oY)
          Multiplicative % promotes to Integer [JavaLangSpec1.0sec15.16]
static Object rightSignedShift(Object oX, Object oY)
          Bitwise >>
static Object rightUnsignedShift(Object oX, Object oY)
          Bitwise >>>
static Object subtract(Object oX, Object oY)
          Additive -
static Object unaryPlus(Object obj)
          Unary + promotes byte, short, char to Integer [15.14.3 Unary Plus]
static int unaryPromoteToInt(Object indexWrapper)
          At runtime, unary promote array dims/indexes to int (char promotes to int, but unfortunately Character is not a Number)
static Object xor(Object oX, Object oY)
          Logical and Bitwise ^
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isNumericValue

public static final boolean isNumericValue(Object obj)
true for Number or Character

unaryPromoteToInt

public static final int unaryPromoteToInt(Object indexWrapper)
At runtime, unary promote array dims/indexes to int (char promotes to int, but unfortunately Character is not a Number)

unaryPlus

public static final Object unaryPlus(Object obj)
Unary + promotes byte, short, char to Integer [15.14.3 Unary Plus]

negate

public static final Object negate(Object obj)
Unary - promotes byte, short, char to Integer [15.14.4 Unary Minus]

multiply

public static final Object multiply(Object oX,
                                    Object oY)
Multiplicative * promotes to Integer [JavaLangSpec1.0sec15.16]

divide

public static final Object divide(Object oX,
                                  Object oY)
                           throws ThrowException
Multiplicative / promotes to Integer [JavaLangSpec1.0sec15.16]
Throws:
ThrowException - of ArithmeticException

remainder

public static final Object remainder(Object oX,
                                     Object oY)
                              throws ThrowException
Multiplicative % promotes to Integer [JavaLangSpec1.0sec15.16]
Throws:
ThrowException - of ArithmeticException

add

public static final Object add(Object oX,
                               Object oY)
Additive +

subtract

public static final Object subtract(Object oX,
                                    Object oY)
Additive -

lessThan

public static final Boolean lessThan(Object oX,
                                     Object oY)
Relational <

greaterThan

public static final Boolean greaterThan(Object oX,
                                        Object oY)
Relational >

lessThanOrEqualTo

public static final Boolean lessThanOrEqualTo(Object oX,
                                              Object oY)
Relational <=

greaterThanOrEqualTo

public static final Boolean greaterThanOrEqualTo(Object oX,
                                                 Object oY)
Relational >=

equals

public static final Boolean equals(Object oX,
                                   Object oY)
Numerical Equality ==

notEquals

public static final Boolean notEquals(Object oX,
                                      Object oY)
Numerical InEquality !=

and

public static final Object and(Object oX,
                               Object oY)
Logical and Bitwise &

xor

public static final Object xor(Object oX,
                               Object oY)
Logical and Bitwise ^

or

public static final Object or(Object oX,
                              Object oY)
Logical and Bitwise |

bitwiseComplement

public static final Object bitwiseComplement(Object oX)
Bitwise ~

leftShift

public static final Object leftShift(Object oX,
                                     Object oY)
Bitwise <<

rightSignedShift

public static final Object rightSignedShift(Object oX,
                                            Object oY)
Bitwise >>

rightUnsignedShift

public static final Object rightUnsignedShift(Object oX,
                                              Object oY)
Bitwise >>>

castPrimitive

public static final Object castPrimitive(Class castType,
                                         Object value)
                                  throws ClassCastException
Throws ClassCastException, though primitive type mismatches are compile time errors, not runtime errors, so caller may want to catch the ClassCastException and throw an IllegalTypeException instead. (also handles useless boolean to boolean casts)

defaultValue

public static final Object defaultValue(Class storeType)
[JavaLangSpec1.0sec4.5.4]

Copyright (c) 1996-1999
Massachusetts Institute of Technology

Feedback: jeva-bugs@ai.mit.edu