Class MarkupWriterImpl
- java.lang.Object
-
- org.apache.tapestry5.internal.services.MarkupWriterImpl
-
- All Implemented Interfaces:
MarkupWriter
public class MarkupWriterImpl extends java.lang.Object implements MarkupWriter
-
-
Constructor Summary
Constructors Constructor Description MarkupWriterImpl()Creates a new instance of the MarkupWriter with aDefaultMarkupModel.MarkupWriterImpl(MarkupModel model)MarkupWriterImpl(MarkupModel model, java.lang.String encoding, java.lang.String mimeType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(MarkupWriterListener listener)Adds a markup writer listener that will be notified as elements are started and ended.ElementattributeNS(java.lang.String namespace, java.lang.String attributeName, java.lang.String attributeValue)Creates an attribute within the namespace for the current element.voidattributes(java.lang.Object... namesAndValues)Adds a series of attributes and values.voidcdata(java.lang.String content)Adds parsed character content.voidcomment(java.lang.String text)Adds an XML comment.ElementdefineNamespace(java.lang.String namespace, java.lang.String namespacePrefix)Defines a namespace for the currently active element.Elementelement(java.lang.String name, java.lang.Object... namesAndValues)Begins a new element as a child of the current element.ElementelementNS(java.lang.String namespace, java.lang.String elementName)Starts an element within the given namespace.Elementend()Ends the current element.DocumentgetDocument()Returns the Document into which this writer creates elements or other nodes.ElementgetElement()Returns the currently active element.voidremoveListener(MarkupWriterListener listener)Removes a previously added listener.voidtoMarkup(java.io.PrintWriter writer)Converts the collected markup into an markup stream (according to rules provided by theDocument'sMarkupModel).java.lang.StringtoString()voidwrite(java.lang.String text)Writes the text as a child of the current element.voidwritef(java.lang.String format, java.lang.Object... args)Writes a formatted string.voidwriteRaw(java.lang.String text)Writes raw text, text with existing markup that should be passed through the client without change.
-
-
-
Constructor Detail
-
MarkupWriterImpl
public MarkupWriterImpl()
Creates a new instance of the MarkupWriter with aDefaultMarkupModel.
-
MarkupWriterImpl
public MarkupWriterImpl(MarkupModel model)
-
MarkupWriterImpl
public MarkupWriterImpl(MarkupModel model, java.lang.String encoding, java.lang.String mimeType)
-
-
Method Detail
-
toMarkup
public void toMarkup(java.io.PrintWriter writer)
Description copied from interface:MarkupWriterConverts the collected markup into an markup stream (according to rules provided by theDocument'sMarkupModel). The markup stream is sent to the writer.- Specified by:
toMarkupin interfaceMarkupWriter
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getDocument
public Document getDocument()
Description copied from interface:MarkupWriterReturns the Document into which this writer creates elements or other nodes.- Specified by:
getDocumentin interfaceMarkupWriter
-
getElement
public Element getElement()
Description copied from interface:MarkupWriterReturns the currently active element.- Specified by:
getElementin interfaceMarkupWriter
-
cdata
public void cdata(java.lang.String content)
Description copied from interface:MarkupWriterAdds parsed character content. This will be enclosed in a CDATA block if supported. When not supported, this is the same asMarkupWriter.write(String).- Specified by:
cdatain interfaceMarkupWriter- Parameters:
content- pre-parsed content
-
write
public void write(java.lang.String text)
Description copied from interface:MarkupWriterWrites the text as a child of the current element.- Specified by:
writein interfaceMarkupWriter
-
writef
public void writef(java.lang.String format, java.lang.Object... args)
Description copied from interface:MarkupWriterWrites a formatted string.- Specified by:
writefin interfaceMarkupWriter
-
attributes
public void attributes(java.lang.Object... namesAndValues)
Description copied from interface:MarkupWriterAdds a series of attributes and values. Null values are quietly skipped. If a name already has a value, then the new value is ignored.- Specified by:
attributesin interfaceMarkupWriter
-
element
public Element element(java.lang.String name, java.lang.Object... namesAndValues)
Description copied from interface:MarkupWriterBegins a new element as a child of the current element. The new element becomes the current element. The new Element is returned and can be directly manipulated (possibly at a later date). Optionally, attributes for the new element can be specified directly.- Specified by:
elementin interfaceMarkupWriter- Parameters:
name- the name of the element to createnamesAndValues- an even number of values, alternating names and values- Returns:
- the new DOM Element node
- See Also:
MarkupWriter.attributes(Object[])
-
writeRaw
public void writeRaw(java.lang.String text)
Description copied from interface:MarkupWriterWrites raw text, text with existing markup that should be passed through the client without change. This can be useful when the markup is read from an external source (a file or a database) and is simply to be included.- Specified by:
writeRawin interfaceMarkupWriter- See Also:
Raw
-
end
public Element end()
Description copied from interface:MarkupWriterEnds the current element. The new current element will be the parent element. Returns the new current element (which may be null when ending the root element for the document).- Specified by:
endin interfaceMarkupWriter
-
comment
public void comment(java.lang.String text)
Description copied from interface:MarkupWriterAdds an XML comment. The text should be just the comment content, the comment delimiters will be provided. Note that, as of Tapestry 5.2., no extra whitespace is added (previous releases added a space around the text).- Specified by:
commentin interfaceMarkupWriter
-
attributeNS
public Element attributeNS(java.lang.String namespace, java.lang.String attributeName, java.lang.String attributeValue)
Description copied from interface:MarkupWriterCreates an attribute within the namespace for the current element.- Specified by:
attributeNSin interfaceMarkupWriter- Parameters:
namespace- URI containing the elementattributeName- name of the attribute within the namespaceattributeValue- the value for the attribute- Returns:
- the currently active element
-
defineNamespace
public Element defineNamespace(java.lang.String namespace, java.lang.String namespacePrefix)
Description copied from interface:MarkupWriterDefines a namespace for the currently active element. The namespace URI will be mapped to the provided namespace prefix within the Element.- Specified by:
defineNamespacein interfaceMarkupWriter- Parameters:
namespace- the namespace URInamespacePrefix- the prefix for elements and attributes associated with the namespace (may be the empty string for the default namespace)- Returns:
- the currently active element
-
elementNS
public Element elementNS(java.lang.String namespace, java.lang.String elementName)
Description copied from interface:MarkupWriterStarts an element within the given namespace. The correct namespace prefix will be identified and used. Must be balanced by a call toMarkupWriter.end().- Specified by:
elementNSin interfaceMarkupWriter- Parameters:
namespace- URI containing the elementelementName- name of the element within the namespace- Returns:
- the new Element
-
addListener
public void addListener(MarkupWriterListener listener)
Description copied from interface:MarkupWriterAdds a markup writer listener that will be notified as elements are started and ended.- Specified by:
addListenerin interfaceMarkupWriter
-
removeListener
public void removeListener(MarkupWriterListener listener)
Description copied from interface:MarkupWriterRemoves a previously added listener.- Specified by:
removeListenerin interfaceMarkupWriter
-
-