|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.nrl.parser.model.xsd.XSDModelLoader
public class XSDModelLoader
The main XML Schema model loader class. Call load(File)
to load a file and its includes
and imports as an NRL model or load(Resource, File)
if you already have a handle on the
EMF resource containing the schema.
Field Summary |
---|
Fields inherited from interface net.sourceforge.nrl.parser.model.xsd.IXSDUserData |
---|
ATTRIBUTE_KIND, CONTAINING_TYPE, JAXB_CATCH_ALL, JAXB_FLATTENED_PROPERTY, MODEL_FILE_LOCATION, NAMESPACE, RENAMED_AMBIGUOUS_ATTRIBUTE, SUBSTITUTABLE, SUBSTITUTION_FOR, XSD_ATTRIBUTE_KIND, XSD_COMPLEX_TYPE_KIND, XSD_ELEMENT_KIND, XSD_GLOBAL_ELEMENT, XSD_PATH, XSD_SIMPLE_TYPE_KIND, XSD_TYPE_KIND |
Constructor Summary | |
---|---|
XSDModelLoader()
|
Method Summary | |
---|---|
protected boolean |
areDescendantTypesUnique(org.eclipse.xsd.XSDParticle particle)
Traverse the entire particle and check whether all descendant elements have a unique type. |
protected org.eclipse.xsd.XSDModelGroup |
getClosestEnclosingGroup(org.eclipse.xsd.XSDElementDeclaration elementA,
org.eclipse.xsd.XSDElementDeclaration elementB)
Assuming that two elements are contained within the same time, return the closest enclosing particular (sequence/choice, etc) that encloses both of them. |
protected XSDClassifier |
getComplexType(XSDPackage resultPackage,
org.eclipse.xsd.XSDComplexTypeDefinition complexDef,
String anonymousTypeName,
boolean declaredAsGlobalElement)
Generate a complex type from a complex type definition, registered it with the name map, add it to the result package and return it. |
protected void |
getComplexTypes(org.eclipse.xsd.XSDSchema schema,
XSDPackage resultPackage)
Read in all global complex type definitions and add to result package. |
protected String |
getCompositorAsString(org.eclipse.xsd.XSDCompositor compositor)
Turn a sequence compositor to a string for naming purposes |
protected XSDDataType |
getDataType(org.eclipse.xsd.XSDComplexTypeDefinition def,
XSDPackage resultPackage,
String anonymousName,
boolean declaredAsGlobalElement)
Construct an XSDDataType from a complex type definition in the schema. |
protected XSDDataType |
getDataType(org.eclipse.xsd.XSDSimpleTypeDefinition def,
XSDPackage resultPackage,
String anonymousName,
boolean declaredAsGlobalElement)
Construct an XSDDataType from a simple type definition in the schema. |
protected org.eclipse.xsd.XSDParticle |
getDescendantElementParticle(org.eclipse.xsd.XSDParticle particle)
Keep looking inside the nested particles until we find the first element declaration. |
protected List<org.eclipse.xsd.XSDElementDeclaration> |
getDirectDescendants(org.eclipse.xsd.XSDParticle particle)
Return all element declarations in a particle, but not element declarations _within_ other element declarations, i.e. |
protected String |
getDisambiguated(String name,
String targetNamespace)
Return a disambiguated type name unique within the namespace. |
protected XSDDataType |
getEnumeration(org.eclipse.xsd.XSDSimpleTypeDefinition def,
XSDPackage resultPackage,
String anonymousName,
boolean declaredAsGlobalElement)
Create an enumeration type from a schema simple type. |
protected String |
getFlattenedJAXBPropertyName(org.eclipse.xsd.XSDParticle particle)
Suggest a property name based on a content model of sequences and choices. |
protected void |
getGlobalElements(org.eclipse.xsd.XSDSchema schema,
XSDPackage resultPackage)
Read in all global element definitions, turning each into a classifier. |
protected int |
getNumberOfDescendantElements(org.eclipse.xsd.XSDParticle particle)
Recursively search for elements within a repeating particle. |
protected void |
getSimpleTypes(org.eclipse.xsd.XSDSchema schema,
XSDPackage resultPackage)
Add anything to the result package that legitimately qualifies as a data type: simple types, derived simple types, enumerations and complex types that derive from simple types. |
protected String |
getSuggestedAnonymousTypeName(String namespace,
String assignedToElement)
Suggest a type name for an anonymous sub type, based on the element it has been assigned to. |
List<String> |
getWarnings()
Return the list of warning strings created during the last load operation. |
IPackage |
load(File file)
Deprecated. Use the IModelLoader interface to load models. |
IPackage |
load(org.eclipse.emf.ecore.resource.Resource res,
File file)
Deprecated. Use the IModelLoader interface to load models. |
IPackage |
load(org.eclipse.emf.ecore.resource.Resource res,
File file,
Map<?,?> options)
Deprecated. Use the IModelLoader interface to load models, or
load(Resource, Map) if you must. |
IPackage |
load(org.eclipse.emf.ecore.resource.Resource res,
Map<?,?> options)
|
protected void |
resolve(XSDPackage pkg)
Resolve attribute types, parent references. |
protected void |
traverseParticle(XSDPackage resultPackage,
XSDClassifier result,
org.eclipse.xsd.XSDParticle particle,
boolean ancestorOptional,
boolean ancestorUnbounded,
String targetNamespace)
Recursive method that traverses a schema particle content model and adds attributes to a classifier. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XSDModelLoader()
Method Detail |
---|
protected boolean areDescendantTypesUnique(org.eclipse.xsd.XSDParticle particle)
particle
- the particle
protected org.eclipse.xsd.XSDModelGroup getClosestEnclosingGroup(org.eclipse.xsd.XSDElementDeclaration elementA, org.eclipse.xsd.XSDElementDeclaration elementB)
elementA
- the first elementelementB
- the second element
protected XSDClassifier getComplexType(XSDPackage resultPackage, org.eclipse.xsd.XSDComplexTypeDefinition complexDef, String anonymousTypeName, boolean declaredAsGlobalElement)
resultPackage
- the package to add tocomplexDef
- the type definitionanonymousTypeName
- a name suggestion if the type is anonymous (has no name)declaredAsGlobalElement
- if true, this is a global element with an anonymous type
protected void getComplexTypes(org.eclipse.xsd.XSDSchema schema, XSDPackage resultPackage)
schema
- the schema to read fromresultPackage
- package to add toprotected String getCompositorAsString(org.eclipse.xsd.XSDCompositor compositor)
compositor
- the compositor (choice/sequence/all)
protected XSDDataType getDataType(org.eclipse.xsd.XSDComplexTypeDefinition def, XSDPackage resultPackage, String anonymousName, boolean declaredAsGlobalElement)
def
- the definitionresultPackage
- the package to add toanonymousName
- name to use if the type has no namedeclaredAsGlobalElement
- if true, this is a global element declaration with an anoymous
typeprotected XSDDataType getDataType(org.eclipse.xsd.XSDSimpleTypeDefinition def, XSDPackage resultPackage, String anonymousName, boolean declaredAsGlobalElement)
def
- the definitionresultPackage
- the package to add toanonymousName
- name to use if the type has no namedeclaredAsGlobalElement
- if true, this is a global element with an anoymous typeprotected org.eclipse.xsd.XSDParticle getDescendantElementParticle(org.eclipse.xsd.XSDParticle particle)
particle
- the particle to search
protected List<org.eclipse.xsd.XSDElementDeclaration> getDirectDescendants(org.eclipse.xsd.XSDParticle particle)
particle
- the particle
protected String getDisambiguated(String name, String targetNamespace)
name
- the nametargetNamespace
- the namespace
protected XSDDataType getEnumeration(org.eclipse.xsd.XSDSimpleTypeDefinition def, XSDPackage resultPackage, String anonymousName, boolean declaredAsGlobalElement)
def
- the the typeresultPackage
- the package to add toanonymousName
- name to use if the type has no namedeclaredAsGlobalElement
- if true, this is a global element with an anonymous typeprotected String getFlattenedJAXBPropertyName(org.eclipse.xsd.XSDParticle particle)
It will create a suggested name based on the JAXB convention, for example elementAAndElementB, if the elements are in a sequence.
particle
- the particle
protected void getGlobalElements(org.eclipse.xsd.XSDSchema schema, XSDPackage resultPackage)
schema
- the schema to read fromresultPackage
- the result package to add toprotected int getNumberOfDescendantElements(org.eclipse.xsd.XSDParticle particle)
particle
- the particle to search
protected void getSimpleTypes(org.eclipse.xsd.XSDSchema schema, XSDPackage resultPackage)
schema
- the schema to scanresultPackage
- the package to add toprotected String getSuggestedAnonymousTypeName(String namespace, String assignedToElement)
assignedToElement
- the element name
public List<String> getWarnings()
@Deprecated public IPackage load(File file) throws Exception
IModelLoader
interface to load models.
The method currently also ignores all ClassNotFoundException and PackageNotFoundException errors, to ignore problems where a profile is not found.
file
- the file to load
Exception
@Deprecated public IPackage load(org.eclipse.emf.ecore.resource.Resource res, File file) throws Exception
IModelLoader
interface to load models.
Exception
@Deprecated public IPackage load(org.eclipse.emf.ecore.resource.Resource res, File file, Map<?,?> options) throws Exception
IModelLoader
interface to load models, or
load(Resource, Map)
if you must.
Exception
public IPackage load(org.eclipse.emf.ecore.resource.Resource res, Map<?,?> options) throws Exception
Exception
protected void resolve(XSDPackage pkg)
protected void traverseParticle(XSDPackage resultPackage, XSDClassifier result, org.eclipse.xsd.XSDParticle particle, boolean ancestorOptional, boolean ancestorUnbounded, String targetNamespace)
result
- the classifier to add toparticle
- the particleancestorOptional
- if true, an ancestor particle was optional; everything from here on
will be optionalancestorUnbounded
- if true, an ancestor was unbounded; everything from here on will be
unbounded
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |