public final class DOMBuilder extends Object
| Constructor and Description |
|---|
DOMBuilder(String name)
Creates a builder for a new DOM document.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addContent(String content)
Adds the given string as text content to the current element.
|
void |
addContentElement(String name,
String content)
Adds a new child element with the given name and text content.
|
void |
endElement()
Makes the parent element current.
|
void |
setAttribute(String name,
boolean value)
Sets the named boolean attribute of the current element.
|
void |
setAttribute(String name,
String value)
Sets the named attribute of the current element.
|
void |
startElement(String name)
Creates a new element with the given name as the child of the
current element and makes the created element current.
|
void |
write(OutputStream xml)
Writes the document built by this builder into the given output stream.
|
public DOMBuilder(String name) throws ParserConfigurationException
name - name of the root elementParserConfigurationException - if a document cannot be createdpublic void write(OutputStream xml) throws IOException
xml - XML output streamIOException - if the document could not be writtenpublic void startElement(String name)
endElement method needs to be called
to return back to the original element.name - name of the new elementpublic void endElement()
startElement method has been fully
built.public void setAttribute(String name, String value)
name - attribute namevalue - attribute valuepublic void setAttribute(String name, boolean value)
name - attribute namevalue - boolean attribute valuepublic void addContent(String content)
content - text contentCopyright © 2004–2021 The Apache Software Foundation. All rights reserved.