com.mymed.utils
Enum ClassType

java.lang.Object
  extended by java.lang.Enum<ClassType>
      extended by com.mymed.utils.ClassType
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<ClassType>

public enum ClassType
extends java.lang.Enum<ClassType>

Enum type to store information about the class types. Information are stored as <Class, Primitive type>; for an int it is: <Integer, int>.

String is stored as <String, String>.

Author:
Milo Casagrande

Enum Constant Summary
BOOL
           
BYTE
           
CHAR
           
DOUBLE
           
FLOAT
           
INT
           
LONG
           
STRING
           
 
Method Summary
 java.lang.Class<?> getObjectClass()
           
 java.lang.Class<?> getPrimitiveType()
           
static ClassType inferTpye(java.lang.Class<?> classType)
          Infer the class type of the given, unknown, class
static ClassType inferType(java.lang.Object object)
          Infer the class type of the given Object
static ClassType inferType(java.lang.reflect.Type type)
          Infer the class type of the given, unknown, class
static java.lang.Object objectFromClassType(ClassType classType, byte[] arg)
          Create an abject of the specified ClassType type
static byte[] objectToByteArray(ClassType classType, java.lang.Object object)
          Convert an object of the specified ClassType into a byte array
 java.lang.String toString()
           
static ClassType valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static ClassType[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

BYTE

public static final ClassType BYTE

BOOL

public static final ClassType BOOL

CHAR

public static final ClassType CHAR

DOUBLE

public static final ClassType DOUBLE

FLOAT

public static final ClassType FLOAT

INT

public static final ClassType INT

LONG

public static final ClassType LONG

STRING

public static final ClassType STRING
Method Detail

values

public static ClassType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (ClassType c : ClassType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static ClassType valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

getObjectClass

public java.lang.Class<?> getObjectClass()
Returns:
the object class

getPrimitiveType

public java.lang.Class<?> getPrimitiveType()
Returns:
the primitive type

inferType

public static ClassType inferType(java.lang.Object object)
Infer the class type of the given Object

Parameters:
object - the Object to infer the Class of
Returns:
the ClassType enumeration type

inferTpye

public static ClassType inferTpye(java.lang.Class<?> classType)
Infer the class type of the given, unknown, class

Parameters:
classType - the class to infer its Class
Returns:
the ClassType enumeration type

inferType

public static ClassType inferType(java.lang.reflect.Type type)
Infer the class type of the given, unknown, class

Parameters:
type - the type to infer its Class
Returns:
the ClassType enumeration type

objectFromClassType

public static java.lang.Object objectFromClassType(ClassType classType,
                                                   byte[] arg)
Create an abject of the specified ClassType type

Parameters:
classType - the type of the object to create
arg - the byte array with the value of the object to create
Returns:
a new object

objectToByteArray

public static byte[] objectToByteArray(ClassType classType,
                                       java.lang.Object object)
Convert an object of the specified ClassType into a byte array

Parameters:
classType - the ClassType with the type of the object
object - the object to convert
Returns:
the byte array that represents the object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Enum<ClassType>