org.exolab.castor.mapping.loader
Class Types
java.lang.Object
org.exolab.castor.mapping.loader.Types
public class Types
extends java.lang.Object
Type information. Can be used to map between short type names (such
as 'int') and actual Java types (java.lang.Integer), to determine
whether a type is simple (i.e. maps to a single XML attribute, SQL
column, etc), as well as to create a new instance of a type.
$Revision: 1.4 $ $Date: 2003/04/23 08:48:20 $(package private) static class | Types.TypeInfo - Information about a specific Java type.
|
(package private) static TypeInfo[] | _typeInfos - List of all the simple types supported by Castor.
|
static Object | getDefault(Class type) - Returns the default value for this Java type (e.g.
|
static String | getFullDatePattern(String pattern) - Transforms short date format pattern into full format pattern
for SimpleDateFormat (e.g., "YMD" to "yyyyMMdd").
|
static boolean | isCloneable(Class type) - Returns true if the Java type implements the
Cloneable
interface.
|
static boolean | isConstructable(Class type) - Returns true if the objects of this class are constructable.
|
static boolean | isConstructable(Class type, boolean allowAbstractOrInterface) - Returns true if the objects of this class are constructable.
|
static boolean | isImmutable(Class type) - Returns true if the Java type is immutable.
|
static boolean | isPrimitiveType(Class type) - Returns true if the Java type is represented as a primitive type.
|
static boolean | isSerializable(Class type) - Returns true if the Java type implements the
Serializable
interface.
|
static boolean | isSimpleType(Class type) - Returns true if the Java type is represented as a simple type.
|
static Object | newInstance(Class type) - Constructs a new object from the given class.
|
static Object | newInstance(Class type, args[] ) - Constructs a new object from the given class.
|
static Class | typeFromName(ClassLoader loader, String typeName) - Returns the class name based on the supplied type name.
|
static Class | typeFromPrimitive(Class type) - Maps from a primitive Java type to a Java class.
|
_typeInfos
(package private) static TypeInfo[] _typeInfos
List of all the simple types supported by Castor.
getDefault
public static Object getDefault(Class type)
Returns the default value for this Java type (e.g. 0 for integer, empty
string) or null if no default value is known. The default value only
applies to primitive types (that is, Integer.TYPE but not
java.lang.Integer).
- The default value or null
getFullDatePattern
public static String getFullDatePattern(String pattern)
Transforms short date format pattern into full format pattern
for SimpleDateFormat (e.g., "YMD" to "yyyyMMdd").
pattern
- The short pattern
isCloneable
public static boolean isCloneable(Class type)
Returns true if the Java type implements the Cloneable
interface.
- True if declared as cloneable
isConstructable
public static boolean isConstructable(Class type)
Returns true if the objects of this class are constructable.
The class must be publicly available and have a default public
constructor.
isConstructable
public static boolean isConstructable(Class type,
boolean allowAbstractOrInterface)
Returns true if the objects of this class are constructable.
The class must be publicly available and have a default public
constructor.
isImmutable
public static boolean isImmutable(Class type)
Returns true if the Java type is immutable. Immutable objects are
not copied.
isPrimitiveType
public static boolean isPrimitiveType(Class type)
Returns true if the Java type is represented as a primitive type. Wrapper
like java.lang.Integer are considered as primitive.
isSerializable
public static boolean isSerializable(Class type)
Returns true if the Java type implements the Serializable
interface.
- True if declared as serializable
isSimpleType
public static boolean isSimpleType(Class type)
Returns true if the Java type is represented as a simple type.
A simple can be described with a single XML attribute value,
a single SQL column, a single LDAP attribute value, etc.
The following types are considered simple:
- All primitive types
- String
- Date
- java.sql.Date
- java.sql.Time
- Timestamp
- byte/char arrays
- BigDecimal
newInstance
public static Object newInstance(Class type)
throws IllegalStateException
Constructs a new object from the given class. Does not generate any
checked exceptions, since object creation has been proven to work
when creating descriptor from mapping.
newInstance
public static Object newInstance(Class type,
args[] )
throws IllegalStateException
Constructs a new object from the given class. Does not generate any
checked exceptions, since object creation has been proven to work
when creating descriptor from mapping.
typeFromName
public static Class typeFromName(ClassLoader loader,
String typeName)
throws ClassNotFoundException
Returns the class name based on the supplied type name. The type name
can be a short name (e.g. int, byte) or any other Java class (e.g.
myapp.Product). If a short type name is used, the primitive type might
be returned. If a Java class name is used, the class will be loaded and
returned through the supplied class loader.
loader
- The class loader to use, may be nulltypeName
- The type name
typeFromPrimitive
public static Class typeFromPrimitive(Class type)
Maps from a primitive Java type to a Java class. Returns the same class
if
type is not a primitive. The following conversion applies:
From To
-------------- ---------------
Boolean.TYPE Boolean.class
Byte.TYPE Byte.class
Character.TYPE Character.class
Short.TYPE Short.class
Integer.TYPE Integer.class
Long.TYPE Long.class
Float.TYPE Float.class
Double.TYPE Double.class
type
- The Java type (primitive or not)
- A comparable non-primitive Java type
Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com