| java.lang.Object org.gjt.sp.jedit.bsh.Primitive
Primitive | final public class Primitive implements ParserConstants,java.io.Serializable(Code) | | 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.
|
Method Summary | |
public static Object | binaryOperation(Object obj1, Object obj2, int kind) Perform a binary operation on two Primitives or wrapper types. | static Object | binaryOperationImpl(Object lhs, Object rhs, int kind) | static Boolean | booleanBinaryOperation(Boolean B1, Boolean B2, int kind) | static boolean | booleanUnaryOperation(Boolean B, int kind) | public boolean | booleanValue() | public static Class | boxType(Class primitiveType) Get the corresponding java.lang wrapper class for the primitive TYPE
class.
e.g. | static Primitive | castPrimitive(Class toType, Class fromType, Primitive fromValue, boolean checkOnly, int operation) | public Primitive | castToType(Class toType, int operation) Cast this bsh.Primitive value to a new bsh.Primitive value
This is usually a numeric type cast. | static Object | castWrapper(Class toType, Object value) Cast a primitive value represented by its java.lang wrapper type to the
specified java.lang wrapper type. | static Object | doubleBinaryOperation(Double D1, Double D2, int kind) | static double | doubleUnaryOperation(Double D, int kind) | public boolean | equals(Object obj) Primitives compare equal with other Primitives containing an equal
wrapped value. | static Object | floatBinaryOperation(Float F1, Float F2, int kind) | static float | floatUnaryOperation(Float F, int kind) | public static Primitive | getDefaultValue(Class type) | public Class | getType() Get the corresponding Java primitive TYPE class for this Primitive. | public Object | getValue() | 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. | static Object | intBinaryOperation(Integer I1, Integer I2, int kind) | static int | intUnaryOperation(Integer I, int kind) | public int | intValue() | public boolean | isNumber() Determine if this primitive is a numeric type.
i.e. | public static boolean | isWrapperType(Class type) | static Object | longBinaryOperation(Long L1, Long L2, int kind) | static long | longUnaryOperation(Long L, int kind) | public Number | numberValue() | static Object[] | promotePrimitives(Object lhs, Object rhs) Promote the pair of primitives to the maximum type of the two.
e.g. | static Object | promoteToInteger(Object wrapper) | public String | toString() | public static Primitive | unaryOperation(Primitive val, int kind) | public static Class | unboxType(Class wrapperType) Get the corresponding primitive TYPE class for the java.lang wrapper
class type.
e.g. | public static Object | unwrap(Object obj) Unwrap primitive values and map voids to nulls. | public static Object[] | unwrap(Object[] args) | public static Object[] | wrap(Object[] args, Class[] paramTypes) | public static Object | wrap(Object value, Class type) Wrap primitive values (as indicated by type param) and nulls in the
Primitive class. |
VOID | final public static Primitive VOID(Code) | | 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 | public Primitive(boolean value)(Code) | | |
Primitive | public Primitive(byte value)(Code) | | |
Primitive | public Primitive(short value)(Code) | | |
Primitive | public Primitive(char value)(Code) | | |
Primitive | public Primitive(int value)(Code) | | |
Primitive | public Primitive(long value)(Code) | | |
Primitive | public Primitive(float value)(Code) | | |
Primitive | public Primitive(double value)(Code) | | |
binaryOperation | public static Object binaryOperation(Object obj1, Object obj2, int kind) throws UtilEvalError(Code) | | 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.
|
boxType | public static Class boxType(Class primitiveType)(Code) | | Get the corresponding java.lang wrapper class for the primitive TYPE
class.
e.g. Integer.TYPE -> Integer.class
|
castToType | public Primitive castToType(Class toType, int operation) throws UtilEvalError(Code) | | 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
Parameters: toType - is the java object or primitive TYPE class |
castWrapper | static Object castWrapper(Class toType, Object value)(Code) | | Cast a primitive value represented by its java.lang wrapper type to the
specified java.lang wrapper type. e.g. Byte(5) to Integer(5) or
Integer(5) to Byte(5)
Parameters: toType - is the java TYPE type Parameters: value - is the value in java.lang wrapper.value may not be null. |
doubleUnaryOperation | static double doubleUnaryOperation(Double D, int kind)(Code) | | |
equals | public boolean equals(Object obj)(Code) | | Primitives compare equal with other Primitives containing an equal
wrapped value.
|
floatUnaryOperation | static float floatUnaryOperation(Float F, int kind)(Code) | | |
getDefaultValue | public static Primitive getDefaultValue(Class type)(Code) | | Get the appropriate default value per JLS 4.5.4
|
getType | public Class getType()(Code) | | Get the corresponding Java primitive TYPE class for this Primitive.
the primitive TYPE class type of the value or Void.TYPE forPrimitive.VOID or null value for type of Primitive.NULL |
getValue | public Object getValue()(Code) | | Return the primitive value stored in its java.lang wrapper class
|
hashCode | public int hashCode()(Code) | | The hash of the Primitive is tied to the hash of the wrapped value but
shifted so that they are not the same.
|
intUnaryOperation | static int intUnaryOperation(Integer I, int kind)(Code) | | |
isNumber | public boolean isNumber()(Code) | | Determine if this primitive is a numeric type.
i.e. not boolean, null, or void (but including char)
|
isWrapperType | public static boolean isWrapperType(Class type)(Code) | | |
longUnaryOperation | static long longUnaryOperation(Long L, int kind)(Code) | | |
promotePrimitives | static Object[] promotePrimitives(Object lhs, Object rhs)(Code) | | Promote the pair of primitives to the maximum type of the two.
e.g. [int,long]->[long,long]
|
promoteToInteger | static Object promoteToInteger(Object wrapper)(Code) | | Promote primitive wrapper type to to Integer wrapper type
|
unboxType | public static Class unboxType(Class wrapperType)(Code) | | Get the corresponding primitive TYPE class for the java.lang wrapper
class type.
e.g. Integer.class -> Integer.TYPE
|
unwrap | public static Object unwrap(Object obj)(Code) | | Unwrap primitive values and map voids to nulls.
Non Primitive types remain unchanged.
Parameters: obj - object type which may be bsh.Primitive corresponding "normal" Java type, "unwrapping" any bsh.Primitive types to their wrapper types. |
wrap | public static Object wrap(Object value, Class type)(Code) | | 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.
|
|
|