org.apache.tapestry5.internal.services
Class MarkupWriterImpl

java.lang.Object
  extended by org.apache.tapestry5.internal.services.MarkupWriterImpl
All Implemented Interfaces:
MarkupWriter

public class MarkupWriterImpl
extends Object
implements MarkupWriter


Constructor Summary
MarkupWriterImpl()
          Creates a new instance of the MarkupWriter with a DefaultMarkupModel.
MarkupWriterImpl(MarkupModel model)
           
MarkupWriterImpl(MarkupModel model, String encoding)
           
 
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... 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MarkupWriterImpl

public MarkupWriterImpl()
Creates a new instance of the MarkupWriter with a DefaultMarkupModel.


MarkupWriterImpl

public MarkupWriterImpl(MarkupModel model)

MarkupWriterImpl

public MarkupWriterImpl(MarkupModel model,
                        String encoding)
Method Detail

toMarkup

public void toMarkup(PrintWriter writer)
Description copied from interface: MarkupWriter
Converts the collected markup into an markup stream (according to rules provided by the Document's MarkupModel). The markup stream is sent to the writer.

Specified by:
toMarkup in interface MarkupWriter

toString

public String toString()
Overrides:
toString in class Object

getDocument

public Document getDocument()
Description copied from interface: MarkupWriter
Returns the Document into which this writer creates elements or other nodes.

Specified by:
getDocument in interface MarkupWriter

getElement

public Element getElement()
Description copied from interface: MarkupWriter
Returns the currently active element.

Specified by:
getElement in interface MarkupWriter

cdata

public void cdata(String content)
Description copied from interface: MarkupWriter
Adds parsed character content. This will be enclosed in a CDATA block if supported. When not supported, this is the same as MarkupWriter.write(String).

Specified by:
cdata in interface MarkupWriter
Parameters:
content - pre-parsed content

write

public void write(String text)
Description copied from interface: MarkupWriter
Writes the text as a child of the current element.

Specified by:
write in interface MarkupWriter

writef

public void writef(String format,
                   Object... args)
Description copied from interface: MarkupWriter
Writes a formatted string.

Specified by:
writef in interface MarkupWriter

attributes

public void attributes(Object... namesAndValues)
Description copied from interface: MarkupWriter
Adds 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:
attributes in interface MarkupWriter

element

public Element element(String name,
                       Object... namesAndValues)
Description copied from interface: MarkupWriter
Begins 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:
element in interface MarkupWriter
Parameters:
name - the name of the element to create
namesAndValues - an even number of values, alternating names and values
Returns:
the new DOM Element node
See Also:
MarkupWriter.attributes(Object[])

writeRaw

public void writeRaw(String text)
Description copied from interface: MarkupWriter
Writes 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:
writeRaw in interface MarkupWriter
See Also:
Raw

end

public Element end()
Description copied from interface: MarkupWriter
Ends 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:
end in interface MarkupWriter

comment

public void comment(String text)
Description copied from interface: MarkupWriter
Adds 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:
comment in interface MarkupWriter

attributeNS

public Element attributeNS(String namespace,
                           String attributeName,
                           String attributeValue)
Description copied from interface: MarkupWriter
Creates an attribute within the namespace for the current element.

Specified by:
attributeNS in interface MarkupWriter
Parameters:
namespace - URI containing the element
attributeName - name of the attribute within the namespace
attributeValue - the value for the attribute
Returns:
the currently active element

defineNamespace

public Element defineNamespace(String namespace,
                               String namespacePrefix)
Description copied from interface: MarkupWriter
Defines a namespace for the currently active element. The namespace URI will be mapped to the provided namespace prefix within the Element.

Specified by:
defineNamespace in interface MarkupWriter
Parameters:
namespace - the namespace URI
namespacePrefix - 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(String namespace,
                         String elementName)
Description copied from interface: MarkupWriter
Starts an element within the given namespace. The correct namespace prefix will be identified and used. Must be balanced by a call to MarkupWriter.end().

Specified by:
elementNS in interface MarkupWriter
Parameters:
namespace - URI containing the element
elementName - name of the element within the namespace
Returns:
the new Element

addListener

public void addListener(MarkupWriterListener listener)
Description copied from interface: MarkupWriter
Adds a markup writer listener that will be notified as elements are started and ended.

Specified by:
addListener in interface MarkupWriter

removeListener

public void removeListener(MarkupWriterListener listener)
Description copied from interface: MarkupWriter
Removes a previously added listener.

Specified by:
removeListener in interface MarkupWriter


Copyright © 2003-2012 The Apache Software Foundation.