|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MarkupWriter
An interface used by objects, such as Tapestry components, that need to render themselves as some form of XML markup. A markup writer maintains the idea of a current element. Attributes are added to the current element, and new text and elements are placed inside the current element. In this way, the markup writer maintains a facade that XML markup is generated as a stream, even though the implementation builds a kind of DOM tree. The DOM tree can be also be manipulated. This solves a number of problems from Tapestry 4 (and earlier) where random access to the DOM was desired and had to be simulated through complex buffering.
Method Summary | |
---|---|
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. |
Method Detail |
---|
Element element(String name, Object... attributes)
name
- the name of the element to createattributes
- an even number of values, alternating names and values
attributes(Object[])
Element end()
void write(String text)
void writef(String format, Object... args)
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 namespace
Element attributeNS(String namespace, String attributeName, String attributeValue)
namespace
- URI containing the elementattributeName
- name of the attribute within the namespaceattributeValue
- the value for the attribute
void addListener(MarkupWriterListener listener)
void removeListener(MarkupWriterListener listener)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |