Class MappingsGenerator
java.lang.Object
org.eclipse.persistence.jaxb.compiler.MappingsGenerator
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.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
protected boolean
Compares a JavaModel JavaClass to a Class.org.eclipse.persistence.internal.oxm.mappings.AnyAttributeMapping
generateAnyAttributeMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespaceInfo) org.eclipse.persistence.internal.oxm.mappings.AnyCollectionMapping
generateAnyCollectionMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespaceInfo, boolean isMixed) org.eclipse.persistence.internal.oxm.mappings.AnyObjectMapping
generateAnyObjectMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespaceInfo) org.eclipse.persistence.internal.oxm.mappings.BinaryDataCollectionMapping
generateBinaryDataCollectionMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespaceInfo) org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping
generateBinaryMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespaceInfo) org.eclipse.persistence.internal.oxm.mappings.ChoiceCollectionMapping
generateChoiceCollectionMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespace) org.eclipse.persistence.internal.oxm.mappings.ChoiceObjectMapping
generateChoiceMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespace) org.eclipse.persistence.internal.oxm.mappings.Mapping
generateCollectionMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, JavaClass descriptorJavaClass, NamespaceInfo namespaceInfo) org.eclipse.persistence.internal.oxm.mappings.CompositeCollectionMapping
generateCompositeCollectionMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, JavaClass javaClass, NamespaceInfo namespaceInfo, String referenceClassName) org.eclipse.persistence.internal.oxm.mappings.CompositeObjectMapping
generateCompositeObjectMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespaceInfo, String referenceClassName) void
generateDescriptor
(JavaClass javaClass, CoreProject project) void
generateDescriptorForJAXBElementSubclass
(JavaClass javaClass, CoreProject project, org.eclipse.persistence.internal.oxm.NamespaceResolver nsr) org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping
generateDirectCollectionMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespaceInfo) org.eclipse.persistence.internal.oxm.mappings.DirectMapping
generateDirectEnumerationMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespaceInfo, EnumTypeInfo enumInfo) org.eclipse.persistence.internal.oxm.mappings.DirectMapping
generateDirectMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespaceInfo) org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping
generateEnumCollectionMapping
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespaceInfo, EnumTypeInfo info) 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.org.eclipse.persistence.internal.oxm.mappings.Mapping
generateMappingForReferenceProperty
(Property property, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, NamespaceInfo namespaceInfo) void
void
generateMappings
(TypeInfo info, org.eclipse.persistence.internal.oxm.mappings.Descriptor descriptor, JavaClass descriptorJavaClass, NamespaceInfo namespaceInfo) Generate mappings for a given TypeInfo.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) 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.generateWrapperClass
(String className, String attributeType, boolean isList, QName theQName) 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.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.org.eclipse.persistence.internal.jaxb.JaxbClassLoader
getPrefixForNamespace
(String URI, org.eclipse.persistence.internal.oxm.NamespaceResolver namespaceResolver) getPrefixForNamespace
(String URI, org.eclipse.persistence.internal.oxm.NamespaceResolver namespaceResolver, boolean addPrefixToNR) getSchemaTypeNameForClassName
(String className) getXmlValueFieldForSimpleContent
(ArrayList<Property> properties) org.eclipse.persistence.internal.oxm.mappings.Field
getXPathForElement
(String path, QName elementName, NamespaceInfo namespaceInfo, boolean isText) org.eclipse.persistence.internal.oxm.mappings.Field
getXPathForField
(Property property, NamespaceInfo namespaceInfo, boolean isTextMapping, boolean isAny) void
processGlobalElements
(CoreProject project)
-
Field Details
-
RESERVED_QNAME
-
-
Constructor Details
-
MappingsGenerator
-
-
Method Details
-
generateProject
public CoreProject generateProject(List<JavaClass> typeInfoClasses, Map<String, TypeInfo> typeInfo, Map<String, throws ExceptionQName> userDefinedSchemaTypes, Map<String, PackageInfo> packageToPackageInfoMappings, Map<QName, ElementDeclaration> globalElements, List<ElementDeclaration> localElements, Map<TypeMappingInfo, Class> typeMappingInfoToGeneratedClass, Map<TypeMappingInfo, Class> typeMappingInfoToAdapterClasses, boolean isDefaultNamespaceAllowed) - Throws:
Exception
-
generateDescriptor
-
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
-
areEquals
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
-
getPrefixForNamespace
-
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
-
getSchemaTypeNameForClassName
-
processGlobalElements
-
generateWrapperClass
-
getQNamesToGeneratedClasses
-
getClassToGeneratedClasses
-
getQNamesToDeclaredClasses
-
getJaxbClassLoader
public org.eclipse.persistence.internal.jaxb.JaxbClassLoader getJaxbClassLoader()
-