com.primix.tapestry
Class HTMLResponseWriter

java.lang.Object
  |
  +--com.primix.tapestry.AbstractResponseWriter
        |
        +--com.primix.tapestry.HTMLResponseWriter
All Implemented Interfaces:
IResponseWriter
Direct Known Subclasses:
NestedHTMLResponseWriter

public class HTMLResponseWriter
extends AbstractResponseWriter

This class is used to create HTML output.

The HTMLResponseWriter handles the necessary escaping of invalid characters. Specifically, the '<', '>' and '&' characters are properly converted to their HTML 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.

Version:
$Id: HTMLResponseWriter.java,v 1.8 2001/05/30 16:13:20 hship Exp $
Author:
Howard Ship

Fields inherited from class com.primix.tapestry.AbstractResponseWriter
openTag, writer
 
Constructor Summary
protected HTMLResponseWriter()
          Protected constructor, needed by NestedHTMLResponseWriter.
  HTMLResponseWriter(java.io.OutputStream stream)
          Sends output to the stream.
 
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
 

Constructor Detail

HTMLResponseWriter

protected HTMLResponseWriter()
Protected constructor, needed by NestedHTMLResponseWriter.

HTMLResponseWriter

public HTMLResponseWriter(java.io.OutputStream stream)
Sends output to the stream. Internally, an instance of PrintWriter is created, which will be closed when the HTMLResponseWriter is closed.
Method Detail

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