Package org.apache.openjpa.meta
Class JavaTypes
- java.lang.Object
-
- org.apache.openjpa.meta.JavaTypes
-
- Direct Known Subclasses:
JavaSQLTypes
public class JavaTypes extends java.lang.Object
Type constants for managed fields.- Author:
- Abe White
-
-
Field Summary
Fields Modifier and Type Field Description static int
ARRAY
static int
BIGDECIMAL
static int
BIGINTEGER
static int
BOOLEAN
static int
BOOLEAN_OBJ
static int
BYTE
static int
BYTE_OBJ
static int
CALENDAR
static int
CHAR
static int
CHAR_OBJ
static int
COLLECTION
static int
DATE
static int
DOUBLE
static int
DOUBLE_OBJ
static int
ENUM
static int
FLOAT
static int
FLOAT_OBJ
static int
INPUT_READER
static int
INPUT_STREAM
static int
INT
static int
INT_OBJ
static int
LOCAL_DATE
static int
LOCAL_DATETIME
static int
LOCAL_TIME
static int
LOCALE
static int
LONG
static int
LONG_OBJ
static int
MAP
static int
NUMBER
static int
OBJECT
static int
OFFSET_DATETIME
static int
OFFSET_TIME
static int
OID
static int
PC
static int
PC_UNTYPED
static int
SHORT
static int
SHORT_OBJ
static int
STRING
-
Constructor Summary
Constructors Constructor Description JavaTypes()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Class<?>
classForName(java.lang.String name, ClassMetaData context)
Check the given name against the same set of standard packages used when parsing metadata.static java.lang.Class<?>
classForName(java.lang.String name, ClassMetaData context, java.lang.ClassLoader loader)
Check the given name against the same set of standard packages used when parsing metadata.static java.lang.Class<?>
classForName(java.lang.String name, ClassMetaData context, java.lang.ClassLoader loader, boolean mustExist)
Check the given name against the same set of standard packages used when parsing metadata.static java.lang.Class<?>
classForName(java.lang.String name, ValueMetaData context)
Check the given name against the same set of standard packages used when parsing metadata.static java.lang.Class<?>
classForName(java.lang.String name, ValueMetaData context, java.lang.ClassLoader loader)
Check the given name against the same set of standard packages used when parsing metadata.static java.lang.Class<?>
classForName(java.lang.String name, ValueMetaData context, java.lang.ClassLoader loader, boolean mustExist)
Try to load a class using the provided loader.static java.lang.Object
convert(java.lang.Object val, int typeCode)
Convert the given object to the given type if possible.static int
getTypeCode(java.lang.Class<?> type)
Return the field metadata type code for the given class.static boolean
isPrimitiveDefault(java.lang.Object o, int typeCode)
Determine whether or not the provided Object value is the default for the provided typeCode.static boolean
maybePC(FieldMetaData field)
Return true if the (possibly unresolved) field or its elements might be persistence capable objects.static boolean
maybePC(ValueMetaData val)
Return true if the (possibly unresolved) value might be a first class object.static java.lang.Object
toArray(java.util.Collection<?> coll, java.lang.Class<?> elem)
Helper method to return the given collection as an array.static <T> java.util.List<T>
toList(java.lang.Object val, java.lang.Class<T> elem, boolean mutable)
Helper method to return the given array value as a collection.
-
-
-
Field Detail
-
BOOLEAN
public static final int BOOLEAN
- See Also:
- Constant Field Values
-
BYTE
public static final int BYTE
- See Also:
- Constant Field Values
-
CHAR
public static final int CHAR
- See Also:
- Constant Field Values
-
DOUBLE
public static final int DOUBLE
- See Also:
- Constant Field Values
-
FLOAT
public static final int FLOAT
- See Also:
- Constant Field Values
-
INT
public static final int INT
- See Also:
- Constant Field Values
-
LONG
public static final int LONG
- See Also:
- Constant Field Values
-
SHORT
public static final int SHORT
- See Also:
- Constant Field Values
-
OBJECT
public static final int OBJECT
- See Also:
- Constant Field Values
-
STRING
public static final int STRING
- See Also:
- Constant Field Values
-
NUMBER
public static final int NUMBER
- See Also:
- Constant Field Values
-
ARRAY
public static final int ARRAY
- See Also:
- Constant Field Values
-
COLLECTION
public static final int COLLECTION
- See Also:
- Constant Field Values
-
MAP
public static final int MAP
- See Also:
- Constant Field Values
-
DATE
public static final int DATE
- See Also:
- Constant Field Values
-
PC
public static final int PC
- See Also:
- Constant Field Values
-
BOOLEAN_OBJ
public static final int BOOLEAN_OBJ
- See Also:
- Constant Field Values
-
BYTE_OBJ
public static final int BYTE_OBJ
- See Also:
- Constant Field Values
-
CHAR_OBJ
public static final int CHAR_OBJ
- See Also:
- Constant Field Values
-
DOUBLE_OBJ
public static final int DOUBLE_OBJ
- See Also:
- Constant Field Values
-
FLOAT_OBJ
public static final int FLOAT_OBJ
- See Also:
- Constant Field Values
-
INT_OBJ
public static final int INT_OBJ
- See Also:
- Constant Field Values
-
LONG_OBJ
public static final int LONG_OBJ
- See Also:
- Constant Field Values
-
SHORT_OBJ
public static final int SHORT_OBJ
- See Also:
- Constant Field Values
-
BIGDECIMAL
public static final int BIGDECIMAL
- See Also:
- Constant Field Values
-
BIGINTEGER
public static final int BIGINTEGER
- See Also:
- Constant Field Values
-
LOCALE
public static final int LOCALE
- See Also:
- Constant Field Values
-
PC_UNTYPED
public static final int PC_UNTYPED
- See Also:
- Constant Field Values
-
CALENDAR
public static final int CALENDAR
- See Also:
- Constant Field Values
-
OID
public static final int OID
- See Also:
- Constant Field Values
-
INPUT_STREAM
public static final int INPUT_STREAM
- See Also:
- Constant Field Values
-
INPUT_READER
public static final int INPUT_READER
- See Also:
- Constant Field Values
-
ENUM
public static final int ENUM
- See Also:
- Constant Field Values
-
LOCAL_DATE
public static final int LOCAL_DATE
- See Also:
- Constant Field Values
-
LOCAL_TIME
public static final int LOCAL_TIME
- See Also:
- Constant Field Values
-
LOCAL_DATETIME
public static final int LOCAL_DATETIME
- See Also:
- Constant Field Values
-
OFFSET_TIME
public static final int OFFSET_TIME
- See Also:
- Constant Field Values
-
OFFSET_DATETIME
public static final int OFFSET_DATETIME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getTypeCode
public static int getTypeCode(java.lang.Class<?> type)
Return the field metadata type code for the given class. First class objects are not recognized in this method.
-
classForName
public static java.lang.Class<?> classForName(java.lang.String name, ClassMetaData context)
Check the given name against the same set of standard packages used when parsing metadata.
-
classForName
public static java.lang.Class<?> classForName(java.lang.String name, ClassMetaData context, java.lang.ClassLoader loader)
Check the given name against the same set of standard packages used when parsing metadata.
-
classForName
public static java.lang.Class<?> classForName(java.lang.String name, ClassMetaData context, java.lang.ClassLoader loader, boolean mustExist)
Check the given name against the same set of standard packages used when parsing metadata.- Parameters:
mustExist
- Whether the supplied loader must be able to load the class. If true no attempt to use a different classloader will be made. If false the ClassResolver from the configuration will be used.
-
classForName
public static java.lang.Class<?> classForName(java.lang.String name, ValueMetaData context)
Check the given name against the same set of standard packages used when parsing metadata.
-
classForName
public static java.lang.Class<?> classForName(java.lang.String name, ValueMetaData context, java.lang.ClassLoader loader)
Check the given name against the same set of standard packages used when parsing metadata.
-
classForName
public static java.lang.Class<?> classForName(java.lang.String name, ValueMetaData context, java.lang.ClassLoader loader, boolean mustExist)
Try to load a class using the provided loader. Optionally tries the configuration's ClassResolver if the supplied loader cannot find the class.- Parameters:
name
- Name of the class to load.loader
- ClassLoader to use. If null, the configuration's ClassResolver will be used.mustExist
- Whether the supplied loader must be able to load the class. If true no attempt to use a different classloader will be made. If false the ClassResolver from the configuration will be used.
-
convert
public static java.lang.Object convert(java.lang.Object val, int typeCode)
Convert the given object to the given type if possible. If the type is a numeric primitive, this method only guarantees that the return value is aNumber
. If no known conversion or the value is null, returns the original value.
-
maybePC
public static boolean maybePC(FieldMetaData field)
Return true if the (possibly unresolved) field or its elements might be persistence capable objects.
-
maybePC
public static boolean maybePC(ValueMetaData val)
Return true if the (possibly unresolved) value might be a first class object.
-
toList
public static <T> java.util.List<T> toList(java.lang.Object val, java.lang.Class<T> elem, boolean mutable)
Helper method to return the given array value as a collection.
-
toArray
public static java.lang.Object toArray(java.util.Collection<?> coll, java.lang.Class<?> elem)
Helper method to return the given collection as an array.
-
isPrimitiveDefault
public static boolean isPrimitiveDefault(java.lang.Object o, int typeCode)
Determine whether or not the provided Object value is the default for the provided typeCode. For example: If o = Integer(0) and typeCode = JavaTypes.INT, this method will return true.
-
-