Class Helper


  • public class Helper
    extends java.lang.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)
    See Also:
    JavaModel, AnnotationProxy
    Since:
    Oracle TopLink 11.1.1.0.0
    • 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​(java.lang.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​(java.lang.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​(java.lang.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 java.util.HashMap getXMLToJavaTypeMap()
        Return a map of default Java types to XML types.
        Returns:
      • getType

        public JavaClass getType​(JavaField field)
        Returns a JavaClass instance wrapping the provided field's resolved type.
        Parameters:
        field -
        Returns:
      • getJaxbElementClass

        public JavaClass getJaxbElementClass()
        Return a JavaClass instance based on the @see javax.xml.bind.JAXBElement . Replacement of direct access to JAXBELEMENT_CLASS field.
        Returns:
      • getObjectClass

        public JavaClass getObjectClass()
        Return a JavaClass instance based on the @see java.lang.Object . Replacement of direct access to OBJECT_CLASS field.
        Returns:
      • isAnnotationPresent

        public boolean isAnnotationPresent​(JavaHasAnnotations element,
                                           java.lang.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." and "javax.xml.rpc"
        Parameters:
        jClass -
        Returns:
      • setClassLoader

        public void setClassLoader​(java.lang.ClassLoader loader)
      • setJavaModel

        public void setJavaModel​(JavaModel model)
      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
      • getClassForJavaClass

        public java.lang.Class getClassForJavaClass​(JavaClass javaClass)
      • classExistsInArray

        public boolean classExistsInArray​(JavaClass theClass,
                                          java.util.List<JavaClass> existingClasses)
        Convenience method to determine if a class exists in a given ArrayList.
      • getQualifiedJavaTypeName

        public static java.lang.String getQualifiedJavaTypeName​(java.lang.String javaTypeName,
                                                                java.lang.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)