Top Description Fields Constructors Methods
com.sun.tools.xjc.api.impl.s2j

public final Class SchemaCompilerImpl

extends ErrorReceiver
implements SchemaCompiler
Class Inheritance
All Implemented Interfaces
com.sun.tools.xjc.api.SchemaCompiler
Imports
java.io.IOException, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, javax.xml.XMLConstants, javax.xml.stream.XMLStreamException, .XMLStreamReader, javax.xml.validation.SchemaFactory, com.sun.codemodel.JCodeModel, com.sun.istack.NotNull, .SAXParseException2, com.sun.tools.xjc.ErrorReceiver, .ModelLoader, .Options, com.sun.tools.xjc.api.ClassNameAllocator, .ErrorListener, .SchemaCompiler, .SpecVersion, com.sun.tools.xjc.model.Model, com.sun.tools.xjc.outline.Outline, com.sun.tools.xjc.reader.internalizer.DOMForest, .SCDBasedBindingSet, com.sun.tools.xjc.reader.xmlschema.parser.LSInputSAXWrapper, .XMLSchemaInternalizationLogic, org.glassfish.jaxb.core.unmarshaller.DOMScanner, org.glassfish.jaxb.core.v2.util.XmlFactory, com.sun.xml.xsom.XSSchemaSet, org.w3c.dom.Element, org.w3c.dom.ls.LSInput, .LSResourceResolver, org.xml.sax.ContentHandler, .EntityResolver, .InputSource, .SAXException, .SAXParseException, org.xml.sax.helpers.LocatorImpl

SchemaCompiler implementation. This class builds a DOMForest until the bind() method, then this method does the rest of the hard work.
Author
Kohsuke Kawaguchi ([email protected])
See Also
ModelLoader

Field Summary

Modifier and TypeField and Description
private ErrorListener
errorListener

User-specified error receiver.

protected DOMForest
private boolean
hadError

Set to true once an error is found.

private static boolean
NO_CORRECTNESS_CHECK

We use JAXP 1.3 to do a schema correctness check, but we know it doesn't always work.

protected final Options

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public JAXBModelImpl
bind()

Implements com.sun.tools.xjc.api.SchemaCompiler.bind.

Obtains the compiled schema object model.

private void
checkAbsoluteness(String systemId)

Checks if the system ID is absolute.

public void
error(SAXParseException exception)

Implements abstract com.sun.tools.xjc.ErrorReceiver.error.

Implements org.xml.sax.ErrorHandler.error, com.sun.tools.xjc.api.ErrorListener.error.

Receive notification of a recoverable error.

public void
fatalError(SAXParseException exception)

Implements abstract com.sun.tools.xjc.ErrorReceiver.fatalError.

Implements org.xml.sax.ErrorHandler.fatalError, com.sun.tools.xjc.api.ErrorListener.fatalError.

Receive notification of a non-recoverable, fatal error.

public void
forcePackageName(String packageName)

Implements com.sun.tools.xjc.api.SchemaCompiler.forcePackageName.

Forces all the JAXB-generated classes to go into the specific package.

public Options
getOptions()

Implements com.sun.tools.xjc.api.SchemaCompiler.getOptions.

Allows the calling code to tweak more schema compilation details.

public ContentHandler
getParserHandler(String systemId)

Implements com.sun.tools.xjc.api.SchemaCompiler.getParserHandler.

Parses schemas or external bindings through SAX events by feeding events into SAX ContentHandler.

public void
info(SAXParseException exception)

Implements abstract com.sun.tools.xjc.ErrorReceiver.info.

Implements com.sun.tools.xjc.api.ErrorListener.info.

Reports verbose messages to users.

public void
parseSchema(String systemId, Element element)

Implements com.sun.tools.xjc.api.SchemaCompiler.parseSchema.

Parses a schema or an external binding file from the specified DOM element.

public void
parseSchema(InputSource source)

Implements com.sun.tools.xjc.api.SchemaCompiler.parseSchema.

Parses a schema or an external binding file from an external source.

public void
parseSchema(String systemId, XMLStreamReader reader)

Implements com.sun.tools.xjc.api.SchemaCompiler.parseSchema.

Parses a schema or an external binding file from the given source.

public void
resetSchema()

Implements com.sun.tools.xjc.api.SchemaCompiler.resetSchema.

Clears all the schema files parsed so far.

public void
public void
setDefaultPackageName(String packageName)

Implements com.sun.tools.xjc.api.SchemaCompiler.setDefaultPackageName.

Sets the default Java package name into which the generated code will be placed.

public void
public void
public void
setTargetVersion(SpecVersion version)

Implements com.sun.tools.xjc.api.SchemaCompiler.setTargetVersion.

Specifies the target spec version for this compilaion.

public void
Inherited from com.sun.tools.xjc.ErrorReceiver:
debugerrorerrorerrorerrorgetLocationStringpollAbortwarning

Field Detail

errorListenerback to summary
private ErrorListener errorListener

User-specified error receiver. This field can be null, in which case errors need to be discarded.

forestback to summary
protected DOMForest forest
Annotations
@NotNull
hadErrorback to summary
private boolean hadError

Set to true once an error is found.

NO_CORRECTNESS_CHECKback to summary
private static boolean NO_CORRECTNESS_CHECK

We use JAXP 1.3 to do a schema correctness check, but we know it doesn't always work. So in case some people hit the problem, this switch is here so that they can turn it off as a workaround.

optsback to summary
protected final Options opts

Constructor Detail

SchemaCompilerImplback to summary
public SchemaCompilerImpl()

Method Detail

bindback to summary
public JAXBModelImpl bind()

Implements com.sun.tools.xjc.api.SchemaCompiler.bind.

Doc from com.sun.tools.xjc.api.SchemaCompiler.bind.

Obtains the compiled schema object model. Once this method is called, no other method should be invoked on the .

Annotations
@Override
checkAbsolutenessback to summary
private void checkAbsoluteness(String systemId)

Checks if the system ID is absolute.

Annotations
@SuppressWarnings:ResultOfObjectAllocationIgnored
errorback to summary
public void error(SAXParseException exception)

Implements abstract com.sun.tools.xjc.ErrorReceiver.error.

Implements org.xml.sax.ErrorHandler.error, com.sun.tools.xjc.api.ErrorListener.error.

Doc from org.xml.sax.ErrorHandler.error.

Receive notification of a recoverable error.

This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML recommendation does not require it to do so.

Filters may use this method to report other, non-XML errors as well.

Annotations
@Override
fatalErrorback to summary
public void fatalError(SAXParseException exception)

Implements abstract com.sun.tools.xjc.ErrorReceiver.fatalError.

Implements org.xml.sax.ErrorHandler.fatalError, com.sun.tools.xjc.api.ErrorListener.fatalError.

Doc from org.xml.sax.ErrorHandler.fatalError.

Receive notification of a non-recoverable, fatal error.

As defined in section 1.2 of the W3C XML 1.0 Recommendation, fatal errors are those that would make it impossible for a parser to continue normal processing. These include violation of a well-formedness constraint, invalid encoding, and forbidden structural errors as described in the W3C XML 1.0 Recommendation.

Annotations
@Override
forcePackageNameback to summary
public void forcePackageName(String packageName)

Implements com.sun.tools.xjc.api.SchemaCompiler.forcePackageName.

Doc from com.sun.tools.xjc.api.SchemaCompiler.forcePackageName.

Forces all the JAXB-generated classes to go into the specific package.

This setting takes precedence over the 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.

Annotations
@Override
getOptionsback to summary
public Options getOptions()

Implements com.sun.tools.xjc.api.SchemaCompiler.getOptions.

Doc from com.sun.tools.xjc.api.SchemaCompiler.getOptions.

Allows the calling code to tweak more schema compilation details.

The caller can use this method to obtain an Options instance, then tweak settings on it. The updated settings will be used when the bind() method is invoked.

The returned Options object is useful for example to specify command-line arguments.

Annotations
@NotNull
@Override
@SuppressWarnings:deprecation
getParserHandlerback to summary
public ContentHandler getParserHandler(String systemId)

Implements com.sun.tools.xjc.api.SchemaCompiler.getParserHandler.

Doc from com.sun.tools.xjc.api.SchemaCompiler.getParserHandler.

Parses schemas or external bindings through SAX events by feeding events into SAX ContentHandler.

Annotations
@Override
infoback to summary
public void info(SAXParseException exception)

Implements abstract com.sun.tools.xjc.ErrorReceiver.info.

Implements com.sun.tools.xjc.api.ErrorListener.info.

Doc from com.sun.tools.xjc.ErrorReceiver.info.

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

Annotations
@Override
parseSchemaback to summary
public void parseSchema(String systemId, Element element)

Implements com.sun.tools.xjc.api.SchemaCompiler.parseSchema.

Doc from com.sun.tools.xjc.api.SchemaCompiler.parseSchema.

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

Annotations
@Override
parseSchemaback to summary
public void parseSchema(InputSource source)

Implements com.sun.tools.xjc.api.SchemaCompiler.parseSchema.

Doc from com.sun.tools.xjc.api.SchemaCompiler.parseSchema.

Parses a schema or an external binding file from an external source.

Annotations
@Override
parseSchemaback to summary
public void parseSchema(String systemId, XMLStreamReader reader) throws XMLStreamException

Implements com.sun.tools.xjc.api.SchemaCompiler.parseSchema.

Doc from com.sun.tools.xjc.api.SchemaCompiler.parseSchema.

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

Annotations
@Override
Exceptions
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.)
resetSchemaback to summary
public void resetSchema()

Implements com.sun.tools.xjc.api.SchemaCompiler.resetSchema.

Doc from com.sun.tools.xjc.api.SchemaCompiler.resetSchema.

Clears all the schema files parsed so far.

Annotations
@Override
setClassNameAllocatorback to summary
public void setClassNameAllocator(ClassNameAllocator allocator)

Implements com.sun.tools.xjc.api.SchemaCompiler.setClassNameAllocator.

Doc from com.sun.tools.xjc.api.SchemaCompiler.setClassNameAllocator.

Sets the ClassNameAllocator to be used for the binding operation.

This mechanism would allow the caller to participate in the binding operation.

Annotations
@Override
setDefaultPackageNameback to summary
public void setDefaultPackageName(String packageName)

Implements com.sun.tools.xjc.api.SchemaCompiler.setDefaultPackageName.

Doc from com.sun.tools.xjc.api.SchemaCompiler.setDefaultPackageName.

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

Annotations
@Override
setEntityResolverback to summary
public void setEntityResolver(EntityResolver entityResolver)

Implements com.sun.tools.xjc.api.SchemaCompiler.setEntityResolver.

Annotations
@Override
setErrorListenerback to summary
public void setErrorListener(ErrorListener errorListener)

Implements com.sun.tools.xjc.api.SchemaCompiler.setErrorListener.

Annotations
@Override
setTargetVersionback to summary
public void setTargetVersion(SpecVersion version)

Implements com.sun.tools.xjc.api.SchemaCompiler.setTargetVersion.

Doc from com.sun.tools.xjc.api.SchemaCompiler.setTargetVersion.

Specifies the target spec version for this compilaion.

Annotations
@Override
warningback to summary
public void warning(SAXParseException exception)

Implements abstract com.sun.tools.xjc.ErrorReceiver.warning.

Implements org.xml.sax.ErrorHandler.warning, com.sun.tools.xjc.api.ErrorListener.warning.

Doc from org.xml.sax.ErrorHandler.warning.

Receive notification of a warning.

SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML recommendation. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.

Filters may use this method to report other, non-XML warnings as well.

Annotations
@Override