- java.lang.Object
-
- com.sun.tools.xjc.model.Model
-
- All Implemented Interfaces:
CCustomizable,TypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
public final class Model extends Object implements TypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>, CCustomizable
Root of the object model that represents the code that needs to be generated.A
Modelis 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
Fields Modifier and Type Field Description JCodeModelcodeModelThis model uses this code model exclusively.SymbolSpacedefaultSymbolSpaceDefault ID/IDREF symbol space.OptionsoptionsCommand-line options used for building this model.JClassrootClassIf non-null, all the generated classes should eventually derive from this class.JClassrootInterfaceIf non-null, all the generated interfaces should eventually derive from this interface.XSSchemaSetschemaComponentIf this model was built from XML Schema, this field stores the root object of the parse schema model.booleanserializableTrue to generate serializable classes.LongserialVersionUIDserial version UID to be generated.com.sun.tools.xjc.generator.bean.ImplStructureStrategystrategySpecifies the code generation strategy.
-
Constructor Summary
Constructors Constructor Description Model(Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Map<com.sun.tools.xjc.model.nav.NType,? extends CArrayInfo>arrays()No array mapping generation for XJC.Map<com.sun.tools.xjc.model.nav.NClass,CClassInfo>beans()Map<com.sun.tools.xjc.model.nav.NType,? extends CBuiltinLeafInfo>builtins()Map<QName,CClassInfo>createTopLevelBindings()Represents the "top-level binding".voiddump(Result out)Map<com.sun.tools.xjc.model.nav.NClass,CEnumLeafInfo>enums()OutlinegenerateCode(Options opt, ErrorReceiver receiver)Fully-generate the source code into the given model.Iterable<? extends CElementInfo>getAllElements()CBuiltinLeafInfogetAnyTypeInfo()javax.xml.bind.annotation.XmlNsFormgetAttributeFormDefault(String nsUri)CClassInfogetClassInfo(com.sun.tools.xjc.model.nav.NClass t)CCustomizationsgetCustomizations()Gets the global customizations.javax.xml.bind.annotation.XmlNsFormgetElementFormDefault(String nsUri)CElementInfogetElementInfo(com.sun.tools.xjc.model.nav.NClass scope, QName name)Map<QName,CElementInfo>getElementMappings(com.sun.tools.xjc.model.nav.NClass scope)LocatorgetLocator()Deprecated.No line number available for the "root" component.NameConvertergetNameConverter()Gets the name converter that shall be used to parse XML names into Java names.Navigator<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>getNavigator()CClassInfoParent.PackagegetPackage(JPackage pkg)XSComponentgetSchemaComponent()Deprecated.Always return null.Map<String,String>getSchemaLocations()SymbolSpacegetSymbolSpace(String name)CNonElementgetTypeInfo(com.sun.tools.xjc.model.nav.NType type)CNonElementgetTypeInfo(Ref<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.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
-
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.- Since:
- 2.1.1
-
codeModel
public final JCodeModel codeModel
This model uses this code model exclusively.
-
options
public final Options options
Command-line options used for building this model.
-
serializable
public boolean serializable
True to generate serializable classes.
-
serialVersionUID
public Long serialVersionUID
serial version UID to be generated. null if not to generate serialVersionUID field.
-
rootClass
public JClass rootClass
If non-null, all the generated classes should eventually derive from this class.
-
rootInterface
public JClass rootInterface
If non-null, all the generated interfaces should eventually derive from this interface.
-
strategy
public com.sun.tools.xjc.generator.bean.ImplStructureStrategy strategy
Specifies the code generation strategy. Must not be null.
-
defaultSymbolSpace
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.
-
-
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
-
setNameConverter
public void setNameConverter(NameConverter nameConverter)
-
getNameConverter
public final NameConverter 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
public SymbolSpace getSymbolSpace(String name)
-
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
Outlineobject, 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
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 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.
-
getNavigator
public Navigator<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void> getNavigator()
- Specified by:
getNavigatorin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getTypeInfo
public CNonElement getTypeInfo(com.sun.tools.xjc.model.nav.NType type)
- Specified by:
getTypeInfoin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getAnyTypeInfo
public CBuiltinLeafInfo getAnyTypeInfo()
- Specified by:
getAnyTypeInfoin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getTypeInfo
public CNonElement getTypeInfo(Ref<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass> ref)
- Specified by:
getTypeInfoin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
beans
public Map<com.sun.tools.xjc.model.nav.NClass,CClassInfo> beans()
- Specified by:
beansin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
enums
public Map<com.sun.tools.xjc.model.nav.NClass,CEnumLeafInfo> enums()
- Specified by:
enumsin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
arrays
public Map<com.sun.tools.xjc.model.nav.NType,? extends CArrayInfo> arrays()
No array mapping generation for XJC.- Specified by:
arraysin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
builtins
public Map<com.sun.tools.xjc.model.nav.NType,? extends CBuiltinLeafInfo> builtins()
- Specified by:
builtinsin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getClassInfo
public CClassInfo getClassInfo(com.sun.tools.xjc.model.nav.NClass t)
- Specified by:
getClassInfoin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getElementInfo
public CElementInfo getElementInfo(com.sun.tools.xjc.model.nav.NClass scope, QName name)
- Specified by:
getElementInfoin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getElementMappings
public Map<QName,CElementInfo> getElementMappings(com.sun.tools.xjc.model.nav.NClass scope)
- Specified by:
getElementMappingsin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getAllElements
public Iterable<? extends CElementInfo> getAllElements()
- Specified by:
getAllElementsin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getSchemaComponent
public XSComponent getSchemaComponent()
Deprecated.Always return null. Perhaps you are interested inschemaComponent?Description copied from interface:CCustomizableIf this model object is built from XML Schema, this property returns a schema component from which the model is built.- Specified by:
getSchemaComponentin interfaceCCustomizable- Returns:
- null if the model is built from sources other than XML Schema (such as DTD.)
-
getLocator
public Locator getLocator()
Deprecated.No line number available for the "root" component.Description copied from interface:CCustomizableGets the source location in the schema from which this model component is created.- Specified by:
getLocatorin interfaceCCustomizable- Returns:
- never null.
-
getCustomizations
public CCustomizations getCustomizations()
Gets the global customizations.- Specified by:
getCustomizationsin interfaceCCustomizable- Returns:
- can be an empty list but never be null. The returned list is read-only. Do not modify.
- See Also:
Plugin.getCustomizationURIs()
-
getXmlNs
public Map<String,String> getXmlNs(String namespaceUri)
Not implemented in the compile-time model.- Specified by:
getXmlNsin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getSchemaLocations
public Map<String,String> getSchemaLocations()
- Specified by:
getSchemaLocationsin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getElementFormDefault
public javax.xml.bind.annotation.XmlNsForm getElementFormDefault(String nsUri)
- Specified by:
getElementFormDefaultin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getAttributeFormDefault
public javax.xml.bind.annotation.XmlNsForm getAttributeFormDefault(String nsUri)
- Specified by:
getAttributeFormDefaultin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
dump
public void dump(Result out)
- Specified by:
dumpin interfaceTypeInfoSet<com.sun.tools.xjc.model.nav.NType,com.sun.tools.xjc.model.nav.NClass,Void,Void>
-
getPackage
public CClassInfoParent.Package getPackage(JPackage pkg)
-
-