|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.jdom.input.SAXBuilder
SAXBuilder builds a JDOM tree using SAX.
Known issues: Relative paths for a DocType or EntityRef may be converted by the SAX parser into absolute paths
| Field Summary | |
protected JDOMFactory |
factory
The factory for creating new JDOM objects |
| Constructor Summary | |
SAXBuilder()
Creates a new SAXBuilder which will attempt to first locate a parser via JAXP, then will try to use a set of default SAX Drivers. |
|
SAXBuilder(boolean validate)
Creates a new SAXBuilder which will attempt to first locate a parser via JAXP, then will try to use a set of default SAX Drivers. |
|
SAXBuilder(String saxDriverClass)
Creates a new SAXBuilder using the specified SAX parser. |
|
SAXBuilder(String saxDriverClass,
boolean validate)
Creates a new SAXBuilder using the specified SAX parser. |
|
| Method Summary | |
Document |
build(File file)
This builds a document from the supplied filename. |
Document |
build(InputSource in)
This builds a document from the supplied input source. |
Document |
build(InputStream in)
This builds a document from the supplied input stream. |
Document |
build(InputStream in,
String systemId)
This builds a document from the supplied input stream. |
Document |
build(Reader characterStream)
This builds a document from the supplied Reader. |
Document |
build(Reader characterStream,
String SystemId)
This builds a document from the supplied Reader. |
Document |
build(String systemId)
This builds a document from the supplied URI. |
Document |
build(URL url)
This builds a document from the supplied URL. |
protected void |
configureContentHandler(SAXHandler contentHandler)
This configures the SAXHandler that will be used to build the Document. |
protected void |
configureParser(XMLReader parser,
SAXHandler contentHandler)
This configures the XMLReader to be used for reading the XML document. |
protected SAXHandler |
createContentHandler()
This creates the SAXHandler that will be used to build the Document. |
protected XMLReader |
createParser()
This creates the XMLReader to be used for reading the XML document. |
protected URL |
fileToURL(File f)
Imitation of File.toURL(), a JDK 1.2 method, reimplemented here to work with JDK 1.1. |
void |
setDTDHandler(DTDHandler dtdHandler)
This sets custom DTDHandler for the Builder. |
void |
setEntityResolver(EntityResolver entityResolver)
This sets custom EntityResolver for the Builder. |
void |
setErrorHandler(ErrorHandler errorHandler)
This sets custom ErrorHandler for the Builder. |
void |
setExpandEntities(boolean expand)
This sets whether or not to expand entities for the builder. |
void |
setFactory(JDOMFactory factory)
|
void |
setIgnoringElementContentWhitespace(boolean ignoringWhite)
Specifies whether or not the parser should elminate whitespace in element content (sometimes known as "ignorable whitespace") when building the document. |
void |
setValidation(boolean validate)
This sets validation for the builder. |
void |
setXMLFilter(XMLFilter xmlFilter)
This sets custom XMLFilter for the Builder. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected JDOMFactory factory
| Constructor Detail |
public SAXBuilder()
Creates a new SAXBuilder which will attempt to first locate a parser via JAXP, then will try to use a set of default SAX Drivers. The underlying parser will not validate.
public SAXBuilder(boolean validate)
Creates a new SAXBuilder which will attempt to first locate a parser via JAXP, then will try to use a set of default SAX Drivers. The underlying parser will validate or not according to the given parameter.
validate - boolean indicating if
validation should occur.public SAXBuilder(String saxDriverClass)
Creates a new SAXBuilder using the specified SAX parser. The underlying parser will not validate.
saxDriverClass - String name of SAX Driver
to use for parsing.
public SAXBuilder(String saxDriverClass,
boolean validate)
Creates a new SAXBuilder using the specified SAX parser. The underlying parser will validate or not according to the given parameter.
saxDriverClass - String name of SAX Driver
to use for parsing.validate - boolean indicating if
validation should occur.| Method Detail |
public void setFactory(JDOMFactory factory)
public void setValidation(boolean validate)
This sets validation for the builder.
validate - boolean indicating whether validation
should occur.public void setErrorHandler(ErrorHandler errorHandler)
This sets custom ErrorHandler for the Builder.
errorHandler - ErrorHandlerpublic void setEntityResolver(EntityResolver entityResolver)
This sets custom EntityResolver for the Builder.
entityResolver - EntityResolverpublic void setDTDHandler(DTDHandler dtdHandler)
This sets custom DTDHandler for the Builder.
dtdHandler - DTDHandlerpublic void setXMLFilter(XMLFilter xmlFilter)
This sets custom XMLFilter for the Builder.
xmlFilter - XMLFilterpublic void setIgnoringElementContentWhitespace(boolean ignoringWhite)
Specifies whether or not the parser should elminate whitespace in
element content (sometimes known as "ignorable whitespace") when
building the document. Only whitespace which is contained within
element content that has an element only content model will be
eliminated (see XML Rec 3.2.1). For this setting to take effect
requires that validation be turned on. The default value of this
setting is false.
ignoringWhite - Whether to ignore ignorable whitespace
public Document build(InputSource in)
throws JDOMException
This builds a document from the supplied input source.
in - InputSource to read from.Document - resultant Document object.
protected SAXHandler createContentHandler()
throws Exception
This creates the SAXHandler that will be used to build the Document.
protected void configureContentHandler(SAXHandler contentHandler)
throws Exception
This configures the SAXHandler that will be used to build the Document.
The default implementation simply passes through some configuration settings that were set on the SAXBuilder: setExpandEntities() and setIgnoringElementContentWhitespace().
protected XMLReader createParser()
throws Exception
This creates the XMLReader to be used for reading the XML document.
The default behavior is to (1) use the saxDriverClass, if it has been set, (2) try to obtain a parser from JAXP, if it is available, and (3) if all else fails, use a hard-coded default parser (currently the Xerces parser). Subclasses may override this method to determine the parser to use in a different way.
protected void configureParser(XMLReader parser,
SAXHandler contentHandler)
throws Exception
This configures the XMLReader to be used for reading the XML document.
The default implementation will set various options on the returned XMLReader, and that those options may change in future releases. It will set the validation flag, the XMLFilter, the DTD resolver, and the entity handler according to the options that were set (e.g. via setEntityResolver), and it will set various SAX properties and features that it needs set in order to work correctly. Change this behavior at your own risk.
public Document build(InputStream in)
throws JDOMException
This builds a document from the supplied input stream.
in - InputStream to read from.Document - resultant Document object.
public Document build(File file)
throws JDOMException
This builds a document from the supplied filename.
file - File to read from.Document - resultant Document object.
public Document build(URL url)
throws JDOMException
This builds a document from the supplied URL.
url - URL to read from.Document - resultant Document object.
public Document build(InputStream in,
String systemId)
throws JDOMException
This builds a document from the supplied input stream.
in - InputStream to read from.systemId - base for resolving relative URIsDocument - resultant Document object.
public Document build(Reader characterStream)
throws JDOMException
This builds a document from the supplied Reader.
in - Reader to read from.Document - resultant Document object.
public Document build(Reader characterStream,
String SystemId)
throws JDOMException
This builds a document from the supplied Reader.
in - Reader to read from.systemId - base for resolving relative URIsDocument - resultant Document object.
public Document build(String systemId)
throws JDOMException
This builds a document from the supplied URI.
systemId - URI for the inputDocument - resultant Document object.
protected URL fileToURL(File f)
throws MalformedURLException
f - the file to convertFilepublic void setExpandEntities(boolean expand)
This sets whether or not to expand entities for the builder.
A true means to expand entities as normal content. A false means to
leave entities unexpanded as EntityRef objects. The
default is true.
expand - boolean indicating whether entity expansion
should occur.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||