public interface MarkupWriter
Modifier and Type | Method and Description |
---|---|
void |
addListener(MarkupWriterListener listener)
Adds a markup writer listener that will be notified as elements are started and ended.
|
Element |
attributeNS(String namespace,
String attributeName,
String attributeValue)
Creates an attribute within the namespace for the current element.
|
void |
attributes(Object... namesAndValues)
Adds a series of attributes and values.
|
void |
cdata(String content)
Adds parsed character content.
|
void |
comment(String text)
Adds an XML comment.
|
Element |
defineNamespace(String namespace,
String namespacePrefix)
Defines a namespace for the currently active element.
|
Element |
element(String name,
Object... attributes)
Begins a new element as a child of the current element.
|
Element |
elementNS(String namespace,
String elementName)
Starts an element within the given namespace.
|
Element |
end()
Ends the current element.
|
Document |
getDocument()
Returns the Document into which this writer creates elements or other nodes.
|
Element |
getElement()
Returns the currently active element.
|
void |
removeListener(MarkupWriterListener listener)
Removes a previously added listener.
|
void |
toMarkup(PrintWriter writer)
Converts the collected markup into an markup stream (according to rules provided by the
Document 's MarkupModel ). |
void |
write(String text)
Writes the text as a child of the current element.
|
void |
writef(String format,
Object... args)
Writes a formatted string.
|
void |
writeRaw(String text)
Writes raw text, text with existing markup that should be passed through the client without change.
|
Element element(String name, Object... attributes)
name
- the name of the element to createattributes
- an even number of values, alternating names and valuesattributes(Object[])
Element end()
void writeRaw(String text)
text
- Raw
void comment(String text)
void cdata(String content)
write(String)
.content
- pre-parsed contentvoid attributes(Object... namesAndValues)
void toMarkup(PrintWriter writer)
Document
's MarkupModel
). The markup stream is sent to the writer.Document getDocument()
Element getElement()
Element defineNamespace(String namespace, String namespacePrefix)
namespace
- the namespace URInamespacePrefix
- the prefix for elements and attributes associated with the namespace (may be the empty
string for the default namespace)Element elementNS(String namespace, String elementName)
end()
.namespace
- URI containing the elementelementName
- name of the element within the namespaceElement attributeNS(String namespace, String attributeName, String attributeValue)
namespace
- URI containing the elementattributeName
- name of the attribute within the namespaceattributeValue
- the value for the attributevoid addListener(MarkupWriterListener listener)
void removeListener(MarkupWriterListener listener)
${project.version} - Copyright © 2003-2015 The Apache Software Foundation.