public class SchemaGenerator
extends java.lang.Object
Purpose:To generate Schema objects based on a map of TypeInfo objects, and some additional information gathered by the AnnotationsProcessing phase.
Responsibilities:
This class is used by the Generator to handle the generation of Schemas. The Generator passes in a map of TypeInfo objects, generated by the Annotations processor. The generated Schemas are stored in a map of keyed on Target Namespace.
TypeInfo
,
AnnotationsProcessor
,
Generator
Constructor and Description |
---|
SchemaGenerator(Helper helper) |
Modifier and Type | Method and Description |
---|---|
void |
addGlobalElements(java.util.Map<javax.xml.namespace.QName,ElementDeclaration> additionalElements) |
void |
addSchemaComponents(JavaClass myClass) |
void |
addToSchemaType(TypeInfo ownerTypeInfo,
java.util.List<Property> properties,
org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle compositor,
org.eclipse.persistence.internal.oxm.schema.model.ComplexType type,
org.eclipse.persistence.internal.oxm.schema.model.Schema workingSchema) |
protected boolean |
areEquals(JavaClass src,
java.lang.Class tgt)
Compares a JavaModel JavaClass to a Class.
|
protected boolean |
areEquals(JavaClass src,
java.lang.String tgtCanonicalName)
Compares a JavaModel JavaClass to a Class.
|
protected org.eclipse.persistence.jaxb.compiler.SchemaGenerator.AddToSchemaResult |
buildSchemaComponentsForXPath(org.eclipse.persistence.internal.oxm.XPathFragment frag,
org.eclipse.persistence.jaxb.compiler.SchemaGenerator.AddToSchemaResult xpr,
boolean isChoice,
Property next)
This method will build element/complexType/typedefparticle components for a given xml-path,
and return an XmlPathResult instance containg the sequence that the target should be added
to, as well as the current schema - which could be different than the working schema used
before calling this method in the case of a prefixed path element from a different namespace.
|
org.eclipse.persistence.internal.oxm.schema.model.Attribute |
createGlobalAttribute(org.eclipse.persistence.internal.oxm.XPathFragment frag,
org.eclipse.persistence.internal.oxm.schema.model.Schema workingSchema,
org.eclipse.persistence.internal.oxm.schema.model.Schema fragSchema,
Property prop)
Create a global attribute.
|
org.eclipse.persistence.internal.oxm.schema.model.Element |
createGlobalElement(org.eclipse.persistence.internal.oxm.XPathFragment frag,
org.eclipse.persistence.internal.oxm.schema.model.Schema workingSchema,
org.eclipse.persistence.internal.oxm.schema.model.Schema fragSchema,
boolean isChoice,
boolean isUnbounded,
Property prop,
boolean shouldSetType)
Create a global element.
|
org.eclipse.persistence.internal.oxm.schema.model.Attribute |
createRefAttribute(java.lang.String attributeRefName,
org.eclipse.persistence.internal.oxm.schema.model.ComplexType owningComplexType)
Create an attribute reference and add it to a given complex type.
|
org.eclipse.persistence.internal.oxm.schema.model.Element |
createRefElement(java.lang.String elementRefName,
org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle particle)
Create an element reference and add it to a given particle.
|
protected org.eclipse.persistence.internal.oxm.schema.model.Element |
elementExistsInParticle(java.lang.String elementName,
java.lang.String refString,
org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle particle)
Convenience method for determining if an element already exists in a given
typedefparticle.
|
void |
generateSchema(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> additionalGlobalElements,
java.util.Map<java.lang.String,java.lang.Class> arrayClassesToGeneratedClasses) |
void |
generateSchema(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> additionalGlobalElements,
java.util.Map<java.lang.String,java.lang.Class> arrayClassesToGeneratedClasses,
SchemaOutputResolver outputResolver) |
java.util.Collection<org.eclipse.persistence.internal.oxm.schema.model.Schema> |
getAllSchemas() |
java.util.ArrayList<java.lang.Object> |
getEnumerationFacetsFor(EnumTypeInfo info) |
NamespaceInfo |
getNamespaceInfoForNamespace(java.lang.String namespace) |
NamespaceInfo |
getNamespaceInfoForNamespace(java.lang.String namespace,
java.lang.String packageName) |
java.lang.String |
getOrGeneratePrefixForNamespace(java.lang.String URI,
org.eclipse.persistence.internal.oxm.schema.model.Schema schema)
Attempt to resolve the given URI to a prefix.
|
java.lang.String |
getPrefixForNamespace(org.eclipse.persistence.internal.oxm.schema.model.Schema schema,
java.lang.String URI) |
javax.xml.namespace.QName |
getSchemaTypeFor(JavaClass javaClass)
Return the schema type (as QName) based on a given JavaClass.
|
java.util.Map<java.lang.String,SchemaTypeInfo> |
getSchemaTypeInfo()
Return the Map of SchemaTypeInfo instances.
|
java.lang.String |
getSchemaTypeNameForClassName(java.lang.String className) |
protected TransformerPropertyBuilder |
getTransformerPropertyBuilder(Property property,
TypeInfo typeInfo)
Returns TransformerPropertyBuilder which builds properties from xml transformers.
|
Property |
getXmlValueFieldForSimpleContent(TypeInfo info) |
boolean |
isCollectionType(Property field)
Indicates if a given Property is a collection type.
|
void |
populateSchemaTypes() |
public SchemaGenerator(Helper helper)
public void generateSchema(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> additionalGlobalElements, java.util.Map<java.lang.String,java.lang.Class> arrayClassesToGeneratedClasses, SchemaOutputResolver outputResolver)
public void generateSchema(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> additionalGlobalElements, java.util.Map<java.lang.String,java.lang.Class> arrayClassesToGeneratedClasses)
public void addSchemaComponents(JavaClass myClass)
public void addToSchemaType(TypeInfo ownerTypeInfo, java.util.List<Property> properties, org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle compositor, org.eclipse.persistence.internal.oxm.schema.model.ComplexType type, org.eclipse.persistence.internal.oxm.schema.model.Schema workingSchema)
public javax.xml.namespace.QName getSchemaTypeFor(JavaClass javaClass)
javaClass
- public void populateSchemaTypes()
public java.lang.String getSchemaTypeNameForClassName(java.lang.String className)
public java.util.ArrayList<java.lang.Object> getEnumerationFacetsFor(EnumTypeInfo info)
public boolean isCollectionType(Property field)
field
- public java.util.Collection<org.eclipse.persistence.internal.oxm.schema.model.Schema> getAllSchemas()
public NamespaceInfo getNamespaceInfoForNamespace(java.lang.String namespace)
public NamespaceInfo getNamespaceInfoForNamespace(java.lang.String namespace, java.lang.String packageName)
public java.lang.String getPrefixForNamespace(org.eclipse.persistence.internal.oxm.schema.model.Schema schema, java.lang.String URI)
public java.lang.String getOrGeneratePrefixForNamespace(java.lang.String URI, org.eclipse.persistence.internal.oxm.schema.model.Schema schema)
URI
- schema
- public void addGlobalElements(java.util.Map<javax.xml.namespace.QName,ElementDeclaration> additionalElements)
public java.util.Map<java.lang.String,SchemaTypeInfo> getSchemaTypeInfo()
protected boolean areEquals(JavaClass src, java.lang.String tgtCanonicalName)
src
- tgtCanonicalName
- protected boolean areEquals(JavaClass src, java.lang.Class tgt)
src
- tgt
- protected org.eclipse.persistence.jaxb.compiler.SchemaGenerator.AddToSchemaResult buildSchemaComponentsForXPath(org.eclipse.persistence.internal.oxm.XPathFragment frag, org.eclipse.persistence.jaxb.compiler.SchemaGenerator.AddToSchemaResult xpr, boolean isChoice, Property next)
frag
- xpr
- isChoice
- next
- protected org.eclipse.persistence.internal.oxm.schema.model.Element elementExistsInParticle(java.lang.String elementName, java.lang.String refString, org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle particle)
elementName
- the non-null element name to look forrefString
- if the element is a ref, this will be the prefix qualified element nameparticle
- the sequence/choice/all to search for an existing elementpublic org.eclipse.persistence.internal.oxm.schema.model.Attribute createGlobalAttribute(org.eclipse.persistence.internal.oxm.XPathFragment frag, org.eclipse.persistence.internal.oxm.schema.model.Schema workingSchema, org.eclipse.persistence.internal.oxm.schema.model.Schema fragSchema, Property prop)
frag
- workingSchema
- fragSchema
- prop
- public org.eclipse.persistence.internal.oxm.schema.model.Element createGlobalElement(org.eclipse.persistence.internal.oxm.XPathFragment frag, org.eclipse.persistence.internal.oxm.schema.model.Schema workingSchema, org.eclipse.persistence.internal.oxm.schema.model.Schema fragSchema, boolean isChoice, boolean isUnbounded, Property prop, boolean shouldSetType)
frag
- XPathFragment which wil lbe used to create the global elementworkingSchema
- current schemafragSchema
- frag's schemaisChoice
- indicates if we need to construct a choiceisUnbounded
- maxOccurs setting for choiceprop
- property which owns the xml-pathshouldSetType
- if this is the last fragment in the xml-path and not an 'any', we should set the typepublic org.eclipse.persistence.internal.oxm.schema.model.Element createRefElement(java.lang.String elementRefName, org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle particle)
elementRefName
- particle
- public org.eclipse.persistence.internal.oxm.schema.model.Attribute createRefAttribute(java.lang.String attributeRefName, org.eclipse.persistence.internal.oxm.schema.model.ComplexType owningComplexType)
attributeRefName
- owningComplexType
- protected TransformerPropertyBuilder getTransformerPropertyBuilder(Property property, TypeInfo typeInfo)
property
- property holding xml transformerstypeInfo
- typeInfo with transformer class