Class SchemaCompilerImpl
- All Implemented Interfaces:
ErrorListener,SchemaCompiler,com.sun.xml.bind.api.ErrorListener,ErrorHandler
SchemaCompiler implementation.
This class builds a DOMForest until the bind() method,
then this method does the rest of the hard work.- Author:
- Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.sun.tools.xjc.api.impl.s2j.JAXBModelImplbind()Obtains the compiled schema object model.voiderror(SAXParseException exception) voidfatalError(SAXParseException exception) voidforcePackageName(String packageName) Forces all the JAXB-generated classes to go into the specific package.Allows the calling code to tweak more schema compilation details.getParserHandler(String systemId) Parses schemas or external bindings through SAX events by feeding events into SAXContentHandler.voidinfo(SAXParseException exception) Reports verbose messages to users.voidparseSchema(String systemId, XMLStreamReader reader) Parses a schema or an external binding file from the given source.voidparseSchema(String systemId, Element element) Parses a schema or an external binding file from the specified DOM element.voidparseSchema(InputSource source) Parses a schema or an external binding file from an external source.voidClears all the schema files parsed so far.voidsetClassNameAllocator(ClassNameAllocator allocator) Sets theClassNameAllocatorto be used for the binding operation.voidsetDefaultPackageName(String packageName) Sets the default Java package name into which the generated code will be placed.voidsetEntityResolver(EntityResolver entityResolver) voidsetErrorListener(ErrorListener errorListener) voidsetTargetVersion(SpecVersion version) Specifies the target spec version for this compilaion.voidwarning(SAXParseException exception) Methods inherited from class com.sun.tools.xjc.ErrorReceiver
debug, error, error, error, error, getLocationString, pollAbort, warning
-
Field Details
-
opts
-
forest
-
-
Constructor Details
-
SchemaCompilerImpl
public SchemaCompilerImpl()
-
-
Method Details
-
getOptions
Description copied from interface:SchemaCompilerAllows the calling code to tweak more schema compilation details.The caller can use this method to obtain an
Optionsinstance, then tweak settings on it. The updated settings will be used when theSchemaCompiler.bind()method is invoked.The returned
Optionsobject is useful for example to specify command-line arguments.- Specified by:
getOptionsin interfaceSchemaCompiler
-
getParserHandler
Description copied from interface:SchemaCompilerParses schemas or external bindings through SAX events by feeding events into SAXContentHandler.- Specified by:
getParserHandlerin interfaceSchemaCompiler- Parameters:
systemId- The system ID of the document to be read in.- See Also:
-
parseSchema
Description copied from interface:SchemaCompilerParses a schema or an external binding file from the specified DOM element.The given DOM element is treated as if it's the root of a virtual document.
XJC will not be able to print location information for errors found in this document, since DOM doesn't have them. For this reason, use of this method is strongly discouraged.
- Specified by:
parseSchemain interfaceSchemaCompiler- Parameters:
systemId- We need an absolute system ID that uniquely designates the virtual document. This should be different from the system ID of the document which contains this element.One way to do that is by adding a fragment identifier to the system ID of the document. For example, if the document is "foo.wsdl" and you are passing in its types section, you can use an unique identifier like "foo.wsdl#types"
-
parseSchema
Description copied from interface:SchemaCompilerParses a schema or an external binding file from an external source.- Specified by:
parseSchemain interfaceSchemaCompiler- Parameters:
source- Its system Id must be set to an absolute URI.
-
setTargetVersion
Description copied from interface:SchemaCompilerSpecifies the target spec version for this compilaion.- Specified by:
setTargetVersionin interfaceSchemaCompiler- Parameters:
version- If null, XJC will generate the source code that takes advantage of the latest JAXB spec that it understands.
-
parseSchema
Description copied from interface:SchemaCompilerParses a schema or an external binding file from the given source.A stream reader must be pointing at the element or at the start of the document. XML is parsed until the corresponding end tag, then the sub tree is processed as a schema document.
When this method returns successfully, the parser is at the next token of the end element.
- Specified by:
parseSchemain interfaceSchemaCompiler- Parameters:
systemId- The absolute system ID of the document that is being parsed. This information is necessary to avoid double-inclusion and etc. Note thatXMLStreamReader.getLocation()only returns the system ID of the entity it is parsing, not necessarily the system ID of the document itself.- Throws:
XMLStreamException- If an error happens while parsing a document. Note that not only the parser but also the XJC itself may throw this error (as a result of the additional validation for example.)
-
setEntityResolver
- Specified by:
setEntityResolverin interfaceSchemaCompiler
-
setDefaultPackageName
Description copied from interface:SchemaCompilerSets the default Java package name into which the generated code will be placed.Customizations in the binding files/schemas will have precedence over this setting. Set to null to use the default package name computation algorithm as specified by the JAXB spec (which is the default behavior.)
Initially this parameter is set to null.
- Specified by:
setDefaultPackageNamein interfaceSchemaCompiler- Parameters:
packageName- Java pckage name such as "org.foo.bar". Use "" to represent the root package, and null to defer to the default computation algorithm.- See Also:
-
forcePackageName
Description copied from interface:SchemaCompilerForces all the JAXB-generated classes to go into the specific package.This setting takes precedence over the
SchemaCompiler.setDefaultPackageName(String)or any of the customization found in the JAXB binding files. This method is designed to implement the semantics of the command-line '-p' option.This somewhat ugly semantics actually have a long history now and too late to change.
- Specified by:
forcePackageNamein interfaceSchemaCompiler- See Also:
-
setClassNameAllocator
Description copied from interface:SchemaCompilerSets theClassNameAllocatorto be used for the binding operation.This mechanism would allow the caller to participate in the binding operation.
- Specified by:
setClassNameAllocatorin interfaceSchemaCompiler- See Also:
-
resetSchema
public void resetSchema()Description copied from interface:SchemaCompilerClears all the schema files parsed so far.- Specified by:
resetSchemain interfaceSchemaCompiler
-
bind
public com.sun.tools.xjc.api.impl.s2j.JAXBModelImpl bind()Description copied from interface:SchemaCompilerObtains the compiled schema object model. Once this method is called, no other method should be invoked on theSchemaCompiler.- Specified by:
bindin interfaceSchemaCompiler- Returns:
- null if the compilation fails. The errors should have been delivered to the registered error handler in such a case.
-
setErrorListener
- Specified by:
setErrorListenerin interfaceSchemaCompiler
-
info
Description copied from class:ErrorReceiverReports verbose messages to users. This method can be used to report additional non-essential messages. The implementation usually discards them unless some specific debug option is turned on.- Specified by:
infoin interfaceErrorListener- Specified by:
infoin interfacecom.sun.xml.bind.api.ErrorListener- Specified by:
infoin classErrorReceiver
-
warning
- Specified by:
warningin interfaceErrorHandler- Specified by:
warningin interfaceErrorListener- Specified by:
warningin interfacecom.sun.xml.bind.api.ErrorListener- Specified by:
warningin classErrorReceiver
-
error
- Specified by:
errorin interfaceErrorHandler- Specified by:
errorin interfaceErrorListener- Specified by:
errorin interfacecom.sun.xml.bind.api.ErrorListener- Specified by:
errorin classErrorReceiver
-
fatalError
- Specified by:
fatalErrorin interfaceErrorHandler- Specified by:
fatalErrorin interfaceErrorListener- Specified by:
fatalErrorin interfacecom.sun.xml.bind.api.ErrorListener- Specified by:
fatalErrorin classErrorReceiver
-