com.primix.tapestry.wml
Class WMLResponseWriter
java.lang.Object
|
+--com.primix.tapestry.AbstractResponseWriter
|
+--com.primix.tapestry.wml.WMLResponseWriter
- All Implemented Interfaces:
- IResponseWriter
- Direct Known Subclasses:
- NestedWMLResponseWriter
- public class WMLResponseWriter
- extends AbstractResponseWriter
This class is used to create WML output.
The WMLResponseWriter
handles the necessary escaping
of invalid characters.
Specifically, the '$', '<', '>' and '&' characters are properly
converted to their WML entities by the print()
methods.
Similar measures are taken by the AbstractResponseWriter.attribute(String, String)
method.
Other invalid characters are converted to their numeric entity equivalent.
This class makes it easy to generate trivial and non-trivial WML pages.
It is also useful to generate WML snippets. It's ability to do simple
formatting is very useful. A JSP may create an instance of the class
and use it as an alternative to the simple-minded <%= ... %>
construct, espcially because it can handle null more cleanly.
- Since:
- 0.2.9
- Version:
- $Id: WMLResponseWriter.java,v 1.4 2001/05/02 14:15:17 hship Exp $
- Author:
- David Solis
Method Summary |
java.lang.String |
getContentType()
Implemented in concrete subclasses to identify the MIME content type
produced by this response writer. |
protected java.lang.String[] |
getEntities()
Implemented in concrete subclasses to provide a mapping from characters
to entities. |
IResponseWriter |
getNestedWriter()
Returns a nested writer, one that accumulates its changes in a
buffer. |
protected boolean[] |
getSafe()
Implemented in concrete subclasses to provide an indication of which
characters are 'safe' to insert directly into the response. |
Methods inherited from class com.primix.tapestry.AbstractResponseWriter |
attribute, attribute, attribute, begin, beginEmpty, checkError, close, closeTag, comment, end, end, flush, pop, print, print, print, print, println, printRaw, printRaw, push |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WMLResponseWriter
protected WMLResponseWriter()
- Protected constructor, needed by
NestedWMLResponseWriter
.
WMLResponseWriter
public WMLResponseWriter(java.io.OutputStream stream)
- Sends output to the stream. Internally, an instance of
PrintWriter
is created, which will be closed when the WMLResponseWriter
is closed.
getEntities
protected java.lang.String[] getEntities()
- Description copied from class:
AbstractResponseWriter
- Implemented in concrete subclasses to provide a mapping from characters
to entities. The offset in the array corresponds to the
character, the String is the literal text to insert into the
output stream as a replacement. A value of null (which is prevalent)
means no subsititution. We're using this as a fast-lookup on a single
character, otherwise we might use a
Map
.
- Overrides:
getEntities
in class AbstractResponseWriter
getSafe
protected boolean[] getSafe()
- Description copied from class:
AbstractResponseWriter
- Implemented in concrete subclasses to provide an indication of which
characters are 'safe' to insert directly into the response. The index
into the array is the character, if the value at the index is false (or the
index out of range), then the character is escaped.
- Overrides:
getSafe
in class AbstractResponseWriter
getNestedWriter
public IResponseWriter getNestedWriter()
- Description copied from interface:
IResponseWriter
- Returns a nested writer, one that accumulates its changes in a
buffer. When the nested writer is closed, it writes its
buffer into its containing
IResponseWriter
.
- Overrides:
getNestedWriter
in class AbstractResponseWriter
getContentType
public java.lang.String getContentType()
- Description copied from class:
AbstractResponseWriter
- Implemented in concrete subclasses to identify the MIME content type
produced by this response writer.
- Overrides:
getContentType
in class AbstractResponseWriter