Class Helper
- java.lang.Object
-
- org.eclipse.persistence.jaxb.javamodel.Helper
-
public class Helper extends Object
INTERNAL:Purpose:To provide helper methods and constants to assist in integrating TopLink JAXB 2.0 Generation with the JDEV JOT APIs.
Responsibilities:
- Make available a map of JOT - XML type pairs
- Redirect method calls to the current JavaModel implementation as required
- Provide methods for accessing generics, annotations, etc. on a given implementaiton's classes
- Provide a dynamic proxy instance for a given JavaAnnotation in the JOT implementation (for reflection a Java SDK annotation is returned)
- Since:
- Oracle TopLink 11.1.1.0.0
- See Also:
JavaModel
,AnnotationProxy
-
-
Field Summary
Fields Modifier and Type Field Description static String
ABYTE
static String
APBYTE
static String
BIGDECIMAL
static String
BIGINTEGER
static String
BOOLEAN
static String
BYTE
static String
CALENDAR
static String
CHAR
static String
CHARACTER
static String
CLASS
static String
DOUBLE
static String
DURATION
static String
FLOAT
static String
GREGORIAN_CALENDAR
static String
INTEGER
static JavaClass
JAXBELEMENT_CLASS
static String
LONG
static String
OBJECT
static JavaClass
OBJECT_CLASS
static String
PBOOLEAN
static String
PBYTE
static String
PDOUBLE
static String
PFLOAT
static String
PINT
static String
PLONG
static String
PSHORT
static String
QNAME_CLASS
static String
SHORT
static String
SQL_DATE
static String
SQL_TIME
static String
SQL_TIMESTAMP
static String
STRING
static String
URI
static String
URL
static String
UTIL_DATE
static String
UUID
static String
XMLGREGORIANCALENDAR
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
classExistsInArray(JavaClass theClass, List<JavaClass> existingClasses)
Convenience method to determine if a class exists in a given ArrayList.Annotation
getAnnotation(JavaHasAnnotations element, Class annotationClass)
Returns a either a dynamic proxy instance that allows an element to be treated as an annotation (for JOT), or a Java annotation (for Reflection), or null if the specified annotation does not exist.Class
getClassForJavaClass(JavaClass javaClass)
ClassLoader
getClassLoader()
JavaClass
getGenericReturnType(JavaMethod meth)
Return a given method's generic return type as a JavaClass.JavaClass
getJavaClass(Class javaClass)
Return a JavaClass instance created based the provided class.JavaClass
getJavaClass(String javaClassName)
Return a JavaClass instance created based on fully qualified class name.JavaClass[]
getJavaClassArray(Class... classes)
Return array of JavaClass instances created based on the provided classes.static String
getQualifiedJavaTypeName(String javaTypeName, String packageName)
Prepends a package name to a given java type name, if it is not already present.JavaClass
getType(JavaField field)
Returns a JavaClass instance wrapping the provided field's resolved type.HashMap
getXMLToJavaTypeMap()
Return a map of default Java types to XML types.boolean
isAnnotationPresent(JavaHasAnnotations element, Class annotationClass)
Indicates if element contains a given annotation.boolean
isBuiltInJavaType(JavaClass jClass)
Indicates if a given JavaClass is a built-in Java type.boolean
isCollectionType(JavaClass type)
boolean
isFacets()
boolean
isMapType(JavaClass type)
void
setClassLoader(ClassLoader loader)
void
setFacets(boolean facets)
void
setJavaModel(JavaModel model)
-
-
-
Field Detail
-
APBYTE
public static final String APBYTE
- See Also:
- Constant Field Values
-
BIGDECIMAL
public static final String BIGDECIMAL
- See Also:
- Constant Field Values
-
BIGINTEGER
public static final String BIGINTEGER
- See Also:
- Constant Field Values
-
PBOOLEAN
public static final String PBOOLEAN
- See Also:
- Constant Field Values
-
PBYTE
public static final String PBYTE
- See Also:
- Constant Field Values
-
CALENDAR
public static final String CALENDAR
- See Also:
- Constant Field Values
-
CHARACTER
public static final String CHARACTER
- See Also:
- Constant Field Values
-
CHAR
public static final String CHAR
- See Also:
- Constant Field Values
-
OBJECT
public static final String OBJECT
- See Also:
- Constant Field Values
-
CLASS
public static final String CLASS
- See Also:
- Constant Field Values
-
PDOUBLE
public static final String PDOUBLE
- See Also:
- Constant Field Values
-
PFLOAT
public static final String PFLOAT
- See Also:
- Constant Field Values
-
PINT
public static final String PINT
- See Also:
- Constant Field Values
-
PLONG
public static final String PLONG
- See Also:
- Constant Field Values
-
PSHORT
public static final String PSHORT
- See Also:
- Constant Field Values
-
QNAME_CLASS
public static final String QNAME_CLASS
- See Also:
- Constant Field Values
-
STRING
public static final String STRING
- See Also:
- Constant Field Values
-
ABYTE
public static final String ABYTE
- See Also:
- Constant Field Values
-
BOOLEAN
public static final String BOOLEAN
- See Also:
- Constant Field Values
-
BYTE
public static final String BYTE
- See Also:
- Constant Field Values
-
GREGORIAN_CALENDAR
public static final String GREGORIAN_CALENDAR
- See Also:
- Constant Field Values
-
DOUBLE
public static final String DOUBLE
- See Also:
- Constant Field Values
-
FLOAT
public static final String FLOAT
- See Also:
- Constant Field Values
-
INTEGER
public static final String INTEGER
- See Also:
- Constant Field Values
-
UUID
public static final String UUID
- See Also:
- Constant Field Values
-
LONG
public static final String LONG
- See Also:
- Constant Field Values
-
SHORT
public static final String SHORT
- See Also:
- Constant Field Values
-
UTIL_DATE
public static final String UTIL_DATE
- See Also:
- Constant Field Values
-
SQL_DATE
public static final String SQL_DATE
- See Also:
- Constant Field Values
-
SQL_TIME
public static final String SQL_TIME
- See Also:
- Constant Field Values
-
SQL_TIMESTAMP
public static final String SQL_TIMESTAMP
- See Also:
- Constant Field Values
-
DURATION
public static final String DURATION
- See Also:
- Constant Field Values
-
XMLGREGORIANCALENDAR
public static final String XMLGREGORIANCALENDAR
- See Also:
- Constant Field Values
-
URI
public static final String URI
- See Also:
- Constant Field Values
-
URL
public static final String URL
- See Also:
- Constant Field Values
-
JAXBELEMENT_CLASS
public static JavaClass JAXBELEMENT_CLASS
-
OBJECT_CLASS
public static JavaClass OBJECT_CLASS
-
-
Constructor Detail
-
Helper
public Helper(JavaModel model)
INTERNAL: This is the preferred constructor. This constructor builds the map of XML-Java type pairs, and sets the JavaModel and ClassLoader.- Parameters:
model
-
-
-
Method Detail
-
getGenericReturnType
public JavaClass getGenericReturnType(JavaMethod meth)
Return a given method's generic return type as a JavaClass.- Parameters:
meth
-- Returns:
-
getJavaClass
public JavaClass getJavaClass(Class javaClass)
Return a JavaClass instance created based the provided class. This assumes that the provided class exists on the classpath - null is returned otherwise.- Parameters:
javaClass
-- Returns:
-
getJavaClassArray
public JavaClass[] getJavaClassArray(Class... classes)
Return array of JavaClass instances created based on the provided classes. This assumes provided classes exist on the classpath.- Parameters:
classes
-- Returns:
- JavaClass array
-
getJavaClass
public JavaClass getJavaClass(String javaClassName)
Return a JavaClass instance created based on fully qualified class name. This assumes that a class with the provided name exists on the classpath - null is returned otherwise.- Parameters:
javaClassName
-- Returns:
-
getXMLToJavaTypeMap
public HashMap getXMLToJavaTypeMap()
Return a map of default Java types to XML types.- Returns:
-
getAnnotation
public Annotation getAnnotation(JavaHasAnnotations element, Class annotationClass)
Returns a either a dynamic proxy instance that allows an element to be treated as an annotation (for JOT), or a Java annotation (for Reflection), or null if the specified annotation does not exist. Intended to be used in conjunction with isAnnotationPresent.- Parameters:
element
-annotationClass
-- Returns:
- See Also:
isAnnotationPresent(org.eclipse.persistence.jaxb.javamodel.JavaHasAnnotations, java.lang.Class)
-
getType
public JavaClass getType(JavaField field)
Returns a JavaClass instance wrapping the provided field's resolved type.- Parameters:
field
-- Returns:
-
isAnnotationPresent
public boolean isAnnotationPresent(JavaHasAnnotations element, Class annotationClass)
Indicates if element contains a given annotation.- Parameters:
element
-annotationClass
-- Returns:
-
isBuiltInJavaType
public boolean isBuiltInJavaType(JavaClass jClass)
Indicates if a given JavaClass is a built-in Java type. A JavaClass is considered to be a built-in type if: 1 - the XMLToJavaTypeMap map contains a key equal to the provided JavaClass' raw name 2 - the provided JavaClass' raw name starts with "java." 3 - the provided JavaClass' raw name starts with "javax.", with the exception of "javax.xml.ws."- Parameters:
jClass
-- Returns:
-
setClassLoader
public void setClassLoader(ClassLoader loader)
-
setJavaModel
public void setJavaModel(JavaModel model)
-
getClassLoader
public ClassLoader getClassLoader()
-
classExistsInArray
public boolean classExistsInArray(JavaClass theClass, List<JavaClass> existingClasses)
Convenience method to determine if a class exists in a given ArrayList.
-
getQualifiedJavaTypeName
public static String getQualifiedJavaTypeName(String javaTypeName, String packageName)
Prepends a package name to a given java type name, if it is not already present.- Parameters:
javaTypeName
- Java type name that may/may not contain 'packageName'packageName
- package name to prepend to javaTypeName if not already- Returns:
- fully qualified java type name
-
isCollectionType
public boolean isCollectionType(JavaClass type)
-
isMapType
public boolean isMapType(JavaClass type)
-
isFacets
public boolean isFacets()
-
setFacets
public void setFacets(boolean facets)
-
-