com.sun.tools.xjc.model

Class Model

public final class Model extends Object implements TypeInfoSet<NType,NClass,Void,Void>, CCustomizable

Root of the object model that represents the code that needs to be generated.

A Model is a schema language neutral representation of the result of a scehma parsing. The back-end then works against this model to turn this into a series of Java source code.

Field Summary
ClassNameAllocatorWrapperallocator
This allocator has the final say on deciding the class name.
JCodeModelcodeModel
This model uses this code model exclusively.
CCustomizationscustomizations
Single linked list that connects all CCustomizations that belong to this model.
SymbolSpacedefaultSymbolSpace
Default ID/IDREF symbol space.
static LocatorEMPTY_LOCATOR
Optionsoptions
Command-line options used for building this model.
JClassrootClass
If non-null, all the generated classes should eventually derive from this class.
JClassrootInterface
If non-null, all the generated interfaces should eventually derive from this interface.
XSSchemaSetschemaComponent
If this model was built from XML Schema, this field stores the root object of the parse schema model.
booleanserializable
True to generate serializable classes.
LongserialVersionUID
serial version UID to be generated. null if not to generate serialVersionUID field.
ImplStructureStrategystrategy
Specifies the code generation strategy.
Constructor Summary
Model(Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent)
Method Summary
voidadd(CEnumLeafInfo e)
voidadd(CClassInfo ci)
voidadd(CElementInfo ei)
Map<NType,? extends CArrayInfo>arrays()
No array mapping generation for XJC.
Map<NClass,CClassInfo>beans()
Map<NType,? extends CBuiltinLeafInfo>builtins()
Map<QName,CClassInfo>createTopLevelBindings()
Represents the "top-level binding".
voiddump(Result out)
Map<NClass,CEnumLeafInfo>enums()
OutlinegenerateCode(Options opt, ErrorReceiver receiver)
Fully-generate the source code into the given model.
Iterable<? extends CElementInfo>getAllElements()
CBuiltinLeafInfogetAnyTypeInfo()
XmlNsFormgetAttributeFormDefault(String nsUri)
CClassInfogetClassInfo(NClass t)
CCustomizationsgetCustomizations()
Gets the global customizations.
XmlNsFormgetElementFormDefault(String nsUri)
CElementInfogetElementInfo(NClass scope, QName name)
Map<QName,CElementInfo>getElementMappings(NClass scope)
LocatorgetLocator()
NameConvertergetNameConverter()
Gets the name converter that shall be used to parse XML names into Java names.
Navigator<NType,NClass,Void,Void>getNavigator()
CClassInfoParent.PackagegetPackage(JPackage pkg)
XSComponentgetSchemaComponent()
Map<String,String>getSchemaLocations()
SymbolSpacegetSymbolSpace(String name)
CNonElementgetTypeInfo(NType type)
CNonElementgetTypeInfo(Ref<NType,NClass> ref)
Map<String,String>getXmlNs(String namespaceUri)
Not implemented in the compile-time model.
booleanisPackageLevelAnnotations()
voidsetNameConverter(NameConverter nameConverter)
voidsetPackageLevelAnnotations(boolean packageLevelAnnotations)
Map<QName,TypeUse>typeUses()

Field Detail

allocator

final ClassNameAllocatorWrapper allocator
This allocator has the final say on deciding the class name. Must not be null.

Model classes are responsible for using the allocator. This allocator interaction should be transparent to the user/builder of the model.

codeModel

final JCodeModel codeModel
This model uses this code model exclusively.

customizations

CCustomizations customizations
Single linked list that connects all CCustomizations that belong to this model.

See Also: next

defaultSymbolSpace

final SymbolSpace defaultSymbolSpace
Default ID/IDREF symbol space. Any ID/IDREF without explicit reference to a symbol space is assumed to use this default symbol space.

EMPTY_LOCATOR

static final Locator EMPTY_LOCATOR

options

public final Options options
Command-line options used for building this model.

rootClass

JClass rootClass
If non-null, all the generated classes should eventually derive from this class.

rootInterface

JClass rootInterface
If non-null, all the generated interfaces should eventually derive from this interface.

schemaComponent

public final XSSchemaSet schemaComponent
If this model was built from XML Schema, this field stores the root object of the parse schema model. Otherwise null.

UNKNOWN: 2.1.1

serializable

boolean serializable
True to generate serializable classes.

serialVersionUID

Long serialVersionUID
serial version UID to be generated. null if not to generate serialVersionUID field.

strategy

public ImplStructureStrategy strategy
Specifies the code generation strategy. Must not be null.

Constructor Detail

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 Detail

add

void add(CEnumLeafInfo e)

add

void add(CClassInfo ci)

add

void add(CElementInfo ei)

arrays

public Map<NType,? extends CArrayInfo> arrays()
No array mapping generation for XJC.

beans

public Map<NClass,CClassInfo> beans()

builtins

public Map<NType,? extends CBuiltinLeafInfo> builtins()

createTopLevelBindings

public final Map<QName,CClassInfo> 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 appendicies 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.

dump

public void dump(Result out)

enums

public Map<NClass,CEnumLeafInfo> enums()

generateCode

public Outline generateCode(Options opt, ErrorReceiver receiver)
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.

getAllElements

public Iterable<? extends CElementInfo> getAllElements()

getAnyTypeInfo

public CBuiltinLeafInfo getAnyTypeInfo()

getAttributeFormDefault

public XmlNsForm getAttributeFormDefault(String nsUri)

getClassInfo

public CClassInfo getClassInfo(NClass t)

getCustomizations

public CCustomizations getCustomizations()
Gets the global customizations.

getElementFormDefault

public XmlNsForm getElementFormDefault(String nsUri)

getElementInfo

public CElementInfo getElementInfo(NClass scope, QName name)

getElementMappings

public Map<QName,CElementInfo> getElementMappings(NClass scope)

getLocator

public Locator getLocator()

Deprecated: No line number available for the "root" component.

getNameConverter

public final NameConverter getNameConverter()
Gets the name converter that shall be used to parse XML names into Java names.

getNavigator

public Navigator<NType,NClass,Void,Void> getNavigator()

getPackage

public CClassInfoParent.Package getPackage(JPackage pkg)

getSchemaComponent

public XSComponent getSchemaComponent()

Deprecated: Always return null. Perhaps you are interested in schemaComponent?

getSchemaLocations

public Map<String,String> getSchemaLocations()

getSymbolSpace

public SymbolSpace getSymbolSpace(String name)

getTypeInfo

public CNonElement getTypeInfo(NType type)

getTypeInfo

public CNonElement getTypeInfo(Ref<NType,NClass> ref)

getXmlNs

public Map<String,String> getXmlNs(String namespaceUri)
Not implemented in the compile-time model.

isPackageLevelAnnotations

public boolean isPackageLevelAnnotations()

setNameConverter

public void setNameConverter(NameConverter nameConverter)

setPackageLevelAnnotations

public void setPackageLevelAnnotations(boolean packageLevelAnnotations)

typeUses

public Map<QName,TypeUse> typeUses()