public class MarkupWriterImpl extends Object implements MarkupWriter
| Constructor and Description |
|---|
MarkupWriterImpl()
Creates a new instance of the MarkupWriter with a
DefaultMarkupModel. |
MarkupWriterImpl(MarkupModel model) |
MarkupWriterImpl(MarkupModel model,
String encoding,
String mimeType) |
| 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... namesAndValues)
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). |
String |
toString() |
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.
|
public MarkupWriterImpl()
DefaultMarkupModel.public MarkupWriterImpl(MarkupModel model)
public MarkupWriterImpl(MarkupModel model, String encoding, String mimeType)
public void toMarkup(PrintWriter writer)
MarkupWriterDocument's MarkupModel). The markup stream is sent to the writer.toMarkup in interface MarkupWriterpublic Document getDocument()
MarkupWritergetDocument in interface MarkupWriterpublic Element getElement()
MarkupWritergetElement in interface MarkupWriterpublic void cdata(String content)
MarkupWriterMarkupWriter.write(String).cdata in interface MarkupWritercontent - pre-parsed contentpublic void write(String text)
MarkupWriterwrite in interface MarkupWriterpublic void writef(String format, Object... args)
MarkupWriterwritef in interface MarkupWriterpublic void attributes(Object... namesAndValues)
MarkupWriterattributes in interface MarkupWriterpublic Element element(String name, Object... namesAndValues)
MarkupWriterelement in interface MarkupWritername - the name of the element to createnamesAndValues - an even number of values, alternating names and valuesMarkupWriter.attributes(Object[])public void writeRaw(String text)
MarkupWriterwriteRaw in interface MarkupWriterRawpublic Element end()
MarkupWriterend in interface MarkupWriterpublic void comment(String text)
MarkupWritercomment in interface MarkupWriterpublic Element attributeNS(String namespace, String attributeName, String attributeValue)
MarkupWriterattributeNS in interface MarkupWriternamespace - URI containing the elementattributeName - name of the attribute within the namespaceattributeValue - the value for the attributepublic Element defineNamespace(String namespace, String namespacePrefix)
MarkupWriterdefineNamespace in interface MarkupWriternamespace - the namespace URInamespacePrefix - the prefix for elements and attributes associated with the namespace (may be the empty
string for the default namespace)public Element elementNS(String namespace, String elementName)
MarkupWriterMarkupWriter.end().elementNS in interface MarkupWriternamespace - URI containing the elementelementName - name of the element within the namespacepublic void addListener(MarkupWriterListener listener)
MarkupWriteraddListener in interface MarkupWriterpublic void removeListener(MarkupWriterListener listener)
MarkupWriterremoveListener in interface MarkupWriter5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.