public final class Primitive
extends java.lang.Object
implements java.io.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.
| Modifier and Type | Field and Description |
|---|---|
static Primitive |
FALSE |
static Primitive |
NULL |
static Primitive |
TRUE |
static Primitive |
VOID
VOID means "no type".
|
static Primitive |
ZERO_BIG_DECIMAL |
static Primitive |
ZERO_BIG_INTEGER |
static Primitive |
ZERO_BYTE |
static Primitive |
ZERO_CHAR
Default zero value constants
|
static Primitive |
ZERO_DOUBLE |
static Primitive |
ZERO_FLOAT |
static Primitive |
ZERO_INT |
static Primitive |
ZERO_LONG |
static Primitive |
ZERO_SHORT |
| Constructor and Description |
|---|
Primitive(java.math.BigDecimal value) |
Primitive(java.math.BigInteger value) |
Primitive(boolean value) |
Primitive(byte value) |
Primitive(char value) |
Primitive(double value) |
Primitive(float value) |
Primitive(int value) |
Primitive(long value) |
Primitive(short value) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
boolean |
isNumber()
Determine if this primitive is a numeric type.
|
static boolean |
isWrapperType(java.lang.Class<?> type) |
java.lang.Number |
numberValue() |
static Primitive |
shrinkWrap(java.lang.Object number) |
java.lang.String |
toString() |
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 TRUE
public static final Primitive FALSE
public static final Primitive ZERO_CHAR
public static final Primitive ZERO_BYTE
public static final Primitive ZERO_SHORT
public static final Primitive ZERO_INT
public static final Primitive ZERO_LONG
public static final Primitive ZERO_FLOAT
public static final Primitive ZERO_DOUBLE
public static final Primitive ZERO_BIG_INTEGER
public static final Primitive ZERO_BIG_DECIMAL
public static final Primitive NULL
public static final Primitive VOID
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 Primitive(java.math.BigInteger value)
public Primitive(java.math.BigDecimal value)
public java.lang.Object getValue()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.Class<?> getType()
public static Primitive shrinkWrap(java.lang.Object number)
public boolean isNumber()
public java.lang.Number numberValue()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic 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)
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 classUtilEvalErrorpublic static boolean isWrapperType(java.lang.Class<?> type)