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

public final Class ModelLoader

extends Object
Class Inheritance
Imports
com.sun.codemodel.JCodeModel, com.sun.tools.rngom.ast.builder.SchemaBuilder, com.sun.tools.rngom.ast.util.CheckingSchemaBuilder, com.sun.tools.rngom.digested.DPattern, .DSchemaBuilderImpl, com.sun.tools.rngom.parse.IllegalSchemaException, .Parseable, com.sun.tools.rngom.parse.compact.CompactParseable, com.sun.tools.rngom.parse.xml.SAXParseable, com.sun.tools.rngom.xml.sax.XMLReaderCreator, com.sun.tools.xjc.model.Model, com.sun.tools.xjc.reader.Const, .ExtensionBindingChecker, com.sun.tools.xjc.reader.dtd.TDTDReader, com.sun.tools.xjc.reader.internalizer.DOMForest, .DOMForestScanner, .InternalizationLogic, .SCDBasedBindingSet, .VersionChecker, com.sun.tools.xjc.reader.relaxng.RELAXNGCompiler, .RELAXNGInternalizationLogic, com.sun.tools.xjc.reader.xmlschema.BGMBuilder, com.sun.tools.xjc.reader.xmlschema.bindinfo.AnnotationParserFactoryImpl, com.sun.tools.xjc.reader.xmlschema.parser.CustomizationContextChecker, .IncorrectNamespaceURIChecker, .SchemaConstraintChecker, .XMLSchemaInternalizationLogic, com.sun.tools.xjc.util.ErrorReceiverFilter, com.sun.xml.xsom.XSSchemaSet, com.sun.xml.xsom.parser.JAXPParser, .XMLParser, .XSOMParser, org.glassfish.jaxb.core.v2.util.XmlFactory, org.w3c.dom.Document, .Element, .NodeList, org.xml.sax.Attributes, .ContentHandler, .EntityResolver, .ErrorHandler, .InputSource, .SAXException, .SAXParseException, .XMLFilter, .XMLReader, org.xml.sax.helpers.XMLFilterImpl, javax.xml.XMLConstants, java.io.IOException, .StringReader

Builds a Model object. This is an utility class that makes it easy to load a grammar object from various sources.
Author
Kohsuke Kawaguchi ([email protected])

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private class
ModelLoader.XMLSchemaParser

XMLParser implementation that adds additional processors into the chain.

Field Summary

Modifier and TypeField and Description
private final JCodeModel
private final ErrorReceiverFilter
private final Options
private SCDBasedBindingSet

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Model

Returns:

null if an error happens. In that case, the error messages will be properly reported to the controller by this method.
annotateXMLSchema
(XSSchemaSet xs)

Annotates the obtained schema set.

public DOMForest
buildDOMForest(InternalizationLogic logic)

Builds DOMForest and performs the internalization.

private void
public XSSchemaSet

Returns:

null if the parsing failed.
createXSOM
(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet)

Parses a DOMForest into a XSSchemaSet.

public XSOMParser
createXSOMParser(XMLParser parser)

Potentially problematic - make sure the parser instance passed is initialized with proper security feature.

public XSOMParser
private XSSchemaSet
createXSOMSpeculative()

Parses schemas directly into XSOM by assuming that there's no external annotations.

private String
public static Model
load(Options opt, JCodeModel codeModel, ErrorReceiver er)

A convenience method to load schemas into a Model.

private Model
load()

private Model
loadDTD(InputSource
DTD file
source
,
InputSource
External binding file.
bindFile
)

Parses a DTD file into an annotated grammar.

private Model
loadRELAXNG()

Parses a RELAX NG grammar into an annotated grammar.

private Model
loadRELAXNG(Parseable p)

Common part between the XML syntax and the compact syntax.

private Model
loadRELAXNGCompact()

Loads RELAX NG compact syntax

private XSSchemaSet
loadWSDL()

Parses a set of schemas inside a WSDL file.

public XSSchemaSet
loadXMLSchema()

Parses a set of XML Schema files into an annotated grammar.

private boolean
sanityCheck()

Do some extra checking and return false if the compilation should abort.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

codeModelback to summary
private final JCodeModel codeModel
errorReceiverback to summary
private final ErrorReceiverFilter errorReceiver
optback to summary
private final Options opt
scdBasedBindingSetback to summary
private SCDBasedBindingSet scdBasedBindingSet

DOMForest#transform(boolean) creates this on the side.

Constructor Detail

ModelLoaderback to summary
public ModelLoader(Options _opt, JCodeModel _codeModel, ErrorReceiver er)

Method Detail

annotateXMLSchemaback to summary
public Model annotateXMLSchema(XSSchemaSet xs)

Annotates the obtained schema set.

Returns:Model

null if an error happens. In that case, the error messages will be properly reported to the controller by this method.

buildDOMForestback to summary
public DOMForest buildDOMForest(InternalizationLogic logic) throws SAXException

Builds DOMForest and performs the internalization.

Exceptions
SAXException:
when a fatal error happens
checkTooManySchemaErrorsback to summary
private void checkTooManySchemaErrors()
createXSOMback to summary
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException

Parses a DOMForest into a XSSchemaSet.

Returns:XSSchemaSet

null if the parsing failed.

createXSOMParserback to summary
public XSOMParser createXSOMParser(XMLParser parser)

Potentially problematic - make sure the parser instance passed is initialized with proper security feature.

createXSOMParserback to summary
public XSOMParser createXSOMParser(final DOMForest forest)
createXSOMSpeculativeback to summary
private XSSchemaSet createXSOMSpeculative() throws SAXException, SpeculationFailure

Parses schemas directly into XSOM by assuming that there's no external annotations.

When an external annotation is found, a SpeculationFailure is thrown, and we will do it all over again by using the slow way.

fixNullback to summary
private String fixNull(String s)
loadback to summary
public static Model load(Options opt, JCodeModel codeModel, ErrorReceiver er)

A convenience method to load schemas into a Model.

loadback to summary
private Model load()
loadDTDback to summary
private Model loadDTD(InputSource source, InputSource bindFile)

Parses a DTD file into an annotated grammar.

Parameters
source:InputSource

DTD file

bindFile:InputSource

External binding file.

loadRELAXNGback to summary
private Model loadRELAXNG() throws SAXException

Parses a RELAX NG grammar into an annotated grammar.

loadRELAXNGback to summary
private Model loadRELAXNG(Parseable p)

Common part between the XML syntax and the compact syntax.

loadRELAXNGCompactback to summary
private Model loadRELAXNGCompact()

Loads RELAX NG compact syntax

loadWSDLback to summary
private XSSchemaSet loadWSDL() throws SAXException

Parses a set of schemas inside a WSDL file. A WSDL file may contain multiple <xsd:schema> elements.

loadXMLSchemaback to summary
public XSSchemaSet loadXMLSchema() throws SAXException

Parses a set of XML Schema files into an annotated grammar.

sanityCheckback to summary
private boolean sanityCheck()

Do some extra checking and return false if the compilation should abort.

com.sun.tools.xjc back to summary

private final Class ModelLoader.SpeculationChecker

extends XMLFilterImpl
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
startElement(String uri, String localName, String qName, Attributes attributes)

Overrides org.xml.sax.helpers.XMLFilterImpl.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Filter a start element event.

Inherited from org.xml.sax.helpers.XMLFilterImpl:
charactersendDocumentendElementendPrefixMappingerrorfatalErrorgetContentHandlergetDTDHandlergetEntityResolvergetErrorHandlergetFeaturegetParentgetPropertyignorableWhitespacenotationDeclparseparseprocessingInstructionresolveEntitysetContentHandlersetDocumentLocatorsetDTDHandlersetEntityResolversetErrorHandlersetFeaturesetParentsetPropertyskippedEntitystartDocumentstartPrefixMappingunparsedEntityDeclwarning

Constructor Detail

SpeculationCheckerback to summary
private SpeculationChecker()

Method Detail

startElementback to summary
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException

Overrides org.xml.sax.helpers.XMLFilterImpl.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Doc from org.xml.sax.helpers.XMLFilterImpl.startElement.

Filter a start element event.

Annotations
@Override
Exceptions
SAXException:
The client may throw an exception during processing.
com.sun.tools.xjc back to summary

private final Class ModelLoader.SpeculationFailure

extends Error
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
private

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Error.serialVersionUID.

Constructor Detail

SpeculationFailureback to summary
private SpeculationFailure()
com.sun.tools.xjc back to summary

private Class ModelLoader.XMLSchemaParser

extends Object
implements XMLParser
Class Inheritance
All Implemented Interfaces
com.sun.xml.xsom.parser.XMLParser

XMLParser implementation that adds additional processors into the chain.

This parser will parse a DOM forest as: DOMForestParser --> ExtensionBindingChecker --> ProhibitedFeatureFilter --> XSOMParser

Field Summary

Modifier and TypeField and Description
private final XMLParser

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
parse(InputSource source, ContentHandler handler, ErrorHandler errorHandler, EntityResolver entityResolver)

Implements com.sun.xml.xsom.parser.XMLParser.parse.

Parses the document identified by the given input source and sends SAX events to the given content handler.

private ContentHandler
wrapBy(XMLFilterImpl filter, ContentHandler handler)

Wraps the specified content handler by a filter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseParserback to summary
private final XMLParser baseParser

Constructor Detail

XMLSchemaParserback to summary
private XMLSchemaParser(XMLParser baseParser)

Method Detail

parseback to summary
public void parse(InputSource source, ContentHandler handler, ErrorHandler errorHandler, EntityResolver entityResolver) throws SAXException, IOException

Implements com.sun.xml.xsom.parser.XMLParser.parse.

Doc from com.sun.xml.xsom.parser.XMLParser.parse.

Parses the document identified by the given input source and sends SAX events to the given content handler.

This method must be re-entrant.

Annotations
@Override
Exceptions
SAXException:
If ErrorHandler throws a SAXException, this method will tunnel it to the caller. All the other errors must be reported to the error handler.
wrapByback to summary
private ContentHandler wrapBy(XMLFilterImpl filter, ContentHandler handler)

Wraps the specified content handler by a filter. It is little awkward to use a helper implementation class like XMLFilterImpl as the method parameter, but this simplifies the code.