Class MappingsGenerator


  • public class MappingsGenerator
    extends java.lang.Object
    INTERNAL:

    Purpose:To generate a TopLink OXM Project based on Java Class and TypeInfo information

    Responsibilities:

    • Generate a XMLDescriptor for each TypeInfo object
    • Generate a mapping for each TypeProperty object
    • Determine the correct mapping type based on the type of each property
    • Set up Converters on mappings for XmlAdapters or JDK 1.5 Enumeration types.

    This class is invoked by a Generator in order to create a TopLink Project. This is generally used by JAXBContextFactory to create the runtime project. A Descriptor will be generated for each TypeInfo and Mappings generated for each Property. In the case that a non-transient property's type is a user defined class, a Descriptor and Mappings will be generated for that class as well.

    See Also:
    Generator, TypeInfo, Property
    Author:
    mmacivor
    Since:
    Oracle TopLink 11.1.1.0.0
    • Field Detail

      • RESERVED_QNAME

        public static final javax.xml.namespace.QName RESERVED_QNAME
    • Constructor Detail

      • MappingsGenerator

        public MappingsGenerator​(Helper helper)
    • Method Detail

      • generateProject

        public CoreProject generateProject​(java.util.List<JavaClass> typeInfoClasses,
                                           java.util.Map<java.lang.String,​TypeInfo> typeInfo,
                                           java.util.Map<java.lang.String,​javax.xml.namespace.QName> userDefinedSchemaTypes,
                                           java.util.Map<java.lang.String,​PackageInfo> packageToPackageInfoMappings,
                                           java.util.Map<javax.xml.namespace.QName,​ElementDeclaration> globalElements,
                                           java.util.List<ElementDeclaration> localElements,
                                           java.util.Map<TypeMappingInfo,​java.lang.Class> typeMappingInfoToGeneratedClass,
                                           java.util.Map<TypeMappingInfo,​java.lang.Class> typeMappingInfoToAdapterClasses,
                                           boolean isDefaultNamespaceAllowed)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • generateDescriptor

        public void generateDescriptor​(JavaClass javaClass,
                                       CoreProject project)
      • generateDescriptorForJAXBElementSubclass

        public void generateDescriptorForJAXBElementSubclass​(JavaClass javaClass,
                                                             CoreProject project,
                                                             org.eclipse.persistence.internal.oxm.NamespaceResolver nsr)
      • generateMapping

        public org.eclipse.persistence.internal.oxm.mappings.Mapping generateMapping​(Property property,
                                                                                     org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                     JavaClass descriptorJavaClass,
                                                                                     NamespaceInfo namespaceInfo)
        Generate a mapping for a given Property.
        Parameters:
        property -
        descriptor -
        namespaceInfo -
        Returns:
        newly created mapping
      • generateTransformationMapping

        public org.eclipse.persistence.internal.oxm.mappings.TransformationMapping generateTransformationMapping​(Property property,
                                                                                                                 org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                                 NamespaceInfo namespace)
        Generate an XMLTransformationMapping based on a given Property.
        Parameters:
        property -
        descriptor -
        namespace -
        Returns:
      • generateChoiceMapping

        public org.eclipse.persistence.internal.oxm.mappings.ChoiceObjectMapping generateChoiceMapping​(Property property,
                                                                                                       org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                       NamespaceInfo namespace)
      • generateChoiceCollectionMapping

        public org.eclipse.persistence.internal.oxm.mappings.ChoiceCollectionMapping generateChoiceCollectionMapping​(Property property,
                                                                                                                     org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                                     NamespaceInfo namespace)
      • generateMappingForReferenceProperty

        public org.eclipse.persistence.internal.oxm.mappings.Mapping generateMappingForReferenceProperty​(Property property,
                                                                                                         org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                         NamespaceInfo namespaceInfo)
      • generateAnyCollectionMapping

        public org.eclipse.persistence.internal.oxm.mappings.AnyCollectionMapping generateAnyCollectionMapping​(Property property,
                                                                                                               org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                               NamespaceInfo namespaceInfo,
                                                                                                               boolean isMixed)
      • generateCompositeObjectMapping

        public org.eclipse.persistence.internal.oxm.mappings.CompositeObjectMapping generateCompositeObjectMapping​(Property property,
                                                                                                                   org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                                   NamespaceInfo namespaceInfo,
                                                                                                                   java.lang.String referenceClassName)
      • generateDirectMapping

        public org.eclipse.persistence.internal.oxm.mappings.DirectMapping generateDirectMapping​(Property property,
                                                                                                 org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                 NamespaceInfo namespaceInfo)
      • generateBinaryMapping

        public org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping generateBinaryMapping​(Property property,
                                                                                                     org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                     NamespaceInfo namespaceInfo)
      • generateBinaryDataCollectionMapping

        public org.eclipse.persistence.internal.oxm.mappings.BinaryDataCollectionMapping generateBinaryDataCollectionMapping​(Property property,
                                                                                                                             org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                                             NamespaceInfo namespaceInfo)
      • generateDirectEnumerationMapping

        public org.eclipse.persistence.internal.oxm.mappings.DirectMapping generateDirectEnumerationMapping​(Property property,
                                                                                                            org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                            NamespaceInfo namespaceInfo,
                                                                                                            EnumTypeInfo enumInfo)
      • generateCollectionMapping

        public org.eclipse.persistence.internal.oxm.mappings.Mapping generateCollectionMapping​(Property property,
                                                                                               org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                               JavaClass descriptorJavaClass,
                                                                                               NamespaceInfo namespaceInfo)
      • generateEnumCollectionMapping

        public org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping generateEnumCollectionMapping​(Property property,
                                                                                                                   org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                                   NamespaceInfo namespaceInfo,
                                                                                                                   EnumTypeInfo info)
      • generateAnyAttributeMapping

        public org.eclipse.persistence.internal.oxm.mappings.AnyAttributeMapping generateAnyAttributeMapping​(Property property,
                                                                                                             org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                             NamespaceInfo namespaceInfo)
      • generateAnyObjectMapping

        public org.eclipse.persistence.internal.oxm.mappings.AnyObjectMapping generateAnyObjectMapping​(Property property,
                                                                                                       org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                       NamespaceInfo namespaceInfo)
      • areEquals

        protected boolean areEquals​(JavaClass src,
                                    java.lang.Class tgt)
      • areEquals

        protected boolean areEquals​(JavaClass src,
                                    java.lang.String tgtCanonicalName)
        Compares a JavaModel JavaClass to a Class. Equality is based on the raw name of the JavaClass compared to the canonical name of the Class.
        Parameters:
        src -
        tgtCanonicalName -
        Returns:
      • generateCompositeCollectionMapping

        public org.eclipse.persistence.internal.oxm.mappings.CompositeCollectionMapping generateCompositeCollectionMapping​(Property property,
                                                                                                                           org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                                           JavaClass javaClass,
                                                                                                                           NamespaceInfo namespaceInfo,
                                                                                                                           java.lang.String referenceClassName)
      • generateDirectCollectionMapping

        public org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping generateDirectCollectionMapping​(Property property,
                                                                                                                     org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                                     NamespaceInfo namespaceInfo)
      • getPrefixForNamespace

        public java.lang.String getPrefixForNamespace​(java.lang.String URI,
                                                      org.eclipse.persistence.internal.oxm.NamespaceResolver namespaceResolver)
      • getPrefixForNamespace

        public java.lang.String getPrefixForNamespace​(java.lang.String URI,
                                                      org.eclipse.persistence.internal.oxm.NamespaceResolver namespaceResolver,
                                                      boolean addPrefixToNR)
      • generateMappings

        public void generateMappings()
      • generateMappings

        public void generateMappings​(TypeInfo info,
                                     org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                     JavaClass descriptorJavaClass,
                                     NamespaceInfo namespaceInfo)
        Generate mappings for a given TypeInfo.
        Parameters:
        info -
        descriptor -
        namespaceInfo -
      • generateXMLCollectionReferenceMapping

        public org.eclipse.persistence.internal.oxm.mappings.CollectionReferenceMapping generateXMLCollectionReferenceMapping​(Property property,
                                                                                                                              org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                                              NamespaceInfo namespaceInfo,
                                                                                                                              JavaClass referenceClass)
        Create an XMLCollectionReferenceMapping and add it to the descriptor.
        Parameters:
        property -
        descriptor -
        namespaceInfo -
        referenceClass -
      • generateXMLObjectReferenceMapping

        public org.eclipse.persistence.internal.oxm.mappings.ObjectReferenceMapping generateXMLObjectReferenceMapping​(Property property,
                                                                                                                      org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor,
                                                                                                                      NamespaceInfo namespaceInfo,
                                                                                                                      JavaClass referenceClass)
        Create an XMLObjectReferenceMapping and add it to the descriptor.
        Parameters:
        property -
        descriptor -
        namespaceInfo -
        referenceClass -
      • getXPathForField

        public org.eclipse.persistence.internal.oxm.mappings.Field getXPathForField​(Property property,
                                                                                    NamespaceInfo namespaceInfo,
                                                                                    boolean isTextMapping,
                                                                                    boolean isAny)
      • getXPathForElement

        public org.eclipse.persistence.internal.oxm.mappings.Field getXPathForElement​(java.lang.String path,
                                                                                      javax.xml.namespace.QName elementName,
                                                                                      NamespaceInfo namespaceInfo,
                                                                                      boolean isText)
      • getXmlValueFieldForSimpleContent

        public Property getXmlValueFieldForSimpleContent​(java.util.ArrayList<Property> properties)
      • getSchemaTypeNameForClassName

        public java.lang.String getSchemaTypeNameForClassName​(java.lang.String className)
      • processGlobalElements

        public void processGlobalElements​(CoreProject project)
      • generateWrapperClass

        public java.lang.Class generateWrapperClass​(java.lang.String className,
                                                    java.lang.String attributeType,
                                                    boolean isList,
                                                    javax.xml.namespace.QName theQName)
      • getQNamesToGeneratedClasses

        public java.util.Map<javax.xml.namespace.QName,​java.lang.Class> getQNamesToGeneratedClasses()
      • getClassToGeneratedClasses

        public java.util.Map<java.lang.String,​java.lang.Class> getClassToGeneratedClasses()
      • getQNamesToDeclaredClasses

        public java.util.Map<javax.xml.namespace.QName,​java.lang.Class> getQNamesToDeclaredClasses()
      • getJaxbClassLoader

        public org.eclipse.persistence.internal.jaxb.JaxbClassLoader getJaxbClassLoader()