public class SAXHandler extends org.xml.sax.helpers.DefaultHandler implements LexicalHandler, DeclHandler, DTDHandler
SAXBuilder.| Constructor and Description |
|---|
SAXHandler()
This will create a new
SAXHandler that listens to SAX
events and creates a JDOM Document. |
SAXHandler(JDOMFactory factory)
This will create a new
SAXHandler that listens to SAX
events and creates a JDOM Document. |
| Modifier and Type | Method and Description |
|---|---|
void |
attributeDecl(String eName,
String aName,
String type,
String valueDefault,
String value)
This handles an attribute declaration in the internal subset.
|
void |
characters(char[] ch,
int start,
int length)
This will report character data (within an element).
|
void |
comment(char[] ch,
int start,
int length)
This reports that a comments is parsed.
|
void |
elementDecl(String name,
String model)
Handle an element declaration in a DTD.
|
void |
endCDATA()
Report a CDATA section
|
void |
endDTD()
This signifies that the reading of the DTD is complete.
|
void |
endElement(String namespaceURI,
String localName,
String qName)
Indicates the end of an element
(
</[element name]>) is reached. |
void |
endEntity(String name) |
void |
externalEntityDecl(String name,
String publicID,
String systemID)
This is called when the parser encounters an external entity
declaration.
|
protected void |
flushCharacters()
This will flush any characters from SAX character calls we've
been buffering.
|
protected void |
flushCharacters(String data)
Flush the given string into the document.
|
Element |
getCurrentElement()
Returns the being-parsed element.
|
Document |
getDocument()
Returns the document.
|
Locator |
getDocumentLocator()
Provides access to the
Locator object provided by the
SAX parser. |
boolean |
getExpandEntities()
Returns whether or not entities will be expanded during the
build.
|
JDOMFactory |
getFactory()
Returns the factory used for constructing objects.
|
boolean |
getIgnoringBoundaryWhitespace()
Returns whether or not the parser will elminate element content
containing only whitespace.
|
boolean |
getIgnoringElementContentWhitespace()
Returns whether or not the parser will elminate whitespace in
element content (sometimes known as "ignorable whitespace") when
building the document.
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Capture ignorable whitespace as text.
|
void |
internalEntityDecl(String name,
String value)
Handle an internal entity declaration in a DTD.
|
void |
notationDecl(String name,
String publicID,
String systemID)
Handle the declaration of a Notation in a DTD
|
void |
processingInstruction(String target,
String data)
This will indicate that a processing instruction has been encountered.
|
protected void |
pushElement(Element element)
Pushes an element onto the tree under construction.
|
void |
setDocumentLocator(Locator locator)
Receives an object for locating the origin of SAX document
events.
|
void |
setExpandEntities(boolean expand)
This sets whether or not to expand entities during the build.
|
void |
setIgnoringBoundaryWhitespace(boolean ignoringBoundaryWhite)
Specifies whether or not the parser should elminate text() nodes
containing only whitespace when building the document.
|
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 |
skippedEntity(String name)
This indicates that an unresolvable entity reference has been
encountered, normally because the external DTD subset has not been
read.
|
void |
startCDATA()
Report a CDATA section
|
void |
startDocument() |
void |
startDTD(String name,
String publicID,
String systemID)
This will signify that a DTD is being parsed, and can be
used to ensure that comments and other lexical structures
in the DTD are not added to the JDOM
Document
object. |
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
This reports the occurrence of an actual element.
|
void |
startEntity(String name) |
void |
startPrefixMapping(String prefix,
String uri)
This will add the prefix mapping to the JDOM
Document object. |
void |
unparsedEntityDecl(String name,
String publicID,
String systemID,
String notationName)
Handler for unparsed entity declarations in the DTD
|
endDocument, endPrefixMapping, error, fatalError, resolveEntity, warningpublic SAXHandler()
SAXHandler that listens to SAX
events and creates a JDOM Document. The objects will be constructed
using the default factory.public SAXHandler(JDOMFactory factory)
SAXHandler that listens to SAX
events and creates a JDOM Document. The objects will be constructed
using the provided factory.factory - JDOMFactory to be used for constructing
objectsprotected void pushElement(Element element)
element - root element under which content will be builtpublic Document getDocument()
Document - Document that was builtpublic JDOMFactory getFactory()
JDOMFactory - the factory used for
constructing objects.SAXHandler(org.jdom.JDOMFactory)public void setExpandEntities(boolean expand)
EntityRef objects. The
default is true.expand - boolean indicating whether entity expansion
should occur.public boolean getExpandEntities()
boolean - whether entity expansion
will occur during build.setExpandEntities(boolean)public void setIgnoringElementContentWhitespace(boolean ignoringWhite)
false.ignoringWhite - Whether to ignore ignorable whitespacepublic void setIgnoringBoundaryWhitespace(boolean ignoringBoundaryWhite)
SAXBuilder.setIgnoringBoundaryWhitespace(boolean).ignoringBoundaryWhite - Whether to ignore only whitespace contentpublic boolean getIgnoringBoundaryWhitespace()
boolean - whether only whitespace content will
be ignored during build.setIgnoringBoundaryWhitespace(boolean)public boolean getIgnoringElementContentWhitespace()
boolean - whether ignorable whitespace will
be ignored during build.setIgnoringElementContentWhitespace(boolean)public void startDocument()
startDocument in interface ContentHandlerstartDocument in class org.xml.sax.helpers.DefaultHandlerpublic void externalEntityDecl(String name, String publicID, String systemID) throws SAXException
externalEntityDecl in interface DeclHandlername - entity namepublicID - public idsystemID - system idSAXException - when things go wrongpublic void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException
attributeDecl in interface DeclHandlereName - String element name of attributeaName - String attribute nametype - String attribute typevalueDefault - String default value of attributevalue - String value of attributeSAXExceptionpublic void elementDecl(String name, String model) throws SAXException
elementDecl in interface DeclHandlername - String name of elementmodel - String model of the element in DTD syntaxSAXExceptionpublic void internalEntityDecl(String name, String value) throws SAXException
internalEntityDecl in interface DeclHandlername - String name of entityvalue - String value of the entitySAXExceptionpublic void processingInstruction(String target, String data) throws SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in class org.xml.sax.helpers.DefaultHandlertarget - String target of PIdata - String containing all data sent to the PI.
This typically looks like one or more attribute value
pairs.SAXException - when things go wrongpublic void skippedEntity(String name) throws SAXException
skippedEntity in interface ContentHandlerskippedEntity in class org.xml.sax.helpers.DefaultHandlername - String name of entitySAXException - when things go wrongpublic void startPrefixMapping(String prefix, String uri) throws SAXException
Document object.startPrefixMapping in interface ContentHandlerstartPrefixMapping in class org.xml.sax.helpers.DefaultHandlerprefix - String namespace prefix.uri - String namespace URI.SAXExceptionpublic void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException
xmlns:[namespace prefix] and
xsi:schemaLocation.startElement in interface ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlernamespaceURI - String namespace URI this element
is associated with, or an empty
StringlocalName - String name of element (with no
namespace prefix, if one is present)qName - String XML 1.0 version of element name:
[namespace prefix]:[localName]atts - Attributes list for this elementSAXException - when things go wrongpublic void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerch - char[] character array with character datastart - int index in array where data starts.length - int length of data.SAXExceptionpublic void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
ignorableWhitespace in interface ContentHandlerignorableWhitespace in class org.xml.sax.helpers.DefaultHandlerch - [] - char array of ignorable whitespacestart - int - starting position within arraylength - int - length of whitespace after startSAXException - when things go wrongprotected void flushCharacters()
throws SAXException
SAXException - when things go wrongprotected void flushCharacters(String data) throws SAXException
data - string to flushSAXExceptionpublic void endElement(String namespaceURI, String localName, String qName) throws SAXException
</[element name]>) is reached. Note that
the parser does not distinguish between empty
elements and non-empty elements, so this will occur uniformly.endElement in interface ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlernamespaceURI - String URI of namespace this
element is associated withlocalName - String name of element without prefixqName - String name of element in XML 1.0 formSAXException - when things go wrongpublic void startDTD(String name, String publicID, String systemID) throws SAXException
Document
object.startDTD in interface LexicalHandlername - String name of element listed in DTDpublicID - String public ID of DTDsystemID - String system ID of DTDSAXExceptionpublic void endDTD()
throws SAXException
endDTD in interface LexicalHandlerSAXExceptionpublic void startEntity(String name) throws SAXException
startEntity in interface LexicalHandlerSAXExceptionpublic void endEntity(String name) throws SAXException
endEntity in interface LexicalHandlerSAXExceptionpublic void startCDATA()
throws SAXException
startCDATA in interface LexicalHandlerSAXExceptionpublic void endCDATA()
throws SAXException
endCDATA in interface LexicalHandlerSAXExceptionpublic void comment(char[] ch,
int start,
int length)
throws SAXException
Element, or the Document itself
if at that level.comment in interface LexicalHandlerch - ch[] array of comment characters.start - int index to start reading from.length - int length of data.SAXExceptionpublic void notationDecl(String name, String publicID, String systemID) throws SAXException
notationDecl in interface DTDHandlernotationDecl in class org.xml.sax.helpers.DefaultHandlername - name of the notationpublicID - the public ID of the notationsystemID - the system ID of the notationSAXExceptionpublic void unparsedEntityDecl(String name, String publicID, String systemID, String notationName) throws SAXException
unparsedEntityDecl in interface DTDHandlerunparsedEntityDecl in class org.xml.sax.helpers.DefaultHandlername - String of the unparsed entity declpublicID - String of the unparsed entity declsystemID - String of the unparsed entity declnotationName - String of the unparsed entity declSAXExceptionpublic Element getCurrentElement() throws SAXException
Element - element being built.SAXExceptionpublic void setDocumentLocator(Locator locator)
JDOMFactory implementations can use the
getDocumentLocator() method to get access to the
Locator during parse.
setDocumentLocator in interface ContentHandlersetDocumentLocator in class org.xml.sax.helpers.DefaultHandlerlocator - Locator an object that can return
the location of any SAX document event.Copyright © 2012 JBoss by Red Hat. All Rights Reserved.