Class SchemaModelGenerator
- java.lang.Object
-
- org.eclipse.persistence.internal.oxm.schema.SchemaModelGenerator
-
public class SchemaModelGenerator extends Object
INTERNAL:Purpose:Generate one or more EclipseLink Schema model objects based on a given list of XMLDescriptors.
Responsibilities:
- Return a Map of generated EclipseLink Schema objects based on a given list of XMLDescriptors
This class will create and populate one or more EclipseLink schema model Schema objects for a given list of EclipseLink XMLDescriptors.
- See Also:
Schema
,XMLDescriptor
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
ID
protected static String
IDREF
protected static String
SCHEMA_FILE_EXT
protected static String
SCHEMA_FILE_NAME
protected static String
SWAREF_LOCATION
protected static String
TEXT
-
Constructor Summary
Constructors Constructor Description SchemaModelGenerator(ConversionManager conversionManager)
The default constructor.SchemaModelGenerator(ConversionManager conversionManager, boolean customSwaRefSchema)
This constructor should be used with a value of 'true' when the schemaLocation attribute of the import for swaRef should be swaref.xsd.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addNamespacesToWorkingSchema(NamespaceResolver nr, Schema workingSchema)
Adds each namespace in the given resolver to the schema.boolean
areNamespacesEqual(String ns1, String ns2)
Indicates if two namespaces are equal.protected Attribute
buildAttribute(DirectMapping mapping, String schemaType)
Build and return an Attribute for a given XMLDirectMapping.protected Attribute
buildAttribute(XPathFragment frag, String schemaType)
Build and return an Attribute for a given XPathFragment.protected ComplexType
buildComplexType(boolean anonymous, Descriptor desc, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors)
Create and return a ComplexType for a given XMLDescriptor.protected Element
buildElement(String name, String minOccurs, String maxOccurs)
Build and return an Element based on a given name, minOccurs and maxOccurs.protected Element
buildElement(Descriptor desc, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, boolean simple)
Create and return an Element for a given XMLDescriptor.protected Element
buildElement(XPathFragment frag, String schemaType, String minOccurs, String maxOccurs)
Build and return an Element for a given XPathFragment.protected Schema
buildNewSchema(String uri, NamespaceResolver nr, int schemaCount, SchemaModelGeneratorProperties properties)
Create and return a new schema for the given namespace.protected SimpleType
buildNewSimpleType(String name)
Create and return a SimpleType with name set to the given name.protected Sequence
buildSchemaComponentsForXPath(XPathFragment frag, Sequence seq, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties)
This method will build element/complexType/sequence components for a given XPath, and return the sequence that the target element of the mapping should be added to.protected SimpleType
buildSimpleType(Descriptor desc, Schema workingSchema, boolean global)
Create and return a SimpleType for a given XMLDescriptor.protected Element
elementExistsInSequence(String elementName, String refString, Sequence seq)
Convenience method for determining if an element already exists in a given sequence.Map<String,Schema>
generateSchemas(List<Descriptor> descriptorsToProcess, SchemaModelGeneratorProperties properties)
Generates a Map of EclipseLink schema model Schema objects for a given list of XMLDescriptors.Map<String,Schema>
generateSchemas(List<Descriptor> descriptorsToProcess, SchemaModelGeneratorProperties properties, Map<QName,Type> additionalGlobalElements)
Generates a Map of EclipseLink schema model Schema objects for a given list of XMLDescriptors.Map<String,Schema>
generateSchemas(List<Descriptor> descriptorsToProcess, SchemaModelGeneratorProperties properties, SchemaModelOutputResolver outputResolver)
Generates a Map of EclipseLink schema model Schema objects for a given list of XMLDescriptors.Map<String,Schema>
generateSchemas(List<Descriptor> descriptorsToProcess, SchemaModelGeneratorProperties properties, SchemaModelOutputResolver outputResolver, Map<QName,Type> additionalGlobalElements)
Generates a Map of EclipseLink schema model Schema objects for a given list of XMLDescriptors.protected QName
getDefaultRootElementAsQName(Descriptor desc, String qualifiedTableName)
Return a QName representation of a qualified table name (aka default root element).protected Descriptor
getDescriptorByClass(Class javaClass, List<Descriptor> descriptors)
Return the descriptor from the list whose java class matches javaClass.protected Descriptor
getDescriptorByName(String javaClassName, List<Descriptor> descriptors)
Return the descriptor from the list whose java class name matches javaClassName.protected Schema
getSchema(String uri, NamespaceResolver nr, HashMap<String,Schema> schemaForNamespace, SchemaModelGeneratorProperties properties)
Return the Schema for a given namespace.protected String
getSchemaTypeForDirectMapping(DirectMapping mapping, Schema workingSchema)
Return the schema type for a given mapping's xmlfield.protected String
getSchemaTypeForElement(Field xmlField, Class attrClass, Schema workingSchema)
Return the schema type for a given xmlfield.protected String
getSchemaTypeString(QName schemaType, Schema workingSchema)
Return the schema type as a string for a given QName and Schema.protected XPathFragment
getTargetXPathFragment(XPathFragment frag)
Return the last fragment before text() in the XPath that a given XPathFragment is part of.protected Element
handleFragNamespace(XPathFragment frag, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, Element element, String schemaTypeString)
This method will generate a global element if required (based in URI and elementFormDefault) and set a reference to it on a given element accordingly.protected Element
handleFragNamespace(XPathFragment frag, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, Element element, ComplexType ctype, Descriptor refDesc)
This method will generate a global element if required (based in URI and elementFormDefault) and set a reference to it on a given element accordingly, or set an anonymous complex type on a given element.protected boolean
importExists(Schema schema, String schemaName)
Determines if a given schema contains an import for a given schema name.protected boolean
isComplexTypeWithSimpleContentRequired(Descriptor desc)
Indicates if a complex type with simple content is to be generated.protected boolean
isFragPrimaryKey(XPathFragment frag, DirectMapping mapping)
Indicates if a given fragment is a primary key.protected boolean
isSimple(Descriptor desc)
Determines if a given descriptor contains a direct mapping to "text()" indicating a simple mapping.protected void
processAnyMapping(Sequence seq, boolean isCollection)
Adds an Any to a given sequence.protected void
processChoiceMapping(Map<Field,Class> fieldToClassMap, List<XMLChoiceFieldToClassAssociation> choiceFieldToClassList, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, boolean isCollection)
Process a given XMLChoiceMapping.protected void
processDescriptor(Descriptor desc, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors)
Process a given descriptor.protected void
processEnumeration(String schemaTypeString, XPathFragment frag, DirectMapping mapping, Sequence seq, ComplexType ct, Schema workingSchema, CoreConverter converter)
Process information contained within an EnumTypeConverter.protected void
processMapping(CoreMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors)
Process a given mapping.protected Element
processReferenceDescriptor(Element element, Descriptor refDesc, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, Field field, boolean isCollection)
protected void
processXMLBinaryDataCollectionMapping(BinaryDataCollectionMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties)
Process a given XMLBinaryDataCollectionMapping.protected void
processXMLBinaryDataMapping(BinaryDataMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties)
Process a given XMLBinaryDataMapping.protected void
processXMLChoiceCollectionMapping(ChoiceCollectionMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors)
Process a given XMLChoiceCollectionMapping.protected void
processXMLChoiceObjectMapping(ChoiceObjectMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors)
protected void
processXMLCompositeDirectCollectionMapping(DirectCollectionMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties)
Process a given XMLCompositeDirectCollectionMapping.protected void
processXMLCompositeMapping(CompositeObjectMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, boolean collection)
Process a given XML composite mapping - either an XMLCompositeObjectMapping, or an XMLCompositeCollectionMapping.protected void
processXMLDirectMapping(DirectMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties)
Process a given XMLDirectMapping.protected void
processXMLObjectReferenceMapping(ObjectReferenceMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, boolean isCollection)
Process a given XMLObjectReferenceMapping.
-
-
-
Field Detail
-
SCHEMA_FILE_NAME
protected static final String SCHEMA_FILE_NAME
- See Also:
- Constant Field Values
-
SCHEMA_FILE_EXT
protected static final String SCHEMA_FILE_EXT
- See Also:
- Constant Field Values
-
TEXT
protected static final String TEXT
- See Also:
- Constant Field Values
-
ID
protected static final String ID
- See Also:
- Constant Field Values
-
IDREF
protected static final String IDREF
- See Also:
- Constant Field Values
-
SWAREF_LOCATION
protected static String SWAREF_LOCATION
-
-
Constructor Detail
-
SchemaModelGenerator
public SchemaModelGenerator(ConversionManager conversionManager)
The default constructor.
-
SchemaModelGenerator
public SchemaModelGenerator(ConversionManager conversionManager, boolean customSwaRefSchema)
This constructor should be used with a value of 'true' when the schemaLocation attribute of the import for swaRef should be swaref.xsd. This is useful when the user has a local copy of the swaRef schema and wants to use it when access to external URLs is not available. The default value is: "http://ws-i.org/profiles/basic/1.1/swaref.xsd".
-
-
Method Detail
-
generateSchemas
public Map<String,Schema> generateSchemas(List<Descriptor> descriptorsToProcess, SchemaModelGeneratorProperties properties, Map<QName,Type> additionalGlobalElements) throws DescriptorException
Generates a Map of EclipseLink schema model Schema objects for a given list of XMLDescriptors. The descriptors are assumed to have been initialized. One Schema object will be generated per namespace.- Parameters:
descriptorsToProcess
- list of XMLDescriptors which will be used to generate Schema objectsproperties
- holds a namespace to Properties map containing schema settings, such as elementFormDefaultadditionalGlobalElements
- a map of QName-Type entries identifying additional global elements to be added- Returns:
- a map of namespaces to EclipseLink schema model Schema objects
- Throws:
DescriptorException
- if the reference descriptor for a composite mapping is not in the list of descriptors- See Also:
Schema
-
generateSchemas
public Map<String,Schema> generateSchemas(List<Descriptor> descriptorsToProcess, SchemaModelGeneratorProperties properties) throws DescriptorException
Generates a Map of EclipseLink schema model Schema objects for a given list of XMLDescriptors. The descriptors are assumed to have been initialized. One Schema object will be generated per namespace.- Parameters:
descriptorsToProcess
- list of XMLDescriptors which will be used to generate Schema objectsproperties
- holds a namespace to Properties map containing schema settings, such as elementFormDefault- Returns:
- a map of namespaces to EclipseLink schema model Schema objects
- Throws:
DescriptorException
- if the reference descriptor for a composite mapping is not in the list of descriptors- See Also:
Schema
-
generateSchemas
public Map<String,Schema> generateSchemas(List<Descriptor> descriptorsToProcess, SchemaModelGeneratorProperties properties, SchemaModelOutputResolver outputResolver, Map<QName,Type> additionalGlobalElements) throws DescriptorException
Generates a Map of EclipseLink schema model Schema objects for a given list of XMLDescriptors. The descriptors are assumed to have been initialized. One Schema object will be generated per namespace.- Parameters:
descriptorsToProcess
- list of XMLDescriptors which will be used to generate Schema objectsproperties
- holds a namespace to Properties map containing schema settings, such as elementFormDefaultadditionalGlobalElements
- a map of QName-Type entries identifying additional global elements to be added- Returns:
- a map of namespaces to EclipseLink schema model Schema objects
- Throws:
DescriptorException
- if the reference descriptor for a composite mapping is not in the list of descriptors- See Also:
Schema
-
generateSchemas
public Map<String,Schema> generateSchemas(List<Descriptor> descriptorsToProcess, SchemaModelGeneratorProperties properties, SchemaModelOutputResolver outputResolver) throws DescriptorException
Generates a Map of EclipseLink schema model Schema objects for a given list of XMLDescriptors. The descriptors are assumed to have been initialized. One Schema object will be generated per namespace.- Parameters:
descriptorsToProcess
- list of XMLDescriptors which will be used to generate Schema objectsproperties
- holds a namespace to Properties map containing schema settings, such as elementFormDefault- Returns:
- a map of namespaces to EclipseLink schema model Schema objects
- Throws:
DescriptorException
- if the reference descriptor for a composite mapping is not in the list of descriptors- See Also:
Schema
-
processDescriptor
protected void processDescriptor(Descriptor desc, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors)
Process a given descriptor. Global complex types will be generated for based on schema context, and global elements based on default root element.- Parameters:
desc
-schemaForNamespace
-workingSchema
-properties
-descriptors
-
-
getSchema
protected Schema getSchema(String uri, NamespaceResolver nr, HashMap<String,Schema> schemaForNamespace, SchemaModelGeneratorProperties properties)
Return the Schema for a given namespace. If one doesn't exist, a new one will be created and returned.- Parameters:
uri
-nr
-schemaForNamespace
-properties
-- Returns:
- See Also:
Schema
-
buildElement
protected Element buildElement(Descriptor desc, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, boolean simple)
Create and return an Element for a given XMLDescriptor.- Parameters:
desc
-schemaForNamespace
-workingSchema
-properties
-descriptors
-simple
-- Returns:
-
buildSimpleType
protected SimpleType buildSimpleType(Descriptor desc, Schema workingSchema, boolean global)
Create and return a SimpleType for a given XMLDescriptor.- Parameters:
desc
-workingSchema
-- Returns:
-
buildNewSimpleType
protected SimpleType buildNewSimpleType(String name)
Create and return a SimpleType with name set to the given name.- Parameters:
name
-- Returns:
-
buildComplexType
protected ComplexType buildComplexType(boolean anonymous, Descriptor desc, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors)
Create and return a ComplexType for a given XMLDescriptor. Assumes that the descriptor has a schema context set.- Parameters:
anonymous
-desc
-schemaForNamespace
-workingSchema
-properties
-descriptors
-- Returns:
-
getSchemaTypeForDirectMapping
protected String getSchemaTypeForDirectMapping(DirectMapping mapping, Schema workingSchema)
Return the schema type for a given mapping's xmlfield. If the field does not have a schema type set, the attribute classification will be used if non-null. Otherwise, ClassConstants.STRING will be returned.- Parameters:
mapping
-workingSchema
-- Returns:
-
getSchemaTypeForElement
protected String getSchemaTypeForElement(Field xmlField, Class attrClass, Schema workingSchema)
Return the schema type for a given xmlfield. If the field does not have a schema type set, the attribute classification will be used if non-null. Otherwise, ClassConstants.STRING will be returned.- Parameters:
xmlField
-attrClass
-workingSchema
-- Returns:
-
getDescriptorByName
protected Descriptor getDescriptorByName(String javaClassName, List<Descriptor> descriptors)
Return the descriptor from the list whose java class name matches javaClassName. If none exists null will be returned.- Parameters:
javaClassName
-descriptors
-- Returns:
-
getDescriptorByClass
protected Descriptor getDescriptorByClass(Class javaClass, List<Descriptor> descriptors)
Return the descriptor from the list whose java class matches javaClass. If none exists null will be returned.- Parameters:
javaClass
-descriptors
-- Returns:
-
processAnyMapping
protected void processAnyMapping(Sequence seq, boolean isCollection)
Adds an Any to a given sequence. If isCollection is true, maxOccurs will be set to unbounded.- Parameters:
seq
-isCollection
-- See Also:
Any
,Occurs.UNBOUNDED
-
processXMLBinaryDataMapping
protected void processXMLBinaryDataMapping(BinaryDataMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties)
Process a given XMLBinaryDataMapping.- Parameters:
mapping
-seq
-ct
-workingSchema
-
-
processXMLBinaryDataCollectionMapping
protected void processXMLBinaryDataCollectionMapping(BinaryDataCollectionMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties)
Process a given XMLBinaryDataCollectionMapping.- Parameters:
mapping
-seq
-ct
-workingSchema
-
-
processXMLDirectMapping
protected void processXMLDirectMapping(DirectMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties)
Process a given XMLDirectMapping.- Parameters:
mapping
-seq
-ct
-workingSchema
-
-
processXMLCompositeDirectCollectionMapping
protected void processXMLCompositeDirectCollectionMapping(DirectCollectionMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties)
Process a given XMLCompositeDirectCollectionMapping.- Parameters:
mapping
-seq
-ct
-workingSchema
-
-
processXMLCompositeMapping
protected void processXMLCompositeMapping(CompositeObjectMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, boolean collection)
Process a given XML composite mapping - either an XMLCompositeObjectMapping, or an XMLCompositeCollectionMapping. For XMLCompositeDirectCollectionMappings the processXMLCompositeDirectCollectionMapping method should be used.- Parameters:
mapping
-seq
-ct
-schemaForNamespace
-workingSchema
-properties
-descriptors
-collection
-
-
processXMLChoiceCollectionMapping
protected void processXMLChoiceCollectionMapping(ChoiceCollectionMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors)
Process a given XMLChoiceCollectionMapping.- Parameters:
mapping
-seq
-ct
-schemaForNamespace
-workingSchema
-properties
-descriptors
-
-
processXMLChoiceObjectMapping
protected void processXMLChoiceObjectMapping(ChoiceObjectMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors)
- Parameters:
mapping
-seq
-ct
-schemaForNamespace
-workingSchema
-properties
-descriptors
-
-
processChoiceMapping
protected void processChoiceMapping(Map<Field,Class> fieldToClassMap, List<XMLChoiceFieldToClassAssociation> choiceFieldToClassList, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, boolean isCollection)
Process a given XMLChoiceMapping.- Parameters:
fieldToClassMap
-choiceFieldToClassList
-seq
-ct
-schemaForNamespace
-workingSchema
-properties
-descriptors
-isCollection
-
-
processXMLObjectReferenceMapping
protected void processXMLObjectReferenceMapping(ObjectReferenceMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, boolean isCollection)
Process a given XMLObjectReferenceMapping. In the case of an XMLCollectionReferenceMapping, i.e. the isCollection flag is set to true, maxOccurs will be set to 'unbounded' on any source elements- Parameters:
mapping
-seq
-ct
-schemaForNamespace
-workingSchema
-properties
-descriptors
-isCollection
-
-
processMapping
protected void processMapping(CoreMapping mapping, Sequence seq, ComplexType ct, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors)
Process a given mapping.- Parameters:
mapping
-seq
-ct
-schemaForNamespace
-workingSchema
-properties
-descriptors
-
-
handleFragNamespace
protected Element handleFragNamespace(XPathFragment frag, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, Element element, String schemaTypeString)
This method will generate a global element if required (based in URI and elementFormDefault) and set a reference to it on a given element accordingly. This method will typically be used for direct mappings.- Parameters:
frag
-schemaForNamespace
-workingSchema
-properties
-element
-schemaTypeString
-- Returns:
-
handleFragNamespace
protected Element handleFragNamespace(XPathFragment frag, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, Element element, ComplexType ctype, Descriptor refDesc)
This method will generate a global element if required (based in URI and elementFormDefault) and set a reference to it on a given element accordingly, or set an anonymous complex type on a given element. This method will typically be used by composite mappings.- Parameters:
frag
-schemaForNamespace
-workingSchema
-properties
-element
-ctype
-refDesc
-
-
getTargetXPathFragment
protected XPathFragment getTargetXPathFragment(XPathFragment frag)
Return the last fragment before text() in the XPath that a given XPathFragment is part of.- Parameters:
frag
-- Returns:
-
buildSchemaComponentsForXPath
protected Sequence buildSchemaComponentsForXPath(XPathFragment frag, Sequence seq, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties)
This method will build element/complexType/sequence components for a given XPath, and return the sequence that the target element of the mapping should be added to. For example, if the XPath was "contact-info/address/street/text()", street would be the target. This method defers processing of the target path element to the calling method, allowing for differences in handling, such as direct mappings versus composite mappings, etc.- Parameters:
frag
-seq
-- Returns:
-
buildAttribute
protected Attribute buildAttribute(DirectMapping mapping, String schemaType)
Build and return an Attribute for a given XMLDirectMapping.- Parameters:
mapping
-schemaType
-- Returns:
-
buildAttribute
protected Attribute buildAttribute(XPathFragment frag, String schemaType)
Build and return an Attribute for a given XPathFragment.- Parameters:
frag
-schemaType
-- Returns:
-
buildElement
protected Element buildElement(XPathFragment frag, String schemaType, String minOccurs, String maxOccurs)
Build and return an Element for a given XPathFragment.- Parameters:
frag
-schemaType
-minOccurs
-maxOccurs
-- Returns:
-
buildElement
protected Element buildElement(String name, String minOccurs, String maxOccurs)
Build and return an Element based on a given name, minOccurs and maxOccurs.- Parameters:
name
-minOccurs
-maxOccurs
-- Returns:
-
areNamespacesEqual
public boolean areNamespacesEqual(String ns1, String ns2)
Indicates if two namespaces are equal. The result is TRUE if the two URI strings are equal according to the equals() method, if one is null and the other is "", or both are null.- Parameters:
ns1
-ns2
-- Returns:
-
getSchemaTypeString
protected String getSchemaTypeString(QName schemaType, Schema workingSchema)
Return the schema type as a string for a given QName and Schema. The schema's namespace resolver will be used to determine the prefix (if any) to use.- Parameters:
schemaType
-workingSchema
-- Returns:
-
addNamespacesToWorkingSchema
protected void addNamespacesToWorkingSchema(NamespaceResolver nr, Schema workingSchema)
Adds each namespace in the given resolver to the schema.- Parameters:
nr
-workingSchema
-
-
buildNewSchema
protected Schema buildNewSchema(String uri, NamespaceResolver nr, int schemaCount, SchemaModelGeneratorProperties properties)
Create and return a new schema for the given namespace. ElementFormDefault and AttributeFormDefault can be set via SchemaModelGeneratorProperties object. The namespace resolver's default namespace will be set if non-null.- Parameters:
uri
-nr
-schemaCount
-properties
-- Returns:
-
importExists
protected boolean importExists(Schema schema, String schemaName)
Determines if a given schema contains an import for a given schema name.- Parameters:
schema
-schemaName
-- Returns:
-
getDefaultRootElementAsQName
protected QName getDefaultRootElementAsQName(Descriptor desc, String qualifiedTableName)
Return a QName representation of a qualified table name (aka default root element). The given descriptor's namespace resolver will be used to determine the correct prefix - if any - to be used.- Parameters:
desc
-qualifiedTableName
-- Returns:
-
processReferenceDescriptor
protected Element processReferenceDescriptor(Element element, Descriptor refDesc, HashMap<String,Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, Field field, boolean isCollection)
- Parameters:
element
-refDesc
-schemaForNamespace
-workingSchema
-properties
-descriptors
-field
-isCollection
-- Returns:
-
elementExistsInSequence
protected Element elementExistsInSequence(String elementName, String refString, Sequence seq)
Convenience method for determining if an element already exists in a given sequence. If an element exists whose name is equal to 'elementName' true is returned. False otherwise.- Parameters:
elementName
-seq
-- Returns:
-
isSimple
protected boolean isSimple(Descriptor desc)
Determines if a given descriptor contains a direct mapping to "text()" indicating a simple mapping. In this case, a simple type or complex type with simple content will be generated- Parameters:
desc
-- Returns:
-
isComplexTypeWithSimpleContentRequired
protected boolean isComplexTypeWithSimpleContentRequired(Descriptor desc)
Indicates if a complex type with simple content is to be generated. This is true when the given descriptor has more than one mapping. It is assumed that isSimple(desc) will return true for the given descriptor, and that the descriptor will contain at most one direct with a 'text()' xpath, and any additional mappings are attribute mappings.- Parameters:
desc
-- Returns:
-
processEnumeration
protected void processEnumeration(String schemaTypeString, XPathFragment frag, DirectMapping mapping, Sequence seq, ComplexType ct, Schema workingSchema, CoreConverter converter)
Process information contained within an EnumTypeConverter. This will generate a simple type containing enumeration info.- Parameters:
schemaTypeString
-frag
-mapping
-seq
-ct
-workingSchema
-converter
-
-
isFragPrimaryKey
protected boolean isFragPrimaryKey(XPathFragment frag, DirectMapping mapping)
Indicates if a given fragment is a primary key.- Parameters:
frag
-mapping
-- Returns:
-
-