Class Model
- All Implemented Interfaces:
CCustomizable
,TypeInfoSet<NType,
NClass, Void, Void>
A Model
is a schema language neutral representation of the
result of a schema parsing. The back-end then works against this model
to turn this into a series of Java source code.
- Author:
- Kohsuke Kawaguchi
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal JCodeModel
This model uses this code model exclusively.final SymbolSpace
Default ID/IDREF symbol space.final Options
Command-line options used for building this model.If non-null, all the generated classes should eventually derive from this class.If non-null, all the generated interfaces should eventually derive from this interface.final XSSchemaSet
If this model was built from XML Schema, this field stores the root object of the parse schema model.boolean
True to generate serializable classes.serial version UID to be generated.Specifies the code generation strategy. -
Constructor Summary
ConstructorsConstructorDescriptionModel
(Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent) -
Method Summary
Modifier and TypeMethodDescriptionMap<NType,
? extends CArrayInfo> arrays()
No array mapping generation for XJC.beans()
Returns all theClassInfo
s known to this set.Map<NType,
? extends CBuiltinLeafInfo> builtins()
Returns all theBuiltinLeafInfo
s known to this set.final Map<QName,
CClassInfo> Represents the "top-level binding".void
Dumps this model into XML.enums()
Returns all theEnumLeafInfo
s known to this set.generateCode
(Options opt, ErrorReceiver receiver) Fully-generate the source code into the given model.Iterable<? extends CElementInfo>
Returns all theElementInfo
known to this set.Gets theTypeInfo
for the any type.getAttributeFormDefault
(String nsUri) Gets the reasonableXmlNsForm
for the given namespace URI.Gets the global customizations.getElementFormDefault
(String nsUri) Gets the reasonableXmlNsForm
for the given namespace URI.getElementInfo
(NClass scope, QName name) Returns aElementInfo
for the given element.getElementMappings
(NClass scope) Returns allElementInfo
s in the given scope.Deprecated.No line number available for the "root" component.final NameConverter
Gets the name converter that shall be used to parse XML names into Java names.Navigator
for this model.getPackage
(JPackage pkg) Deprecated.Always return null.GetsXmlSchema.location()
found in this context.getSymbolSpace
(String name) getTypeInfo
(NType type) Returns aTypeInfo
for the given type.getTypeInfo
(Ref<NType, NClass> ref) Returns a type information for the given reference.Not implemented in the compile-time model.boolean
void
setNameConverter
(NameConverter nameConverter) void
setPackageLevelAnnotations
(boolean packageLevelAnnotations) typeUses()
-
Field Details
-
schemaComponent
If this model was built from XML Schema, this field stores the root object of the parse schema model. Otherwise null.- Since:
- 2.1.1
-
codeModel
This model uses this code model exclusively. -
options
Command-line options used for building this model. -
serializable
public boolean serializableTrue to generate serializable classes. -
serialVersionUID
serial version UID to be generated. null if not to generate serialVersionUID field. -
rootClass
If non-null, all the generated classes should eventually derive from this class. -
rootInterface
If non-null, all the generated interfaces should eventually derive from this interface. -
strategy
Specifies the code generation strategy. Must not be null. -
defaultSymbolSpace
Default ID/IDREF symbol space. Any ID/IDREF without explicit reference to a symbol space is assumed to use this default symbol space.
-
-
Constructor Details
-
Model
public Model(Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent) - Parameters:
nc
- Usually this should be set in the constructor, but we do allow this parameter to be initially null, and then set later.schemaComponent
- The source schema model, if this is built from XSD.
-
-
Method Details
-
setNameConverter
-
getNameConverter
Gets the name converter that shall be used to parse XML names into Java names. -
isPackageLevelAnnotations
public boolean isPackageLevelAnnotations() -
setPackageLevelAnnotations
public void setPackageLevelAnnotations(boolean packageLevelAnnotations) -
getSymbolSpace
-
generateCode
Fully-generate the source code into the given model.- Returns:
- null if there was any errors. Otherwise it returns a valid
Outline
object, which captures how the model objects are mapped to the generated source code.Add-ons can use those information to further augment the generated source code.
-
createTopLevelBindings
Represents the "top-level binding".This is used to support the use of a schema inside WSDL. For XML Schema, the top-level binding is a map from global element declarations to its representation class.
For other schema languages, it should follow the appendices in WSDL (but in practice no one would use WSDL with a schema language other than XML Schema, so it doesn't really matter.)
This needs to be filled by the front-end.
-
getAnyTypeInfo
Description copied from interface:TypeInfoSet
Gets theTypeInfo
for the any type.- Specified by:
getAnyTypeInfo
in interfaceTypeInfoSet<NType,
NClass, Void, Void>
-
getTypeInfo
Description copied from interface:TypeInfoSet
Returns a type information for the given reference.- Specified by:
getTypeInfo
in interfaceTypeInfoSet<NType,
NClass, Void, Void>
-
beans
Description copied from interface:TypeInfoSet
Returns all theClassInfo
s known to this set. -
enums
Description copied from interface:TypeInfoSet
Returns all theEnumLeafInfo
s known to this set. -
typeUses
-
arrays
No array mapping generation for XJC. -
builtins
Description copied from interface:TypeInfoSet
Returns all theBuiltinLeafInfo
s known to this set. -
getAllElements
Description copied from interface:TypeInfoSet
Returns all theElementInfo
known to this set.- Specified by:
getAllElements
in interfaceTypeInfoSet<NType,
NClass, Void, Void>
-
getSchemaComponent
Deprecated.Always return null. Perhaps you are interested inschemaComponent
?Description copied from interface:CCustomizable
If this model object is built from XML Schema, this property returns a schema component from which the model is built.- Specified by:
getSchemaComponent
in interfaceCCustomizable
- Returns:
- null if the model is built from sources other than XML Schema (such as DTD.)
-
getLocator
Deprecated.No line number available for the "root" component.Description copied from interface:CCustomizable
Gets the source location in the schema from which this model component is created.- Specified by:
getLocator
in interfaceCCustomizable
- Returns:
- never null.
-
getCustomizations
Gets the global customizations.- Specified by:
getCustomizations
in interfaceCCustomizable
- Returns:
- can be an empty list but never be null. The returned list is read-only. Do not modify.
- See Also:
-
getXmlNs
Not implemented in the compile-time model. -
getSchemaLocations
Description copied from interface:TypeInfoSet
GetsXmlSchema.location()
found in this context.This operation is expected to be only used in schema generator, so it can be slow.
- Specified by:
getSchemaLocations
in interfaceTypeInfoSet<NType,
NClass, Void, Void> - Returns:
- A map from namespace URI to the value of the location.
If the entry is missing, that means a schema should be generated for that namespace.
If the value is "", that means the schema location is implied
(
<xs:schema namespace="..."/>
w/o schemaLocation.)
-
getElementFormDefault
Description copied from interface:TypeInfoSet
Gets the reasonableXmlNsForm
for the given namespace URI.The spec doesn't define very precisely what the
XmlNsForm
value for the given namespace would be, so this method is implemented in rather ad-hoc way. It should work as what most people expect for simple cases.- Specified by:
getElementFormDefault
in interfaceTypeInfoSet<NType,
NClass, Void, Void> - Returns:
- never null.
-
getAttributeFormDefault
Description copied from interface:TypeInfoSet
Gets the reasonableXmlNsForm
for the given namespace URI.The spec doesn't define very precisely what the
XmlNsForm
value for the given namespace would be, so this method is implemented in rather ad-hoc way. It should work as what most people expect for simple cases.- Specified by:
getAttributeFormDefault
in interfaceTypeInfoSet<NType,
NClass, Void, Void> - Returns:
- never null.
-
dump
Description copied from interface:TypeInfoSet
Dumps this model into XML. For debug only. TODO: not sure if this actually works. We don't really know what are T,C. -
getPackage
-