public final class Primitive extends java.lang.Object implements ParserConstants, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static Primitive |
NULL |
static Primitive |
VOID
VOID means "no type".
|
_DEFAULT, ABSTRACT, ANDASSIGN, ANDASSIGNX, ASSIGN, BANG, BIT_AND, BIT_ANDX, BIT_OR, BIT_ORX, BOOL_AND, BOOL_ANDX, BOOL_OR, BOOL_ORX, BOOLEAN, BREAK, BYTE, CASE, CATCH, CHAR, CHARACTER_LITERAL, CLASS, COLON, COMMA, CONST, CONTINUE, DECIMAL_LITERAL, DECR, DEFAULT, DIGIT, DO, DOT, DOUBLE, ELSE, ENUM, EOF, EQ, EXPONENT, EXTENDS, FALSE, FINAL, FINALLY, FLOAT, FLOATING_POINT_LITERAL, FOR, FORMAL_COMMENT, GE, GEX, GOTO, GT, GTX, HASH_BANG_COMMENT, HEX_LITERAL, HOOK, IDENTIFIER, IF, IMPLEMENTS, IMPORT, INCR, INSTANCEOF, INT, INTEGER_LITERAL, INTERFACE, LBRACE, LBRACKET, LE, LETTER, LEX, LONG, LPAREN, LSHIFT, LSHIFTASSIGN, LSHIFTASSIGNX, LSHIFTX, LT, LTX, MINUS, MINUSASSIGN, MOD, MODASSIGN, MULTI_LINE_COMMENT, NATIVE, NE, NEW, NONPRINTABLE, OCTAL_LITERAL, ORASSIGN, ORASSIGNX, PACKAGE, PLUS, PLUSASSIGN, PRIVATE, PROTECTED, PUBLIC, RBRACE, RBRACKET, RETURN, RPAREN, RSIGNEDSHIFT, RSIGNEDSHIFTASSIGN, RSIGNEDSHIFTASSIGNX, RSIGNEDSHIFTX, RUNSIGNEDSHIFT, RUNSIGNEDSHIFTASSIGN, RUNSIGNEDSHIFTASSIGNX, RUNSIGNEDSHIFTX, SEMICOLON, SHORT, SINGLE_LINE_COMMENT, SLASH, SLASHASSIGN, STAR, STARASSIGN, STATIC, STRICTFP, STRING_LITERAL, SWITCH, SYNCHRONIZED, THROW, THROWS, TILDE, tokenImage, TRANSIENT, TRUE, TRY, VOLATILE, WHILE, XOR, XORASSIGN
Constructor and Description |
---|
Primitive(boolean value) |
Primitive(byte value) |
Primitive(char value) |
Primitive(double value) |
Primitive(float value) |
Primitive(int value) |
Primitive(long value) |
Primitive(java.lang.Object value) |
Primitive(short value) |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
binaryOperation(java.lang.Object obj1,
java.lang.Object obj2,
int kind)
Perform a binary operation on two Primitives or wrapper types.
|
boolean |
booleanValue() |
static java.lang.Class |
boxType(java.lang.Class primitiveType)
Get the corresponding java.lang wrapper class for the primitive TYPE
class.
|
Primitive |
castToType(java.lang.Class toType,
int operation)
Cast this bsh.Primitive value to a new bsh.Primitive value
This is usually a numeric type cast.
|
boolean |
equals(java.lang.Object obj)
Primitives compare equal with other Primitives containing an equal
wrapped value.
|
static Primitive |
getDefaultValue(java.lang.Class type)
Get the appropriate default value per JLS 4.5.4
|
java.lang.Class |
getType()
Get the corresponding Java primitive TYPE class for this Primitive.
|
java.lang.Object |
getValue()
Return the primitive value stored in its java.lang wrapper class
|
int |
hashCode()
The hash of the Primitive is tied to the hash of the wrapped value but
shifted so that they are not the same.
|
int |
intValue() |
boolean |
isNumber()
Determine if this primitive is a numeric type.
|
static boolean |
isWrapperType(java.lang.Class type) |
java.lang.Number |
numberValue() |
java.lang.String |
toString() |
static Primitive |
unaryOperation(Primitive val,
int kind) |
static java.lang.Class |
unboxType(java.lang.Class wrapperType)
Get the corresponding primitive TYPE class for the java.lang wrapper
class type.
|
static java.lang.Object |
unwrap(java.lang.Object obj)
Unwrap primitive values and map voids to nulls.
|
static java.lang.Object[] |
unwrap(java.lang.Object[] args) |
static java.lang.Object[] |
wrap(java.lang.Object[] args,
java.lang.Class[] paramTypes) |
static java.lang.Object |
wrap(java.lang.Object value,
java.lang.Class type)
Wrap primitive values (as indicated by type param) and nulls in the
Primitive class.
|
public static final Primitive NULL
public static final Primitive VOID
public Primitive(java.lang.Object value)
public Primitive(boolean value)
public Primitive(byte value)
public Primitive(short value)
public Primitive(char value)
public Primitive(int value)
public Primitive(long value)
public Primitive(float value)
public Primitive(double value)
public java.lang.Object getValue()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Class getType()
public static java.lang.Object binaryOperation(java.lang.Object obj1, java.lang.Object obj2, int kind) throws UtilEvalError
UtilEvalError
public static Primitive unaryOperation(Primitive val, int kind) throws UtilEvalError
UtilEvalError
public int intValue() throws UtilEvalError
UtilEvalError
public boolean booleanValue() throws UtilEvalError
UtilEvalError
public boolean isNumber()
public java.lang.Number numberValue() throws UtilEvalError
UtilEvalError
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static java.lang.Object unwrap(java.lang.Object obj)
obj
- object type which may be bsh.Primitivepublic static java.lang.Object[] unwrap(java.lang.Object[] args)
public static java.lang.Object[] wrap(java.lang.Object[] args, java.lang.Class[] paramTypes)
public static java.lang.Object wrap(java.lang.Object value, java.lang.Class type)
The value null is mapped to Primitive.NULL. Any value specified with type Void.TYPE is mapped to Primitive.VOID.
public static Primitive getDefaultValue(java.lang.Class type)
public static java.lang.Class boxType(java.lang.Class primitiveType)
public static java.lang.Class unboxType(java.lang.Class wrapperType)
public Primitive castToType(java.lang.Class toType, int operation) throws UtilEvalError
toType
- is the java object or primitive TYPE classUtilEvalError
public static boolean isWrapperType(java.lang.Class type)