org.ow2.jonas.lib.ejb21
Class JavaType

java.lang.Object
  extended by org.ow2.jonas.lib.ejb21.JavaType

public class JavaType
extends Object

This class implements methods which permit to get informations about Java Types:


(The Java Type may be or not a primitive type)

Author:
Helene Joanin : Initial developer, ico.Hoogervorst@nl.compuware.com : Support for BigInteger and avoid cast exceptions with rs.getObject()

Constructor Summary
JavaType()
           
 
Method Summary
static String getDefaultValue(Class c)
          Returns the default value of the given Java Type.
static String getName(Class c)
          Returns the name of the given type
static String getSQLGetMethod(Class c)
          Returns the name of the getXXX method associated with the given type in java.sql.ResultSet.
static String getSQLSetMethod(Class c)
          Returns the name of the setXXX method associated with the given type in java.sql.ResultSet.
static String getSQLType(Class c)
          Returns the SQL Type mapping the given Java Type.
static String getWrapperType(Class c)
          Returns the wrapper type of the given Java Type.
static boolean isCollecOrEnum(Class c)
          Returns true if the given class implements java.uti.Collection or java.util.Enumeration false otherwise.
static boolean isSerializable(Class c)
          Returns true if the given class is a Serializable Java Type, false otherwise.
static boolean isValidForRmi(Class c)
          Returns true if the given class is a valid type for RMI, false otherwise.
static boolean isVoid(Class c)
          Returns true if the given type is the type 'void'
static boolean isXxxObjectMethod(String name)
          Returns true if the given method name is getObject() or setObject()
static Boolean toObject(boolean val)
           
static Byte toObject(byte val)
           
static Character toObject(char val)
           
static Double toObject(double val)
           
static Float toObject(float val)
           
static Integer toObject(int val)
           
static Long toObject(long val)
           
static Object toObject(Object val)
           
static Short toObject(short val)
           
static String toStringObject(String name, Class c)
          If it is a primitive type, return a new Object constructor, else return the same object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaType

public JavaType()
Method Detail

isVoid

public static boolean isVoid(Class c)
Returns true if the given type is the type 'void'


getName

public static String getName(Class c)
Returns the name of the given type


isSerializable

public static boolean isSerializable(Class c)
Returns true if the given class is a Serializable Java Type, false otherwise.


isValidForRmi

public static boolean isValidForRmi(Class c)
Returns true if the given class is a valid type for RMI, false otherwise. Valid types for RMI are primitive types, remote objects, and non-remote objects that implement the java.io.Serializable interface


isCollecOrEnum

public static boolean isCollecOrEnum(Class c)
Returns true if the given class implements java.uti.Collection or java.util.Enumeration false otherwise.


getSQLGetMethod

public static String getSQLGetMethod(Class c)
Returns the name of the getXXX method associated with the given type in java.sql.ResultSet.

Parameters:
c - the class object for a Java type.
Returns:
a string representing the name of the get method, null in error case

getSQLSetMethod

public static String getSQLSetMethod(Class c)
Returns the name of the setXXX method associated with the given type in java.sql.ResultSet.

Parameters:
c - the class object for a Java type.
Returns:
a string representing the name of the set method, null in error case

isXxxObjectMethod

public static boolean isXxxObjectMethod(String name)
Returns true if the given method name is getObject() or setObject()


getSQLType

public static String getSQLType(Class c)
Returns the SQL Type mapping the given Java Type.

Parameters:
c - the class object for a Java type.
Returns:
the SQL Type mapping the given Java Type, (Types.OTHER in error case)

getDefaultValue

public static String getDefaultValue(Class c)
Returns the default value of the given Java Type.

Parameters:
c - the class object for a Java type.
Returns:
the default value of the given Java Type

getWrapperType

public static String getWrapperType(Class c)
Returns the wrapper type of the given Java Type.

Parameters:
c - the class object for a Java type.
Returns:
the wrapper type of the given Java Type. Empty String for non primitive classes

toObject

public static Boolean toObject(boolean val)

toObject

public static Byte toObject(byte val)

toObject

public static Short toObject(short val)

toObject

public static Integer toObject(int val)

toObject

public static Long toObject(long val)

toObject

public static Float toObject(float val)

toObject

public static Double toObject(double val)

toObject

public static Character toObject(char val)

toObject

public static Object toObject(Object val)

toStringObject

public static String toStringObject(String name,
                                    Class c)
If it is a primitive type, return a new Object constructor, else return the same object. There are nine predefined Class objects to represent the eight primitive types and void. These are created by the Java Virtual Machine, and have the same names as the primitive types that they represent, namely boolean, byte, char, short, int, long, float, and double.

Parameters:
name - name of the var
val - the object value
Returns:
new object


Copyright © 2010 OW2 Consortium. All Rights Reserved.