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)
MarkupWriter
Document
's MarkupModel
). The markup stream is sent to the writer.toMarkup
in interface MarkupWriter
public Document getDocument()
MarkupWriter
getDocument
in interface MarkupWriter
public Element getElement()
MarkupWriter
getElement
in interface MarkupWriter
public void cdata(String content)
MarkupWriter
MarkupWriter.write(String)
.cdata
in interface MarkupWriter
content
- pre-parsed contentpublic void write(String text)
MarkupWriter
write
in interface MarkupWriter
public void writef(String format, Object... args)
MarkupWriter
writef
in interface MarkupWriter
public void attributes(Object... namesAndValues)
MarkupWriter
attributes
in interface MarkupWriter
public Element element(String name, Object... namesAndValues)
MarkupWriter
element
in interface MarkupWriter
name
- the name of the element to createnamesAndValues
- an even number of values, alternating names and valuesMarkupWriter.attributes(Object[])
public void writeRaw(String text)
MarkupWriter
writeRaw
in interface MarkupWriter
Raw
public Element end()
MarkupWriter
end
in interface MarkupWriter
public void comment(String text)
MarkupWriter
comment
in interface MarkupWriter
public Element attributeNS(String namespace, String attributeName, String attributeValue)
MarkupWriter
attributeNS
in interface MarkupWriter
namespace
- URI containing the elementattributeName
- name of the attribute within the namespaceattributeValue
- the value for the attributepublic Element defineNamespace(String namespace, String namespacePrefix)
MarkupWriter
defineNamespace
in interface MarkupWriter
namespace
- 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)
MarkupWriter
MarkupWriter.end()
.elementNS
in interface MarkupWriter
namespace
- URI containing the elementelementName
- name of the element within the namespacepublic void addListener(MarkupWriterListener listener)
MarkupWriter
addListener
in interface MarkupWriter
public void removeListener(MarkupWriterListener listener)
MarkupWriter
removeListener
in interface MarkupWriter
${project.version} - Copyright © 2003-2015 The Apache Software Foundation.