程序包 bsh
类 Primitive
java.lang.Object
bsh.Primitive
- 所有已实现的接口:
ParserConstants
,Serializable
Wrapper for primitive types in Bsh. This is package public because it
is used in the implementation of some bsh commands.
See the note in LHS.java about wrapping objects.
- 另请参阅:
-
字段概要
字段从接口继承的字段 bsh.ParserConstants
_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
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static Object
binaryOperation
(Object obj1, Object obj2, int kind) Perform a binary operation on two Primitives or wrapper types.boolean
static Class
Get the corresponding java.lang wrapper class for the primitive TYPE class.castToType
(Class toType, int operation) Cast this bsh.Primitive value to a new bsh.Primitive value This is usually a numeric type cast.boolean
Primitives compare equal with other Primitives containing an equal wrapped value.static Primitive
getDefaultValue
(Class type) Get the appropriate default value per JLS 4.5.4getType()
Get the corresponding Java primitive TYPE class for this Primitive.getValue()
Return the primitive value stored in its java.lang wrapper classint
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
(Class type) toString()
static Primitive
unaryOperation
(Primitive val, int kind) static Class
Get the corresponding primitive TYPE class for the java.lang wrapper class type.static Object
Unwrap primitive values and map voids to nulls.static Object[]
static Object[]
static Object
Wrap primitive values (as indicated by type param) and nulls in the Primitive class.
-
字段详细资料
-
NULL
-
VOID
VOID means "no type". Strictly speaking, this makes no sense here. But for practical reasons we'll consider the lack of a type to be a special value.
-
-
构造器详细资料
-
Primitive
-
Primitive
public Primitive(boolean value) -
Primitive
public Primitive(byte value) -
Primitive
public Primitive(short value) -
Primitive
public Primitive(char value) -
Primitive
public Primitive(int value) -
Primitive
public Primitive(long value) -
Primitive
public Primitive(float value) -
Primitive
public Primitive(double value)
-
-
方法详细资料
-
getValue
Return the primitive value stored in its java.lang wrapper class -
toString
-
getType
Get the corresponding Java primitive TYPE class for this Primitive.- 返回:
- the primitive TYPE class type of the value or Void.TYPE for Primitive.VOID or null value for type of Primitive.NULL
-
binaryOperation
Perform a binary operation on two Primitives or wrapper types. If both original args were Primitives return a Primitive result else it was mixed (wrapper/primitive) return the wrapper type. The exception is for boolean operations where we will return the primitive type either way.- 抛出:
UtilEvalError
-
unaryOperation
- 抛出:
UtilEvalError
-
intValue
- 抛出:
UtilEvalError
-
booleanValue
- 抛出:
UtilEvalError
-
isNumber
public boolean isNumber()Determine if this primitive is a numeric type. i.e. not boolean, null, or void (but including char) -
numberValue
- 抛出:
UtilEvalError
-
equals
Primitives compare equal with other Primitives containing an equal wrapped value. -
hashCode
public 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. -
unwrap
Unwrap primitive values and map voids to nulls. Non Primitive types remain unchanged.- 参数:
obj
- object type which may be bsh.Primitive- 返回:
- corresponding "normal" Java type, "unwrapping" any bsh.Primitive types to their wrapper types.
-
unwrap
-
wrap
-
wrap
Wrap primitive values (as indicated by type param) and nulls in the Primitive class. Values not primitive or null are left unchanged. Primitive values are represented by their wrapped values in param value. The value null is mapped to Primitive.NULL. Any value specified with type Void.TYPE is mapped to Primitive.VOID. -
getDefaultValue
Get the appropriate default value per JLS 4.5.4 -
boxType
Get the corresponding java.lang wrapper class for the primitive TYPE class. e.g. Integer.TYPE -> Integer.class -
unboxType
Get the corresponding primitive TYPE class for the java.lang wrapper class type. e.g. Integer.class -> Integer.TYPE -
castToType
Cast this bsh.Primitive value to a new bsh.Primitive value This is usually a numeric type cast. Other cases include: A boolean can be cast to boolen null can be cast to any object type and remains null Attempting to cast a void causes an exception- 参数:
toType
- is the java object or primitive TYPE class- 抛出:
UtilEvalError
-
isWrapperType
-