SAXbuilder uses a third-party SAX parser (chosen by JAXP by default, or you can configure it manually) to handle the parsing duties and uses an instance of a SAXHandler to listen to the SAX events in order to construct a document with JDOM content using a JDOMFactory. Information about SAX can be found at http://www.saxproject.org.
For a complete description of how SAXBuilder is used, and how to customise
the process you should look at the org. package
documentation.
JDOM users needing to customise the SAX parsing process have traditionally
sub-classed this SAXBuilder class. In JDOM2 this should never be necessary.
Please read the full documentation of this class, SAXHandler,
SAXHandlerFactory, JDOMFactory, and the package documentation
for org. before overriding this class. Future versions
of JDOM2 may make this class 'final'. I you feel you have a good reason to
subclass SAXBuilder please mention it on jdom-interest mailing list
so that SAXBuilder can be extended or adapted to handle your use-case.
Neither SAXBuilder nor anything derived from SAXBuilder is thread-safe. You
must ensure that SAXBuilder is used in a single thread, or that sufficient
locking is in place to ensure that SAXBuilder is not concurrently accessed.
See the special note on buildEngine().
Known issues:
org.jdom2.input.sax
| Modifier and Type | Field and Description |
|---|---|
| private static final JDOMFactory | DEFAULTJDOMFAC
Default source of JDOM Content |
| private static final SAXHandlerFactory | DEFAULTSAXHANDLERFAC
Default source of SAXHandlers |
| private SAXEngine | engine
The current SAX parser, if parser reuse has been activated. |
| private final HashMap | features
User-specified features to be set on the SAX parser |
| private SAXHandlerFactory | handlerfac
The SAXHandler pillar of SAXBuilder |
| private boolean | ignoringBoundaryWhite
Whether to ignore all whitespace content |
| private boolean | ignoringWhite
Whether to ignore ignorable whitespace |
| private JDOMFactory | jdomfac
The JDOMFactory pillar for creating new JDOM objects |
| private final HashMap | properties
User-specified properties to be set on the SAX parser |
| private XMLReaderJDOMFactory | readerfac
The XMLReader pillar of SAXBuilder |
| private boolean | reuseParser
Whether parser reuse is allowed. |
| private DTDHandler | saxDTDHandler
DTDHandler class to use |
| private EntityResolver | saxEntityResolver
EntityResolver class to use |
| private ErrorHandler | saxErrorHandler
ErrorHandler class to use |
| private XMLFilter | saxXMLFilter
XMLFilter instance to use |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SAXBuilder(final boolean
boolean indicating if DTD validation should occur.
Deprecated
use
Creates a new JAXP-based SAXBuilder.
SAXBuilder#SAXBuilder(XMLReaderJDOMFactory) with
either XMLReaders#DTDVALIDATING
or XMLReaders#NONVALIDATING
|
| public | SAXBuilder(final String
String name of SAX Driver to use for parsing. |
| public | SAXBuilder(final String
String name of SAX Driver to use for parsing.boolean indicating if validation should occur. |
| public | SAXBuilder(final XMLReaderJDOMFactory
the readersouce)XMLReaderJDOMFactory that supplies XMLReaders. If the
value is null then a Non-Validating JAXP-based SAX2.0 parser will
be used.Creates a new SAXBuilder with the specified XMLReaderJDOMFactory. |
| public | SAXBuilder(final XMLReaderJDOMFactory
a xmlreaderfactory, final SAXHandlerFactory XMLReaderJDOMFactory that creates XMLReaders. Specify
null for the default.a handlerfactory, final JDOMFactory SAXHandlerFactory that creates SAXHandlers Specify null
for the default.a jdomfactory)JDOMFactory that creates JDOM Content. Specify null for
the default.Creates a new SAXBuilder. |
| Modifier and Type | Method and Description |
|---|---|
| public Document | Returns: Document resultant Document objectInputSource to read fromImplements org. |
| public Document | Returns: Document resultant Document objectInputStream to read fromImplements org. This builds a document from the supplied input stream. |
| public Document | Returns: Document resultant Document objectFile to read fromImplements org. This builds a document from the supplied filename. |
| public Document | Returns: Document - resultant Document object.URL to read from.Implements org. This builds a document from the supplied URL. |
| public Document | Returns: Document resultant Document objectInputStream to read from.base for resolving relative URIs systemId)Implements org. This builds a document from the supplied input stream. |
| public Document | Returns: Document resultant Document objectReader to read fromImplements org. This builds a document from the supplied Reader. |
| public Document | Returns: Document resultant Document objectReader to read from.base for resolving relative URIs systemId)Implements org. This builds a document from the supplied Reader. |
| public Document | Returns: Document resultant Document objectURI for the input systemId)Implements org. This builds a document from the supplied URI. |
| public SAXEngine | Returns: aSAXEngine representing the current state of the
current SAXBuilder settings.This method builds a new and reusable |
| protected void | configureParser(final XMLReader
the XMLReader to configure. parser, final SAXHandler The SAXHandler to use for the XMLReader contentHandler)This configures the XMLReader to be used for reading the XML document. |
| protected XMLReader | Returns: a XMLReader parser.Allow overriding classes access to the Parser before it is used in a SAXBuilderEngine. |
| public String | Returns: the driver class assigned in the constructor
Deprecated
as the driver class is only available in limited situations
and anyway it had to be supplied in a constructor as either a
direct value or as an
Returns the driver class assigned in the constructor, or null if none.
XMLReaderSAX2Factory instance.
|
| public DTDHandler | Returns: the DTDHandler assignedImplements org. DTDHandler assigned, or null if the assigned
SAXHandler will be used for DTD SAX events.
|
| private SAXEngine | Returns: aSAXBuilderEngine representing the current state of the
current SAXBuilder settings.This method retrieves (or builds) a SAXBuilderEngine that represents the current SAXBuilder state. |
| public EntityResolver | Returns: the EntityResolver assignedImplements org. EntityResolver assigned, or null if none.
|
| public ErrorHandler | Returns: the ErrorHandler assigned, or null if SAXBuilder will create a default ErrorHandler when needed.Implements org. ErrorHandler assigned, or null if none.
|
| public boolean | Returns: whether entities are being expandedImplements org. |
| public JDOMFactory | Returns: the factory in use
Deprecated
as it is replaced by
Returns the current getJDOMFactory()
org. in use.
|
| public boolean | Returns: boolean - whether only whitespace content will be
ignored during build.Implements org. |
| public boolean | Returns: whether element content whitespace is to be ignored during the buildImplements org. |
| public JDOMFactory | Returns: the factory in useImplements org. org. in use.
|
| public boolean | Returns: whether the contained SAX parser instance is reused across multiple parsesReturns whether the contained SAX parser instance is reused across multiple parses. |
| public SAXHandlerFactory | Returns: the current SAXHandlerFactory (never null).Get the SAXHandlerFactory used to supply SAXHandlers to this SAXBuilder. |
| public boolean | Returns: whether validation is to be performed during the build
Deprecated
in lieu of
Returns whether validation is to be performed during the build.
isValidating()
|
| public XMLFilter | Returns: the XMLFilter used during parsingReturns the |
| public XMLReaderJDOMFactory | |
| private void | internalSetFeature(final XMLReader parser, final String feature, final boolean value, final String displayName)
Tries to set a feature on the parser. |
| private void | internalSetProperty(final XMLReader parser, final String property, final Object value, final String displayName)
Tries to set a property on the parser. |
| public boolean | Returns: whether validation is to be performed during the buildImplements org. |
| public void | |
| public void | setEntityResolver(final EntityResolver
EntityResolverThis sets custom EntityResolver for the |
| public void | setErrorHandler(final ErrorHandler
ErrorHandlerThis sets custom ErrorHandler for the Builder. |
| public void | setExpandEntities(final boolean
boolean indicating whether entity expansion should
occur.This sets whether or not to expand entities for the builder. |
| public void | setFactory(final JDOMFactory
JDOMFactory to use
Deprecated
as it is replaced by
This sets a custom JDOMFactory for the builder.
setJDOMFactory(JDOMFactory)
|
| public void | setFastReconfigure(final boolean
Whether to do a fast reconfiguration of the parser fastReconfigure)
Deprecated
All reused Parsers are now fast-reconfigured. No need to set
it.
Specifies whether this builder will do fast reconfiguration of the
underlying SAX parser when reuseParser is true.
|
| public void | setFeature(final String
The feature name, which is a fully-qualified URI. name, final boolean The requested state of the feature (true or false). value)This sets a feature on the SAX parser. |
| public void | setIgnoringBoundaryWhitespace(final boolean
Whether to ignore whitespace-only text nodes ignoringBoundaryWhite)Specifies whether or not the parser should eliminate boundary whitespace, a term that indicates whitespace-only text between element tags. |
| public void | setIgnoringElementContentWhitespace(final boolean
Whether to ignore ignorable whitespace ignoringWhite)Specifies whether or not the parser should eliminate whitespace in element content (sometimes known as "ignorable whitespace") when building the document. |
| public void | setJDOMFactory(final JDOMFactory
JDOMFactory to useThis sets a custom JDOMFactory for the builder. |
| public void | setProperty(final String
The property name, which is a fully-qualified URI. name, final Object The requested value for the property. value)This sets a property on the SAX parser. |
| public void | setReuseParser(final boolean
Whether to reuse the SAX parser. reuseParser)Specifies whether this builder will reuse the same SAX parser when performing subsequent parses or allocate a new parser for each parse. |
| public void | setSAXHandlerFactory(final SAXHandlerFactory
the required SAXHandlerFactory. A null input factory will request
the factory)DefaultSAXHandlerFactory.Set the SAXHandlerFactory to be used by this SAXBuilder. |
| public void | setValidation(final boolean
boolean indicating whether validation should occur.
Deprecated
use
This sets validation for the builder.
setXMLReaderFactory(XMLReaderJDOMFactory)
|
| public void | setXMLFilter(final XMLFilter
the XMLFilter to use xmlFilter)This sets a custom |
| public void | setXMLReaderFactory(final XMLReaderJDOMFactory
the JDOMXMLReaderFactory to set. A null rfac will indicate the
default rfac)XMLReaders#NONVALIDATINGSet the current XMLReader factory. |