EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jaxb.compiler
Class SchemaGenerator

java.lang.Object
  extended by org.eclipse.persistence.jaxb.compiler.SchemaGenerator

public class SchemaGenerator
extends java.lang.Object

INTERNAL:

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.

See Also:
TypeInfo, AnnotationsProcessor, Generator
Author:
mmacivor
Since:
Oracle TopLink 11.1.1.0.0

Constructor Summary
SchemaGenerator(Helper helper)
           
 
Method Summary
 void addGlobalElements(java.util.HashMap<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.
 org.eclipse.persistence.internal.oxm.schema.model.Schema generateSchema(java.util.ArrayList<JavaClass> typeInfoClasses, java.util.HashMap<java.lang.String,TypeInfo> typeInfo, java.util.HashMap<java.lang.String,javax.xml.namespace.QName> userDefinedSchemaTypes, java.util.HashMap<java.lang.String,PackageInfo> packageToPackageInfoMappings, java.util.HashMap<javax.xml.namespace.QName,ElementDeclaration> additionalGlobalElements, java.util.Map<java.lang.String,java.lang.Class> arrayClassesToGeneratedClasses)
           
 org.eclipse.persistence.internal.oxm.schema.model.Schema generateSchema(java.util.ArrayList<JavaClass> typeInfoClasses, java.util.HashMap<java.lang.String,TypeInfo> typeInfo, java.util.HashMap<java.lang.String,javax.xml.namespace.QName> userDefinedSchemaTypes, java.util.HashMap<java.lang.String,PackageInfo> packageToPackageInfoMappings, java.util.HashMap<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)
           
 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.HashMap<java.lang.String,SchemaTypeInfo> getSchemaTypeInfo()
          Return the Map of SchemaTypeInfo instances.
 java.lang.String getSchemaTypeNameForClassName(java.lang.String className)
           
 Property getXmlValueFieldForSimpleContent(TypeInfo info)
           
 boolean isCollectionType(Property field)
          Indicates if a given Property is a collection type.
 void populateSchemaTypes()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaGenerator

public SchemaGenerator(Helper helper)
Method Detail

generateSchema

public org.eclipse.persistence.internal.oxm.schema.model.Schema generateSchema(java.util.ArrayList<JavaClass> typeInfoClasses,
                                                                               java.util.HashMap<java.lang.String,TypeInfo> typeInfo,
                                                                               java.util.HashMap<java.lang.String,javax.xml.namespace.QName> userDefinedSchemaTypes,
                                                                               java.util.HashMap<java.lang.String,PackageInfo> packageToPackageInfoMappings,
                                                                               java.util.HashMap<javax.xml.namespace.QName,ElementDeclaration> additionalGlobalElements,
                                                                               java.util.Map<java.lang.String,java.lang.Class> arrayClassesToGeneratedClasses,
                                                                               SchemaOutputResolver outputResolver)

generateSchema

public org.eclipse.persistence.internal.oxm.schema.model.Schema generateSchema(java.util.ArrayList<JavaClass> typeInfoClasses,
                                                                               java.util.HashMap<java.lang.String,TypeInfo> typeInfo,
                                                                               java.util.HashMap<java.lang.String,javax.xml.namespace.QName> userDefinedSchemaTypes,
                                                                               java.util.HashMap<java.lang.String,PackageInfo> packageToPackageInfoMappings,
                                                                               java.util.HashMap<javax.xml.namespace.QName,ElementDeclaration> additionalGlobalElements,
                                                                               java.util.Map<java.lang.String,java.lang.Class> arrayClassesToGeneratedClasses)

addSchemaComponents

public void addSchemaComponents(JavaClass myClass)

addToSchemaType

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)

getSchemaTypeFor

public javax.xml.namespace.QName getSchemaTypeFor(JavaClass javaClass)
Return the schema type (as QName) based on a given JavaClass.

Parameters:
javaClass -
Returns:

populateSchemaTypes

public void populateSchemaTypes()

getSchemaTypeNameForClassName

public java.lang.String getSchemaTypeNameForClassName(java.lang.String className)

getEnumerationFacetsFor

public java.util.ArrayList<java.lang.Object> getEnumerationFacetsFor(EnumTypeInfo info)

getXmlValueFieldForSimpleContent

public Property getXmlValueFieldForSimpleContent(TypeInfo info)

isCollectionType

public boolean isCollectionType(Property field)
Indicates if a given Property is a collection type.

Parameters:
field -
Returns:

getAllSchemas

public java.util.Collection<org.eclipse.persistence.internal.oxm.schema.model.Schema> getAllSchemas()

getNamespaceInfoForNamespace

public NamespaceInfo getNamespaceInfoForNamespace(java.lang.String namespace)

getPrefixForNamespace

public java.lang.String getPrefixForNamespace(org.eclipse.persistence.internal.oxm.schema.model.Schema schema,
                                              java.lang.String URI)

getOrGeneratePrefixForNamespace

public 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. If this is unsuccessful, one will be generated and added to the resolver.

Parameters:
URI -
schema -
Returns:

addGlobalElements

public void addGlobalElements(java.util.HashMap<javax.xml.namespace.QName,ElementDeclaration> additionalElements)

getSchemaTypeInfo

public java.util.HashMap<java.lang.String,SchemaTypeInfo> getSchemaTypeInfo()
Return the Map of SchemaTypeInfo instances. The Map is keyed on JavaClass qualified name.

Returns:

areEquals

protected boolean areEquals(JavaClass src,
                            java.lang.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 -
tgt -
Returns:

areEquals

protected boolean areEquals(JavaClass src,
                            java.lang.Class tgt)
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 -
tgt -
Returns:

buildSchemaComponentsForXPath

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. Regarding the path 'target', if the xml-path was "contact-info/address/street", "street" would be the target. In this case the sequence containing the "address" element would be set in the XmlPathResult to be returned. The exception case is an 'any', where we want to process the last path element before returning - this is necessary due to the fact that an Any will be added to the sequence in place of the last path element by the calling method.

Parameters:
frag -
xpr -
isAny -
isChoice -
Returns:

elementExistsInParticle

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. If an element exists whose ref is equal to 'refString' or its name is equal to 'elementName', it is returned. Null otherwise. Note that ref takes precidence, so if either has a ref set name equality will not be performed.

Parameters:
elementName - the non-null element name to look for
refString - if the element is a ref, this will be the prefix qualified element name
particle - the sequence/choice/all to search for an existing element
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 -
next -
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 element
workingSchema - current schema
fragSchema - frag's schema
isChoice - indicates if we need to construct a choice
isUnbounded - maxOccurs setting for choice
next - property which owns the xml-path
shouldSetType - 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(java.lang.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(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. 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:

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference