Package nu.validator.saxtree
Class TreeBuilder
java.lang.Object
nu.validator.saxtree.TreeBuilder
- All Implemented Interfaces:
ContentHandler
,LexicalHandler
Builds a SAX Tree representation of a document or a fragment
streamed as
ContentHandler
and
LexicalHandler
events. The start/end event matching
is expected to adhere to the SAX API contract. Things will
simply break if this is not the case. Fragments are expected to
omit startDocument()
and endDocument()
calls.- Version:
- $Id$
- Author:
- hsivonen
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a reusableTreeBuilder
that buildsDocument
s and copies attributes.TreeBuilder
(boolean fragment, boolean retainAttributes) The constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
characters
(char[] ch, int start, int length) void
comment
(char[] ch, int start, int length) void
endCDATA()
void
void
endDTD()
void
endElement
(String uri, String localName, String qName) void
void
endPrefixMapping
(String prefix) getRoot()
Returns the root (Document
if building a full document orDocumentFragment
if building a fragment.).void
ignorableWhitespace
(char[] ch, int start, int length) void
processingInstruction
(String target, String data) void
setDocumentLocator
(Locator locator) void
skippedEntity
(String name) void
void
void
void
startElement
(String uri, String localName, String qName, Attributes atts) void
startEntity
(String name) void
startPrefixMapping
(String prefix, String uri) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
TreeBuilder
public TreeBuilder()Constructs a reusableTreeBuilder
that buildsDocument
s and copies attributes. -
TreeBuilder
public TreeBuilder(boolean fragment, boolean retainAttributes) The constructor. The instance will be reusabe if building a full document and not reusable if building a fragment.- Parameters:
fragment
- whether thisTreeBuilder
should build aDocumentFragment
instead of aDocument
.retainAttributes
- whether instances of theAttributes
interface passed tostartElement
should be retained (the alternative is copying).
-
-
Method Details
-
characters
- Specified by:
characters
in interfaceContentHandler
- Throws:
SAXException
- See Also:
-
endDocument
- Specified by:
endDocument
in interfaceContentHandler
- Throws:
SAXException
- See Also:
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Throws:
SAXException
- See Also:
-
endPrefixMapping
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Throws:
SAXException
- See Also:
-
ignorableWhitespace
- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Throws:
SAXException
- See Also:
-
processingInstruction
- Specified by:
processingInstruction
in interfaceContentHandler
- Throws:
SAXException
- See Also:
-
setDocumentLocator
- Specified by:
setDocumentLocator
in interfaceContentHandler
- See Also:
-
skippedEntity
- Specified by:
skippedEntity
in interfaceContentHandler
- Throws:
SAXException
-
startDocument
- Specified by:
startDocument
in interfaceContentHandler
- Throws:
SAXException
- See Also:
-
startElement
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Throws:
SAXException
- See Also:
-
startPrefixMapping
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Throws:
SAXException
- See Also:
-
comment
- Specified by:
comment
in interfaceLexicalHandler
- Throws:
SAXException
- See Also:
-
endCDATA
- Specified by:
endCDATA
in interfaceLexicalHandler
- Throws:
SAXException
- See Also:
-
endDTD
- Specified by:
endDTD
in interfaceLexicalHandler
- Throws:
SAXException
- See Also:
-
endEntity
- Specified by:
endEntity
in interfaceLexicalHandler
- Throws:
SAXException
- See Also:
-
startCDATA
- Specified by:
startCDATA
in interfaceLexicalHandler
- Throws:
SAXException
- See Also:
-
startDTD
- Specified by:
startDTD
in interfaceLexicalHandler
- Throws:
SAXException
- See Also:
-
startEntity
- Specified by:
startEntity
in interfaceLexicalHandler
- Throws:
SAXException
- See Also:
-
getRoot
Returns the root (Document
if building a full document orDocumentFragment
if building a fragment.).- Returns:
- the root
-