Class SAXBuilderEngine
- java.lang.Object
-
- org.jdom.input.sax.SAXBuilderEngine
-
- All Implemented Interfaces:
SAXEngine
public class SAXBuilderEngine extends Object implements SAXEngine
Builds a JDOM document from files, streams, readers, URLs, or a SAXInputSourceinstance using a SAX parser. This Engine is built by the SAXBuilder based on the state of the SAXBuilder when the engine was produced. It is not possible to reconfigure the engine once built, but it can be reused many times (though not concurrently). This makes it the fastest way to process many multitudes of XML documents (if those documents are all parsed the same way). If you want to process in multiple threads you can safely have one SAXBuilderEngine in each thread on the condition that:- The JDOMFactory is thread-safe (the JDOM-supplied JDOMFactories are)
- There is no XMLFilter given to the SAXBuilder, or, if there is, then it is thread-safe.
- If you have a custom
XMLReaderJDOMFactorythat it supplies a new instance of an XMLReader on each call (the JDOM-supplied ones all do). - If you have a custom
SAXHandlerFactorythat it supplies a new instance of a SAXHanfler on each call (the JDOM-supplied one does)
- See Also:
org.jdom.input.sax
-
-
Constructor Summary
Constructors Constructor Description SAXBuilderEngine(XMLReader reader, SAXHandler handler, boolean validating)Creates a new SAXBuilderEngine.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Documentbuild(File file)This builds a document from the supplied filename.Documentbuild(InputStream in)This builds a document from the supplied input stream.Documentbuild(InputStream in, String systemId)This builds a document from the supplied input stream.Documentbuild(Reader characterStream)This builds a document from the supplied Reader.Documentbuild(Reader characterStream, String systemId)This builds a document from the supplied Reader.Documentbuild(String systemId)This builds a document from the supplied URI.Documentbuild(URL url)This builds a document from the supplied URL.Documentbuild(InputSource in)This builds a document from the supplied input source.DTDHandlergetDTDHandler()Returns theDTDHandlerassigned, or null if none.EntityResolvergetEntityResolver()Returns theEntityResolverassigned, or null if none.ErrorHandlergetErrorHandler()Returns theErrorHandlerassigned, or null if none.booleangetExpandEntities()Returns whether or not entities are being expanded into normal text content.booleangetIgnoringBoundaryWhitespace()Returns whether or not the parser will elminate element content containing only whitespace.booleangetIgnoringElementContentWhitespace()Returns whether element content whitespace is to be ignored during the build.JDOMFactorygetJDOMFactory()Returns the currentJDOMFactoryin use.booleanisValidating()Returns whether validation is to be performed during the build.
-
-
-
Constructor Detail
-
SAXBuilderEngine
public SAXBuilderEngine(XMLReader reader, SAXHandler handler, boolean validating)
Creates a new SAXBuilderEngine.- Parameters:
reader- The XMLReader this Engine parses withhandler- The SAXHandler that processes the SAX Events.validating- True if this is a validating system.
-
-
Method Detail
-
getJDOMFactory
public JDOMFactory getJDOMFactory()
Description copied from interface:SAXEngineReturns the currentJDOMFactoryin use.- Specified by:
getJDOMFactoryin interfaceSAXEngine- Returns:
- the factory in use
-
isValidating
public boolean isValidating()
Description copied from interface:SAXEngineReturns whether validation is to be performed during the build.- Specified by:
isValidatingin interfaceSAXEngine- Returns:
- whether validation is to be performed during the build
-
getErrorHandler
public ErrorHandler getErrorHandler()
Description copied from interface:SAXEngineReturns theErrorHandlerassigned, or null if none.- Specified by:
getErrorHandlerin interfaceSAXEngine- Returns:
- the ErrorHandler assigned, or null if none
-
getEntityResolver
public EntityResolver getEntityResolver()
Description copied from interface:SAXEngineReturns theEntityResolverassigned, or null if none.- Specified by:
getEntityResolverin interfaceSAXEngine- Returns:
- the EntityResolver assigned
-
getDTDHandler
public DTDHandler getDTDHandler()
Description copied from interface:SAXEngineReturns theDTDHandlerassigned, or null if none.- Specified by:
getDTDHandlerin interfaceSAXEngine- Returns:
- the DTDHandler assigned
-
getIgnoringElementContentWhitespace
public boolean getIgnoringElementContentWhitespace()
Description copied from interface:SAXEngineReturns whether element content whitespace is to be ignored during the build.- Specified by:
getIgnoringElementContentWhitespacein interfaceSAXEngine- Returns:
- whether element content whitespace is to be ignored during the build
-
getIgnoringBoundaryWhitespace
public boolean getIgnoringBoundaryWhitespace()
Description copied from interface:SAXEngineReturns whether or not the parser will elminate element content containing only whitespace.- Specified by:
getIgnoringBoundaryWhitespacein interfaceSAXEngine- Returns:
boolean- whether only whitespace content will be ignored during build.
-
getExpandEntities
public boolean getExpandEntities()
Description copied from interface:SAXEngineReturns whether or not entities are being expanded into normal text content.- Specified by:
getExpandEntitiesin interfaceSAXEngine- Returns:
- whether entities are being expanded
-
build
public Document build(InputSource in) throws JDOMException, IOException
Description copied from interface:SAXEngineThis builds a document from the supplied input source.- Specified by:
buildin interfaceSAXEngine- Parameters:
in-InputSourceto read from- Returns:
Documentresultant Document object- Throws:
JDOMException- when errors occur in parsingIOException- when an I/O error prevents a document from being fully parsed
-
build
public Document build(InputStream in) throws JDOMException, IOException
Description copied from interface:SAXEngineThis builds a document from the supplied input stream.
- Specified by:
buildin interfaceSAXEngine- Parameters:
in-InputStreamto read from- Returns:
Documentresultant Document object- Throws:
JDOMException- when errors occur in parsingIOException- when an I/O error prevents a document from being fully parsed.
-
build
public Document build(File file) throws JDOMException, IOException
Description copied from interface:SAXEngineThis builds a document from the supplied filename.
- Specified by:
buildin interfaceSAXEngine- Parameters:
file-Fileto read from- Returns:
Documentresultant Document object- Throws:
JDOMException- when errors occur in parsingIOException- when an I/O error prevents a document from being fully parsed
-
build
public Document build(URL url) throws JDOMException, IOException
Description copied from interface:SAXEngineThis builds a document from the supplied URL.
- Specified by:
buildin interfaceSAXEngine- Parameters:
url-URLto read from.- Returns:
Document- resultant Document object.- Throws:
JDOMException- when errors occur in parsingIOException- when an I/O error prevents a document from being fully parsed.
-
build
public Document build(InputStream in, String systemId) throws JDOMException, IOException
Description copied from interface:SAXEngineThis builds a document from the supplied input stream.
- Specified by:
buildin interfaceSAXEngine- Parameters:
in-InputStreamto read from.systemId- base for resolving relative URIs- Returns:
Documentresultant Document object- Throws:
JDOMException- when errors occur in parsingIOException- when an I/O error prevents a document from being fully parsed
-
build
public Document build(Reader characterStream) throws JDOMException, IOException
Description copied from interface:SAXEngineThis builds a document from the supplied Reader. It's the programmer's responsibility to make sure the reader matches the encoding of the file. It's often easier and safer to use an InputStream rather than a Reader, and to let the parser auto-detect the encoding from the XML declaration.
- Specified by:
buildin interfaceSAXEngine- Parameters:
characterStream-Readerto read from- Returns:
Documentresultant Document object- Throws:
JDOMException- when errors occur in parsingIOException- when an I/O error prevents a document from being fully parsed
-
build
public Document build(Reader characterStream, String systemId) throws JDOMException, IOException
Description copied from interface:SAXEngineThis builds a document from the supplied Reader. It's the programmer's responsibility to make sure the reader matches the encoding of the file. It's often easier and safer to use an InputStream rather than a Reader, and to let the parser auto-detect the encoding from the XML declaration.
- Specified by:
buildin interfaceSAXEngine- Parameters:
characterStream-Readerto read from.systemId- base for resolving relative URIs- Returns:
Documentresultant Document object- Throws:
JDOMException- when errors occur in parsingIOException- when an I/O error prevents a document from being fully parsed
-
build
public Document build(String systemId) throws JDOMException, IOException
Description copied from interface:SAXEngineThis builds a document from the supplied URI.
- Specified by:
buildin interfaceSAXEngine- Parameters:
systemId- URI for the input- Returns:
Documentresultant Document object- Throws:
JDOMException- when errors occur in parsingIOException- when an I/O error prevents a document from being fully parsed
-
-