Class ncsa.horizon.util.JavaType
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ncsa.horizon.util.JavaType

java.lang.Object
   |
   +----ncsa.horizon.util.JavaType

public final class JavaType
extends Object
This class represents java primitive type information. It cannot be instantiated but contains 8 primitive public final static type and 1 object public final static type. It also provide a rich set of methods to automatically wrap and unwrap java primitive data, to create primitive data array, to access primitive data array.
The necessities of this class are justified in several situations.
1. Suppose a number wrapper nWrapper is returned, but the wrapper is not know of its type. If we somehow get its corresponding JavaType jType, we can call jType.value(nWrapper) to get the value. It is especially useful in wide conversion.
2. Allocate a 1-d array of corresponding primitive data type.
JDK1.1 provides 9 final static types, which have most of the functionalities of JavaType's 8 static types. However, if you want to allocate a 1-d array of corresponding primitive data type, JavaType is the way to go.

Variable Index

 o BOOLEAN
code: 1, name: "boolean", className: "Java.Lang.Boolean" data size: unknown
 o BYTE
code: 3, name: "byte", className: "Java.Lang.Integer" data size: 8
 o CHAR
code: 2, name: "char", className: "Java.Lang.Character" data size: 16
 o DOUBLE
code: 8, name: "double", className: "Java.Lang.Double" data size: 64
 o FLOAT
code: 7, name: "float", className: "Java.Lang.Float" data size: 32
 o INT
code: 5, name: "int", className: "Java.Lang.Integer" data size: 32
 o LONG
code: 6, name: "long", className: "Java.Lang.Long" data size: 64
 o OBJECT
code: 9, name: "Object", className: "Java.Lang.Object" data size: unknown
 o SHORT
code: 4, name: "short", className: "Java.Lang.Integer" data size: 16

Method Index

 o allocateArray(int)
Creates a new array with the specified length.
 o className()
 o code()
Provide a code to each array for the purpose of switch.
 o isSizeKnown()
 o name()
 o setArray(Object, int, Object)
Set the element of array at index to be value of the wrapper
 o size()
Returns the type memory saving length.
 o value(Boolean)
 o value(Character)
 o value(Double)
 o value(Float)
 o value(Integer)
 o value(Long)
 o wrap(boolean)
The overloading methods wrap corresponding primitive data type, and returns the wrapper.
 o wrap(byte)
The overloading methods wrap corresponding primitive data type, and returns the wrapper.
 o wrap(char)
The overloading methods wrap corresponding primitive data type, and returns the wrapper.
 o wrap(double)
The overloading methods wrap corresponding primitive data type, and returns the wrapper.
 o wrap(float)
The overloading methods wrap corresponding primitive data type, and returns the wrapper.
 o wrap(int)
The overloading methods wrap corresponding primitive data type, and returns the wrapper.
 o wrap(long)
The overloading methods wrap corresponding primitive data type, and returns the wrapper.
 o wrap(short)
The overloading methods wrap corresponding primitive data type, and returns the wrapper.
 o wrappedValueFromArray(Object, int)

Variables

 o BOOLEAN
  public final static JavaType BOOLEAN
code: 1, name: "boolean", className: "Java.Lang.Boolean" data size: unknown
 o CHAR
  public final static JavaType CHAR
code: 2, name: "char", className: "Java.Lang.Character" data size: 16
 o BYTE
  public final static JavaType BYTE
code: 3, name: "byte", className: "Java.Lang.Integer" data size: 8
 o SHORT
  public final static JavaType SHORT
code: 4, name: "short", className: "Java.Lang.Integer" data size: 16
 o INT
  public final static JavaType INT
code: 5, name: "int", className: "Java.Lang.Integer" data size: 32
 o LONG
  public final static JavaType LONG
code: 6, name: "long", className: "Java.Lang.Long" data size: 64
 o FLOAT
  public final static JavaType FLOAT
code: 7, name: "float", className: "Java.Lang.Float" data size: 32
 o DOUBLE
  public final static JavaType DOUBLE
code: 8, name: "double", className: "Java.Lang.Double" data size: 64
 o OBJECT
  public final static JavaType OBJECT
code: 9, name: "Object", className: "Java.Lang.Object" data size: unknown

Methods

 o allocateArray
  public Object allocateArray(int length) throws OutOfMemoryError
Creates a new array with the specified length. The new array is with primitive type represented by this object.
 o code
  public int code()
Provide a code to each array for the purpose of switch. The code for the types are:

1 for JavaType.BOOLEAN

2 for JavaType.CHAR

3 for JavaType.BYTE

4 for JavaType.SHORT

5 for JavaType.INT

6 for JavaType.LONG

7 for JavaType.FLOAT

8 for JavaType.DOUBLE

9 for JavaType.OBJECT

 o name
  public String name()
 o className
  public String className()
 o setArray
  public void setArray(Object array,
                       int index,
                       Object wrapper)
Set the element of array at index to be value of the wrapper
 o size
  public int size() throws NoSuchElementException
Returns the type memory saving length. If the length is unknow, java.util.NoSuchElementException will be thrown.
 o isSizeKnown
  public boolean isSizeKnown()
 o value
  public boolean value(Boolean wrapper)
 o value
  public char value(Character wrapper)
 o value
  public int value(Integer wrapper)
 o value
  public long value(Long wrapper)
 o value
  public float value(Float wrapper)
 o value
  public double value(Double wrapper)
 o wrap
  public Boolean wrap(boolean value)
The overloading methods wrap corresponding primitive data type, and returns the wrapper. Since no Byte for byte and no Short for short in JDK1.02, byte and short are wrapped in Integer.
If this javaType is asked to wrap a data with other data type, NumberFormatException is thrown.
 o wrap
  public Character wrap(char value)
The overloading methods wrap corresponding primitive data type, and returns the wrapper. Since no Byte for byte and no Short for short in JDK1.02, byte and short are wrapped in Integer.
If this javaType is asked to wrap a data with other data type, NumberFormatException is thrown.
 o wrap
  public Integer wrap(byte value)
The overloading methods wrap corresponding primitive data type, and returns the wrapper. Since no Byte for byte and no Short for short in JDK1.02, byte and short are wrapped in Integer.
If this javaType is asked to wrap a data with other data type, NumberFormatException is thrown.
 o wrap
  public Integer wrap(short value)
The overloading methods wrap corresponding primitive data type, and returns the wrapper. Since no Byte for byte and no Short for short in JDK1.02, byte and short are wrapped in Integer.
If this javaType is asked to wrap a data with other data type, NumberFormatException is thrown.
 o wrap
  public Integer wrap(int value)
The overloading methods wrap corresponding primitive data type, and returns the wrapper. Since no Byte for byte and no Short for short in JDK1.02, byte and short are wrapped in Integer.
If this javaType is asked to wrap a data with other data type, NumberFormatException is thrown.
 o wrap
  public Long wrap(long value)
The overloading methods wrap corresponding primitive data type, and returns the wrapper. Since no Byte for byte and no Short for short in JDK1.02, byte and short are wrapped in Integer.
If this javaType is asked to wrap a data with other data type, NumberFormatException is thrown.
 o wrap
  public Float wrap(float value)
The overloading methods wrap corresponding primitive data type, and returns the wrapper. Since no Byte for byte and no Short for short in JDK1.02, byte and short are wrapped in Integer.
If this javaType is asked to wrap a data with other data type, NumberFormatException is thrown.
 o wrap
  public Double wrap(double value)
The overloading methods wrap corresponding primitive data type, and returns the wrapper. Since no Byte for byte and no Short for short in JDK1.02, byte and short are wrapped in Integer.
If this javaType is asked to wrap a data with other data type, NumberFormatException is thrown.
 o wrappedValueFromArray
  public Object wrappedValueFromArray(Object array,
                                      int index)

All Packages  Class Hierarchy  This Package  Previous  Next  Index