|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.xml.sax.helpers.DefaultHandler | +--org.jdom.input.SAXHandler
SAXHandler
supports SAXBuilder
Field Summary | |
protected boolean |
atRoot
Indicator of where in the document we are |
protected java.util.LinkedList |
availableNamespaces
The namespaces in scope and actually attached to an element |
protected java.util.LinkedList |
declaredNamespaces
Temporary holder for namespaces that have been declared with startPrefixMapping, but are not yet available on the element |
protected boolean |
inCDATA
Indicator of whether we are in a CDATA |
protected boolean |
inDTD
Indicator of whether we are in the DocType. |
protected boolean |
inInternalSubset
Indicator of whether we are in the internal subset |
protected boolean |
previousCDATA
Indicator of whether we previously where in a CDATA |
protected java.util.Stack |
stack
Element stack |
protected boolean |
suppress
Indicator of whether we are actively suppressing (non-expanding) a current entity |
Constructor Summary | |
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. |
Method Summary | |
protected void |
appendExternalId(java.lang.String publicID,
java.lang.String systemID)
Appends an external ID to the internal subset buffer. |
void |
attributeDecl(java.lang.String eName,
java.lang.String aName,
java.lang.String type,
java.lang.String valueDefault,
java.lang.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(java.lang.String name,
java.lang.String model)
Handle an element declaration in a DTD |
void |
endCDATA()
Report a CDATA section - ignored in SAXBuilder. |
void |
endDTD()
This signifies that the reading of the DTD is complete. |
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName)
Indicates the end of an element ( </[element name]> ) is reached. |
void |
endEntity(java.lang.String name)
|
void |
endPrefixMapping(java.lang.String prefix)
This will add the prefix mapping to the JDOM Document object. |
void |
externalEntityDecl(java.lang.String name,
java.lang.String publicID,
java.lang.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 Element |
getCurrentElement()
Returns the being-parsed element. |
Document |
getDocument()
Returns the document. |
org.xml.sax.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 |
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(java.lang.String name,
java.lang.String value)
Handle an internal entity declaration in a DTD. |
void |
notationDecl(java.lang.String name,
java.lang.String publicID,
java.lang.String systemID)
Handle the declaration of a Notation in a DTD |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
This will indicate that a processing instruction has been encountered. |
void |
setDocumentLocator(org.xml.sax.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 |
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(java.lang.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 - ignored in SAXBuilder. |
void |
startDTD(java.lang.String name,
java.lang.String publicID,
java.lang.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(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
This reports the occurrence of an actual element. |
void |
startEntity(java.lang.String name)
|
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
This will add the prefix mapping to the JDOM Document object. |
void |
unparsedEntityDecl(java.lang.String name,
java.lang.String publicID,
java.lang.String systemID,
java.lang.String notationName)
Handler for unparsed entity declarations in the DTD |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
endDocument, error, fatalError, resolveEntity, startDocument, warning |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Stack stack
protected boolean atRoot
protected boolean inDTD
protected boolean inInternalSubset
protected boolean previousCDATA
protected boolean inCDATA
protected boolean suppress
protected java.util.LinkedList declaredNamespaces
protected java.util.LinkedList availableNamespaces
Constructor Detail |
public SAXHandler()
This will create a new SAXHandler
that listens to SAX
events and creates a JDOM Document. The objects will be constructed
using the default factory.
public SAXHandler(JDOMFactory factory)
This will create a new 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
objectsMethod Detail |
public Document getDocument()
Returns the document. Should be called after parsing is complete.
Document
- Document that was builtpublic JDOMFactory getFactory()
Returns the factory used for constructing objects.
JDOMFactory
- the factory used for
constructing objects.SAXHandler(org.jdom.input.JDOMFactory)
public void setExpandEntities(boolean expand)
This sets whether or not to expand entities during the build.
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.public boolean getExpandEntities()
Returns whether or not entities will be expanded during the build.
boolean
- whether entity expansion
will occur during build.setExpandEntities(boolean)
public 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 whitespacepublic boolean getIgnoringElementContentWhitespace()
Returns whether or not the parser will elminate whitespace in element content (sometimes known as "ignorable whitespace") when building the document.
boolean
- whether ignorable whitespace will
be ignored during build.setIgnoringElementContentWhitespace(boolean)
public void externalEntityDecl(java.lang.String name, java.lang.String publicID, java.lang.String systemID) throws org.xml.sax.SAXException
externalEntityDecl
in interface org.xml.sax.ext.DeclHandler
name
- entity namepublicID
- public idsystemID
- system idorg.xml.sax.SAXException
- when things go wrongpublic void attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value) throws org.xml.sax.SAXException
This handles an attribute declaration in the internal subset
attributeDecl
in interface org.xml.sax.ext.DeclHandler
eName
- String
element name of attributeaName
- String
attribute nametype
- String
attribute typevalueDefault
- String
default value of attributevalue
- String
value of attributepublic void elementDecl(java.lang.String name, java.lang.String model) throws org.xml.sax.SAXException
Handle an element declaration in a DTD
elementDecl
in interface org.xml.sax.ext.DeclHandler
name
- String
name of elementmodel
- String
model of the element in DTD syntaxpublic void internalEntityDecl(java.lang.String name, java.lang.String value) throws org.xml.sax.SAXException
Handle an internal entity declaration in a DTD.
internalEntityDecl
in interface org.xml.sax.ext.DeclHandler
name
- String
name of entityvalue
- String
value of the entitypublic void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
This will indicate that a processing instruction has been encountered. (The XML declaration is not a processing instruction and will not be reported.)
processingInstruction
in class org.xml.sax.helpers.DefaultHandler
target
- String
target of PIdata
- String
containing all data sent to the PI.
This typically looks like one or more attribute value
pairs.org.xml.sax.SAXException
- when things go wrongpublic void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException
This indicates that an unresolvable entity reference has been encountered, normally because the external DTD subset has not been read.
skippedEntity
in class org.xml.sax.helpers.DefaultHandler
name
- String
name of entityorg.xml.sax.SAXException
- when things go wrongpublic void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
This will add the prefix mapping to the JDOM
Document
object.
startPrefixMapping
in class org.xml.sax.helpers.DefaultHandler
prefix
- String
namespace prefix.uri
- String
namespace URI.public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException
This will add the prefix mapping to the JDOM
Document
object.
endPrefixMapping
in class org.xml.sax.helpers.DefaultHandler
prefix
- String
namespace prefix.uri
- String
namespace URI.public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
This reports the occurrence of an actual element. It will include
the element's attributes, with the exception of XML vocabulary
specific attributes, such as
xmlns:[namespace prefix]
and
xsi:schemaLocation
.
startElement
in class org.xml.sax.helpers.DefaultHandler
namespaceURI
- String
namespace URI this element
is associated with, or an empty
String
localName
- 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 elementorg.xml.sax.SAXException
- when things go wrongpublic void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
This will report character data (within an element).
characters
in class org.xml.sax.helpers.DefaultHandler
ch
- char[]
character array with character datastart
- int
index in array where data starts.length
- int
length of data.public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
Capture ignorable whitespace as text. If setIgnoringElementContentWhitespace(true) has been called then this method does nothing.
ignorableWhitespace
in class org.xml.sax.helpers.DefaultHandler
ch
- []
- char array of ignorable whitespacestart
- int
- starting position within arraylength
- int
- length of whitespace after startorg.xml.sax.SAXException
- when things go wrongprotected void flushCharacters() throws org.xml.sax.SAXException
This will flush any characters from SAX character calls we've been buffering.
org.xml.sax.SAXException
- when things go wrongpublic void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
Indicates the end of an element
(</[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 class org.xml.sax.helpers.DefaultHandler
namespaceURI
- String
URI of namespace this
element is associated withlocalName
- String
name of element without prefixqName
- String
name of element in XML 1.0 formorg.xml.sax.SAXException
- when things go wrongpublic void startDTD(java.lang.String name, java.lang.String publicID, java.lang.String systemID) throws org.xml.sax.SAXException
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.
startDTD
in interface org.xml.sax.ext.LexicalHandler
name
- String
name of element listed in DTDpublicID
- String
public ID of DTDsystemID
- String
system ID of DTDpublic void endDTD() throws org.xml.sax.SAXException
This signifies that the reading of the DTD is complete.
endDTD
in interface org.xml.sax.ext.LexicalHandler
public void startEntity(java.lang.String name) throws org.xml.sax.SAXException
startEntity
in interface org.xml.sax.ext.LexicalHandler
public void endEntity(java.lang.String name) throws org.xml.sax.SAXException
endEntity
in interface org.xml.sax.ext.LexicalHandler
public void startCDATA() throws org.xml.sax.SAXException
Report a CDATA section - ignored in SAXBuilder.
startCDATA
in interface org.xml.sax.ext.LexicalHandler
public void endCDATA() throws org.xml.sax.SAXException
Report a CDATA section - ignored in SAXBuilder.
endCDATA
in interface org.xml.sax.ext.LexicalHandler
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXException
This reports that a comments is parsed. If not in the
DTD, this comment is added to the current JDOM
Element
, or the Document
itself
if at that level.
comment
in interface org.xml.sax.ext.LexicalHandler
ch
- ch[]
array of comment characters.start
- int
index to start reading from.length
- int
length of data.public void notationDecl(java.lang.String name, java.lang.String publicID, java.lang.String systemID) throws org.xml.sax.SAXException
Handle the declaration of a Notation in a DTD
notationDecl
in interface org.xml.sax.DTDHandler
notationDecl
in class org.xml.sax.helpers.DefaultHandler
name
- name of the notationpublicID
- the public ID of the notationsystemID
- the system ID of the notationpublic void unparsedEntityDecl(java.lang.String name, java.lang.String publicID, java.lang.String systemID, java.lang.String notationName) throws org.xml.sax.SAXException
Handler for unparsed entity declarations in the DTD
unparsedEntityDecl
in interface org.xml.sax.DTDHandler
unparsedEntityDecl
in class org.xml.sax.helpers.DefaultHandler
name
- String
of the unparsed entity declpublicID
- String
of the unparsed entity declsystemID
- String
of the unparsed entity declnotationName
- String
of the unparsed entity declprotected void appendExternalId(java.lang.String publicID, java.lang.String systemID)
Appends an external ID to the internal subset buffer. Either publicID or systemID may be null, but not both.
publicID
- the public IDsystemID
- the system IDprotected Element getCurrentElement() throws org.xml.sax.SAXException
Returns the being-parsed element.
Element
- element at the top of the stack.public void setDocumentLocator(org.xml.sax.Locator locator)
Receives an object for locating the origin of SAX document events. This method is invoked by the SAX parser.
JDOMFactory
implementations can use the
getDocumentLocator()
method to get access to the
Locator
during parse.
setDocumentLocator
in class org.xml.sax.helpers.DefaultHandler
locator
- Locator
an object that can return
the location of any SAX document event.public org.xml.sax.Locator getDocumentLocator()
Provides access to the Locator
object provided by the
SAX parser.
Locator
an object that can return
the location of any SAX document event.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |