Class MappingsGenerator

java.lang.Object
org.eclipse.persistence.jaxb.compiler.MappingsGenerator

public class MappingsGenerator extends 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:
Author:
mmacivor
  • Field Details

    • RESERVED_QNAME

      public static final QName RESERVED_QNAME
  • Constructor Details

    • MappingsGenerator

      public MappingsGenerator(Helper helper)
  • Method Details

    • generateProject

      public CoreProject generateProject(List<JavaClass> typeInfoClasses, Map<String,TypeInfo> typeInfo, Map<String,QName> userDefinedSchemaTypes, Map<String,PackageInfo> packageToPackageInfoMappings, Map<QName,ElementDeclaration> globalElements, List<ElementDeclaration> localElements, Map<TypeMappingInfo,Class> typeMappingInfoToGeneratedClass, Map<TypeMappingInfo,Class> typeMappingInfoToAdapterClasses, boolean isDefaultNamespaceAllowed) throws Exception
      Throws:
      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, 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, Class tgt)
    • areEquals

      protected boolean areEquals(JavaClass src, 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, 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 String getPrefixForNamespace(String URI, org.eclipse.persistence.internal.oxm.NamespaceResolver namespaceResolver)
    • getPrefixForNamespace

      public String getPrefixForNamespace(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(String path, QName elementName, NamespaceInfo namespaceInfo, boolean isText)
    • getXmlValueFieldForSimpleContent

      public Property getXmlValueFieldForSimpleContent(ArrayList<Property> properties)
    • getSchemaTypeNameForClassName

      public String getSchemaTypeNameForClassName(String className)
    • processGlobalElements

      public void processGlobalElements(CoreProject project)
    • generateWrapperClass

      public Class generateWrapperClass(String className, String attributeType, boolean isList, QName theQName)
    • getQNamesToGeneratedClasses

      public Map<QName,Class> getQNamesToGeneratedClasses()
    • getClassToGeneratedClasses

      public Map<String,Class> getClassToGeneratedClasses()
    • getQNamesToDeclaredClasses

      public Map<QName,Class> getQNamesToDeclaredClasses()
    • getJaxbClassLoader

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