Top Description Fields Constructors Methods
com.sun.tools.xjc.model

public final Class Model

extends Object
implements TypeInfoSet<NType, NClass, Void, Void>, CCustomizable
Class Inheritance
All Implemented Interfaces
com.sun.tools.xjc.model.CCustomizable, org.glassfish.jaxb.core.v2.model.core.TypeInfoSet
Imports
com.sun.codemodel.JClass, .JCodeModel, .JPackage, com.sun.tools.xjc.ErrorReceiver, .Options, .Plugin, com.sun.tools.xjc.api.ClassNameAllocator, com.sun.tools.xjc.generator.bean.BeanGenerator, .ImplStructureStrategy, com.sun.tools.xjc.model.nav.NClass, .NType, .NavigatorImpl, com.sun.tools.xjc.outline.Outline, com.sun.tools.xjc.reader.xmlschema.Messages, com.sun.tools.xjc.util.ErrorReceiverFilter, org.glassfish.jaxb.core.api.impl.NameConverter, org.glassfish.jaxb.core.v2.model.core.Ref, .TypeInfoSet, org.glassfish.jaxb.core.v2.model.nav.Navigator, org.glassfish.jaxb.core.v2.util.FlattenIterator, com.sun.xml.xsom.XSComponent, .XSSchemaSet, org.xml.sax.Locator, .SAXException, org.xml.sax.helpers.LocatorImpl, jakarta.xml.bind.annotation.XmlAttribute, .XmlNsForm, .XmlTransient, javax.xml.namespace.QName, javax.xml.transform.Result, java.util.Collections, .HashMap, .HashSet, .Iterator, .LinkedHashMap, .Map, .Set

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 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

Modifier and TypeField and Description
private final Iterable<? extends CElementInfo>
pack-priv final ClassNameAllocatorWrapper
allocator

This allocator has the final say on deciding the class name.

private final Map<NClass, CClassInfo>
beans

Generated beans.

private final Map<JPackage, CClassInfoParent.Package>
public final JCodeModel
codeModel

This model uses this code model exclusively.

pack-priv CCustomizations
customizations

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

public final SymbolSpace
defaultSymbolSpace

Default ID/IDREF symbol space.

private final Map<NClass, Map<QName, CElementInfo>>
elementMappings

The element mappings.

pack-priv static final Locator
private final Map<NClass, CEnumLeafInfo>
enums

Generated enums.

private CCustomizations
private NameConverter
public final Options
options

Command-line options used for building this model.

private boolean
packageLevelAnnotations

This field controls the generation of package level annotations for s2j

public JClass
rootClass

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

public JClass
rootInterface

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

public final XSSchemaSet
schemaComponent

If this model was built from XML Schema, this field stores the root object of the parse schema model.

public boolean
serializable

True to generate serializable classes.

public Long
serialVersionUID

serial version UID to be generated.

public ImplStructureStrategy
strategy

Specifies the code generation strategy.

private final Map<String, SymbolSpace>
symbolSpaces

All the defined SymbolSpaces keyed by their name.

private final Map<QName, TypeUse>
typeUses

TypeUses for all named types.

Constructor Summary

AccessConstructor and Description
public
Model(Options opts, JCodeModel cm, NameConverter
Usually this should be set in the constructor, but we do allow this parameter to be initially null, and then set later.
nc
,
ClassNameAllocator allocator, XSSchemaSet
The source schema model, if this is built from XSD.
schemaComponent
)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
pack-priv void
public Map<NType, ? extends CArrayInfo>
arrays()

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.arrays.

No array mapping generation for XJC.

public Map<NClass, CClassInfo>
beans()

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.beans.

Returns all the ClassInfos known to this set.

public Map<NType, ? extends CBuiltinLeafInfo>
public Map<QName, CClassInfo>
createTopLevelBindings()

Represents the "top-level binding".

public void
dump(Result out)

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.dump.

Dumps this model into XML.

public Map<NClass, CEnumLeafInfo>
enums()

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.enums.

Returns all the EnumLeafInfos known to this set.

public Outline

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.

generateCode
(Options opt, ErrorReceiver receiver)

Fully-generate the source code into the given model.

public Iterable<? extends CElementInfo>
public CBuiltinLeafInfo
public XmlNsForm
public CClassInfo
public CCustomizations
public XmlNsForm
public CElementInfo
public Map<QName, CElementInfo>
public Locator
getLocator()

Implements com.sun.tools.xjc.model.CCustomizable.getLocator.

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

Gets the source location in the schema from which this model component is created.

public NameConverter
getNameConverter()

Gets the name converter that shall be used to parse XML names into Java names.

public Navigator<NType, NClass, Void, Void>
public CClassInfoParent.Package
public XSComponent
getSchemaComponent()

Implements com.sun.tools.xjc.model.CCustomizable.getSchemaComponent.

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

If this model object is built from XML Schema, this property returns a schema component from which the model is built.

public Map<String, String>
public SymbolSpace
public CNonElement
public CNonElement
public Map<String, String>
getXmlNs(String namespaceUri)

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getXmlNs.

Not implemented in the compile-time model.

public boolean
public void
public void
setPackageLevelAnnotations(boolean packageLevelAnnotations)

public Map<QName, TypeUse>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allElementsback to summary
private final Iterable<? extends CElementInfo> allElements
allocatorback to summary
pack-priv 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.

beansback to summary
private final Map<NClass, CClassInfo> beans

Generated beans.

cacheback to summary
private final Map<JPackage, CClassInfoParent.Package> cache
codeModelback to summary
public final JCodeModel codeModel

This model uses this code model exclusively.

Annotations
@XmlTransient
customizationsback to summary
pack-priv CCustomizations customizations

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

See Also
CCustomizations#next
defaultSymbolSpaceback to summary
public 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.

Annotations
@XmlTransient
elementMappingsback to summary
private final Map<NClass, Map<QName, CElementInfo>> elementMappings

The element mappings.

EMPTY_LOCATORback to summary
pack-priv static final Locator EMPTY_LOCATOR
enumsback to summary
private final Map<NClass, CEnumLeafInfo> enums

Generated enums.

globalCustomizationsback to summary
private CCustomizations globalCustomizations
nameConverterback to summary
private NameConverter nameConverter

NameConverter to be used.

optionsback to summary
public final Options options

Command-line options used for building this model.

packageLevelAnnotationsback to summary
private boolean packageLevelAnnotations

This field controls the generation of package level annotations for s2j

rootClassback to summary
public JClass rootClass

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

Annotations
@XmlTransient
rootInterfaceback to summary
public JClass rootInterface

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

Annotations
@XmlTransient
schemaComponentback to summary
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.

Since
2.1.1
serializableback to summary
public boolean serializable

True to generate serializable classes.

Annotations
@XmlAttribute
serialVersionUIDback to summary
public Long serialVersionUID

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

Annotations
@XmlAttribute
strategyback to summary
public ImplStructureStrategy strategy

Specifies the code generation strategy. Must not be null.

symbolSpacesback to summary
private final Map<String, SymbolSpace> symbolSpaces

All the defined SymbolSpaces keyed by their name.

typeUsesback to summary
private final Map<QName, TypeUse> typeUses

TypeUses for all named types.

I really don't want to promote the notion of a 'type' in any place except in the XML Schema code, but this needs to be exposed for JAX-RPC. A reference to a named XML type will be converted into a reference to a Java type with annotations.

Constructor Detail

Modelback to summary
public Model(Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent)
Parameters
nc:NameConverter

Usually this should be set in the constructor, but we do allow this parameter to be initially null, and then set later.

schemaComponent:XSSchemaSet

The source schema model, if this is built from XSD.

Method Detail

addback to summary
pack-priv void add(CEnumLeafInfo e)
addback to summary
pack-priv void add(CClassInfo ci)
addback to summary
pack-priv void add(CElementInfo ei)
arraysback to summary
public Map<NType, ? extends CArrayInfo> arrays()

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.arrays.

No array mapping generation for XJC.

Annotations
@Override
beansback to summary
public Map<NClass, CClassInfo> beans()

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.beans.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.beans.

Returns all the ClassInfos known to this set.

Annotations
@Override
builtinsback to summary
public Map<NType, ? extends CBuiltinLeafInfo> builtins()

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.builtins.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.builtins.

Returns all the BuiltinLeafInfos known to this set.

Annotations
@Override
createTopLevelBindingsback to summary
public 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 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.

dumpback to summary
public void dump(Result out)

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.dump.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.dump.

Dumps this model into XML. For debug only.

Todo

not sure if this actually works. We don't really know what are T,C.

Annotations
@Override
enumsback to summary
public Map<NClass, CEnumLeafInfo> enums()

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.enums.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.enums.

Returns all the EnumLeafInfos known to this set.

Annotations
@Override
generateCodeback to summary
public Outline generateCode(Options opt, ErrorReceiver receiver)

Fully-generate the source code into the given model.

Returns:Outline

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.

getAllElementsback to summary
public Iterable<? extends CElementInfo> getAllElements()

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getAllElements.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getAllElements.

Returns all the ElementInfo known to this set.

Annotations
@Override
getAnyTypeInfoback to summary
public CBuiltinLeafInfo getAnyTypeInfo()

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getAnyTypeInfo.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getAnyTypeInfo.

Gets the TypeInfo for the any type.

Annotations
@Override
getAttributeFormDefaultback to summary
public XmlNsForm getAttributeFormDefault(String nsUri)

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getAttributeFormDefault.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getAttributeFormDefault.

Gets the reasonable XmlNsForm 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.

Annotations
@Override
getClassInfoback to summary
public CClassInfo getClassInfo(NClass t)

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getClassInfo.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getClassInfo.

Returns a ClassInfo, ArrayInfo, or LeafInfo for the given bean.

This method is almost like refinement of getTypeInfo(Object) except our C cannot derive from T.

Annotations
@Override
getCustomizationsback to summary
public CCustomizations getCustomizations()

Implements com.sun.tools.xjc.model.CCustomizable.getCustomizations.

Gets the global customizations.

Annotations
@Override
getElementFormDefaultback to summary
public XmlNsForm getElementFormDefault(String nsUri)

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getElementFormDefault.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getElementFormDefault.

Gets the reasonable XmlNsForm 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.

Annotations
@Override
getElementInfoback to summary
public CElementInfo getElementInfo(NClass scope, QName name)

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getElementInfo.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getElementInfo.

Returns a ElementInfo for the given element.

Annotations
@Override
getElementMappingsback to summary
public Map<QName, CElementInfo> getElementMappings(NClass scope)

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getElementMappings.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getElementMappings.

Returns all ElementInfos in the given scope.

Annotations
@Override
getLocatorback to summary
public Locator getLocator()

Implements com.sun.tools.xjc.model.CCustomizable.getLocator.

Doc from com.sun.tools.xjc.model.CCustomizable.getLocator.

Deprecated

No line number available for the "root" component.

Gets the source location in the schema from which this model component is created.

Annotations
@Deprecated
@Override
getNameConverterback to summary
public NameConverter getNameConverter()

Gets the name converter that shall be used to parse XML names into Java names.

getNavigatorback to summary
public Navigator<NType, NClass, Void, Void> getNavigator()

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getNavigator.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getNavigator.

Navigator for this model.

Annotations
@Override
getPackageback to summary
public CClassInfoParent.Package getPackage(JPackage pkg)
getSchemaComponentback to summary
public XSComponent getSchemaComponent()

Implements com.sun.tools.xjc.model.CCustomizable.getSchemaComponent.

Doc from com.sun.tools.xjc.model.CCustomizable.getSchemaComponent.

Deprecated

Always return null. Perhaps you are interested in schemaComponent?

If this model object is built from XML Schema, this property returns a schema component from which the model is built.

Annotations
@Deprecated
@Override
getSchemaLocationsback to summary
public Map<String, String> getSchemaLocations()

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getSchemaLocations.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getSchemaLocations.

Gets XmlSchema#location() found in this context.

This operation is expected to be only used in schema generator, so it can be slow.

Annotations
@Override
getSymbolSpaceback to summary
public SymbolSpace getSymbolSpace(String name)
getTypeInfoback to summary
public CNonElement getTypeInfo(NType type)

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getTypeInfo.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getTypeInfo.

Returns a TypeInfo for the given type.

Annotations
@Override
getTypeInfoback to summary
public CNonElement getTypeInfo(Ref<NType, NClass> ref)

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getTypeInfo, org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getTypeInfo.

Doc from org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getTypeInfo.

Returns a type information for the given reference.

Annotations
@Override
getXmlNsback to summary
public Map<String, String> getXmlNs(String namespaceUri)

Implements org.glassfish.jaxb.core.v2.model.core.TypeInfoSet.getXmlNs.

Not implemented in the compile-time model.

Annotations
@Override
isPackageLevelAnnotationsback to summary
public boolean isPackageLevelAnnotations()
setNameConverterback to summary
public void setNameConverter(NameConverter nameConverter)
setPackageLevelAnnotationsback to summary
public void setPackageLevelAnnotations(boolean packageLevelAnnotations)
typeUsesback to summary
public Map<QName, TypeUse> typeUses()