Class SchemaGenerator
- java.lang.Object
-
- org.eclipse.persistence.jaxb.compiler.SchemaGenerator
-
public class SchemaGenerator extends Object
INTERNAL:Purpose:To generate Schema objects based on a map of TypeInfo objects, and some additional information gathered by the AnnotationsProcessing phase.
Responsibilities:
- Create and maintain a collection of Schema objects based on the provided TypeInfo objects
- Add additional global elements to the schema based on an optional map (for WS integration)
- Should create a schema for each namespace encountered during generation.
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.
- Since:
- Oracle TopLink 11.1.1.0.0
- Author:
- mmacivor
- See Also:
TypeInfo,AnnotationsProcessor,Generator
-
-
Constructor Summary
Constructors Constructor Description SchemaGenerator(Helper helper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGlobalElements(Map<QName,ElementDeclaration> additionalElements)voidaddSchemaComponents(JavaClass myClass)voidaddToSchemaType(TypeInfo ownerTypeInfo, 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)org.eclipse.persistence.internal.oxm.schema.model.AttributecreateGlobalAttribute(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.ElementcreateGlobalElement(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.AttributecreateRefAttribute(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.ElementcreateRefElement(String elementRefName, org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle particle)Create an element reference and add it to a given particle.voidgenerateSchema(List<JavaClass> typeInfoClasses, Map<String,TypeInfo> typeInfo, Map<String,QName> userDefinedSchemaTypes, Map<String,PackageInfo> packageToPackageInfoMappings, Map<QName,ElementDeclaration> additionalGlobalElements, Map<String,Class> arrayClassesToGeneratedClasses)voidgenerateSchema(List<JavaClass> typeInfoClasses, Map<String,TypeInfo> typeInfo, Map<String,QName> userDefinedSchemaTypes, Map<String,PackageInfo> packageToPackageInfoMappings, Map<QName,ElementDeclaration> additionalGlobalElements, Map<String,Class> arrayClassesToGeneratedClasses, javax.xml.bind.SchemaOutputResolver outputResolver)Collection<org.eclipse.persistence.internal.oxm.schema.model.Schema>getAllSchemas()ArrayList<Object>getEnumerationFacetsFor(EnumTypeInfo info)NamespaceInfogetNamespaceInfoForNamespace(String namespace)NamespaceInfogetNamespaceInfoForNamespace(String namespace, String packageName)StringgetOrGeneratePrefixForNamespace(String URI, org.eclipse.persistence.internal.oxm.schema.model.Schema schema)Attempt to resolve the given URI to a prefix.StringgetPrefixForNamespace(org.eclipse.persistence.internal.oxm.schema.model.Schema schema, String URI)QNamegetSchemaTypeFor(JavaClass javaClass)Return the schema type (as QName) based on a given JavaClass.Map<String,SchemaTypeInfo>getSchemaTypeInfo()Return the Map of SchemaTypeInfo instances.StringgetSchemaTypeNameForClassName(String className)PropertygetXmlValueFieldForSimpleContent(TypeInfo info)booleanisCollectionType(Property field)Indicates if a given Property is a collection type.voidpopulateSchemaTypes()
-
-
-
Constructor Detail
-
SchemaGenerator
public SchemaGenerator(Helper helper)
-
-
Method Detail
-
generateSchema
public void generateSchema(List<JavaClass> typeInfoClasses, Map<String,TypeInfo> typeInfo, Map<String,QName> userDefinedSchemaTypes, Map<String,PackageInfo> packageToPackageInfoMappings, Map<QName,ElementDeclaration> additionalGlobalElements, Map<String,Class> arrayClassesToGeneratedClasses, javax.xml.bind.SchemaOutputResolver outputResolver)
-
generateSchema
public void generateSchema(List<JavaClass> typeInfoClasses, Map<String,TypeInfo> typeInfo, Map<String,QName> userDefinedSchemaTypes, Map<String,PackageInfo> packageToPackageInfoMappings, Map<QName,ElementDeclaration> additionalGlobalElements, Map<String,Class> arrayClassesToGeneratedClasses)
-
addSchemaComponents
public void addSchemaComponents(JavaClass myClass)
-
addToSchemaType
public void addToSchemaType(TypeInfo ownerTypeInfo, 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)
-
getSchemaTypeFor
public QName getSchemaTypeFor(JavaClass javaClass)
Return the schema type (as QName) based on a given JavaClass.- Parameters:
javaClass-- Returns:
-
populateSchemaTypes
public void populateSchemaTypes()
-
getEnumerationFacetsFor
public ArrayList<Object> getEnumerationFacetsFor(EnumTypeInfo info)
-
isCollectionType
public boolean isCollectionType(Property field)
Indicates if a given Property is a collection type.- Parameters:
field-- Returns:
-
getAllSchemas
public Collection<org.eclipse.persistence.internal.oxm.schema.model.Schema> getAllSchemas()
-
getNamespaceInfoForNamespace
public NamespaceInfo getNamespaceInfoForNamespace(String namespace)
-
getNamespaceInfoForNamespace
public NamespaceInfo getNamespaceInfoForNamespace(String namespace, String packageName)
-
getPrefixForNamespace
public String getPrefixForNamespace(org.eclipse.persistence.internal.oxm.schema.model.Schema schema, String URI)
-
getOrGeneratePrefixForNamespace
public String getOrGeneratePrefixForNamespace(String URI, org.eclipse.persistence.internal.oxm.schema.model.Schema schema)
Attempt to resolve the given URI to a prefix. If this is unsuccessful, one will be generated and added to the resolver.- Parameters:
URI-schema-- Returns:
-
addGlobalElements
public void addGlobalElements(Map<QName,ElementDeclaration> additionalElements)
-
getSchemaTypeInfo
public Map<String,SchemaTypeInfo> getSchemaTypeInfo()
Return the Map of SchemaTypeInfo instances. The Map is keyed on JavaClass qualified name.- Returns:
-
createGlobalAttribute
public 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. An import is added if necessary. This method will typically be called when processing an XPath and a prefixed path element is encountered tha requires an attribute ref.- Parameters:
frag-workingSchema-fragSchema-prop-- Returns:
-
createGlobalElement
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)Create a global element. An import is added if necessary. This method will typically be called when processing an XPath and a prefixed path element is encountered the requires an element ref.- Parameters:
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 type- Returns:
-
createRefElement
public org.eclipse.persistence.internal.oxm.schema.model.Element createRefElement(String elementRefName, org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle particle)
Create an element reference and add it to a given particle. This method will typically be called when processing an XPath and a prefixed path element is encountered that requires an element ref.- Parameters:
elementRefName-particle-- Returns:
-
createRefAttribute
public org.eclipse.persistence.internal.oxm.schema.model.Attribute createRefAttribute(String attributeRefName, org.eclipse.persistence.internal.oxm.schema.model.ComplexType owningComplexType)
Create an attribute reference and add it to a given complex type. This method will typically be called when processing an XPath and a prefixed path element is encountered that requires an attribute ref.- Parameters:
attributeRefName-owningComplexType-- Returns:
-
-