org.ditchnet.jsp.util
Class JspResponseWriter

java.lang.Object
  extended byorg.ditchnet.jsp.util.JspResponseWriter

public final class JspResponseWriter
extends java.lang.Object

A JSP-specific XML writing utility class meant to be used as an output buffer in a JSP tag handler subclass of SimpleTag. This class should not be viewed as a general purpose XML writing utility class as several of it's methods make assumptions about the formatting of the output that make it's use in a JSP tag handler class more natural. Note that this class is not thread safe.

Version:
0.8
Author:
Todd Ditchendorf

Constructor Summary
JspResponseWriter()
          Defualt constructor -- Sets pretty printing to 'on'.
JspResponseWriter(boolean prettyPrinting)
          Allows instanciating this writer with pretty printing turned off.
 
Method Summary
 void attribute(java.lang.String prefix, Xml.Attr localName, java.lang.String value)
          Write an attribute with this namespace prefix, and local name corresponding values.
 void attribute(Xml.Attr qName, java.lang.String value)
          Write an attribute with qualified name and corresponding value.
 void comment(java.lang.Object comment)
          Write a comment containing the specified text, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered.
 void endElement(java.lang.String prefix, Xml.Tag localName)
          End an XML element with a namespace prefix and a localName.
 void endElement(Xml.Tag qName)
          End an XML element with a qualified name.
 java.lang.StringBuffer getBuffer()
           
 java.io.Writer getWriter()
           
 boolean isPrettyPrinting()
          Check for pretty printing setting.
 void lineBreak()
          This method exists for the convenience of the JSP author in manually controlling the pretty printing of the buffered output.
 void setPrettyPrinting(boolean prettyPrinting)
          Set this writer to include line breaks and tabstops in the output for easier human-readable markup.
 void startElement(java.lang.String prefix, Xml.Tag localName)
          Start an XML element with a namespace prefix and a localName.
 void startElement(Xml.Tag qName)
          Start an XML element with a qualified name, up to and including the element name.
 void tabStop()
           
 void text(java.lang.Object text)
          Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JspResponseWriter

public JspResponseWriter()
Defualt constructor -- Sets pretty printing to 'on'.


JspResponseWriter

public JspResponseWriter(boolean prettyPrinting)
Allows instanciating this writer with pretty printing turned off.

Method Detail

getBuffer

public java.lang.StringBuffer getBuffer()

getWriter

public java.io.Writer getWriter()

setPrettyPrinting

public void setPrettyPrinting(boolean prettyPrinting)
Set this writer to include line breaks and tabstops in the output for easier human-readable markup.


isPrettyPrinting

public boolean isPrettyPrinting()
Check for pretty printing setting.


tabStop

public void tabStop()

startElement

public void startElement(Xml.Tag qName)
Start an XML element with a qualified name, up to and including the element name. Once this method has been called, clients can call the writeAttribute() or methods to add attributes and corresponding values. The starting element will be closed (that is, the trailing '>' character added) on any subsequent call to startElement(), comment(), lineBreak(), text(), endElement()


startElement

public void startElement(java.lang.String prefix,
                         Xml.Tag localName)
Start an XML element with a namespace prefix and a localName.


endElement

public void endElement(Xml.Tag qName)
End an XML element with a qualified name.


endElement

public void endElement(java.lang.String prefix,
                       Xml.Tag localName)
End an XML element with a namespace prefix and a localName.


lineBreak

public void lineBreak()
This method exists for the convenience of the JSP author in manually controlling the pretty printing of the buffered output.


attribute

public void attribute(Xml.Attr qName,
                      java.lang.String value)
Write an attribute with qualified name and corresponding value. This method may only be called after a call to startElement(), and before the element has been closed.

Throws:
NullPointerException
IllegalStateException - if no element tag is currently open

attribute

public void attribute(java.lang.String prefix,
                      Xml.Attr localName,
                      java.lang.String value)
Write an attribute with this namespace prefix, and local name corresponding values. This method may only be called after a call to startElement(), and before the element has been closed.

Throws:
NullPointerException
IllegalStateException - if no element tag is currently open

text

public void text(java.lang.Object text)

Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. If there is an open element that has been created by a call to startElement(), that element will be closed first.

Parameters:
text - Text to be written
Throws:
java.lang.NullPointerException - if text is null

comment

public void comment(java.lang.Object comment)

Write a comment containing the specified text, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. If there is an open element that has been created by a call to startElement(), that element will be closed first.

Parameters:
comment - Text content of the comment
Throws:
java.lang.NullPointerException - if comment is null