javax.faces.context
Class ResponseWriter

java.lang.Object
  extended by java.io.Writer
      extended by javax.faces.context.ResponseWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable
Direct Known Subclasses:
ResponseWriterWrapper

public abstract class ResponseWriter
extends java.io.Writer

ResponseWriter is an abstract class describing an adapter to an underlying output mechanism for character-based output. In addition to the low-level write() methods inherited from java.io.Writer, this class provides utility methods that are useful in producing elements and attributes for markup languages like HTML and XML.


Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
ResponseWriter()
           
 
Method Summary
abstract  ResponseWriter cloneWithWriter(java.io.Writer writer)
          Create and return a new instance of this ResponseWriter, using the specified Writer as the output destination.
 void endCDATA()
          

Close an XML CDATA block.

abstract  void endDocument()
          Write whatever text should end a response.
abstract  void endElement(java.lang.String name)
          Write the end of an element, after closing any open element created by a call to startElement().
abstract  void flush()
          Flush any ouput buffered by the output method to the underlying Writer or OutputStream.
abstract  java.lang.String getCharacterEncoding()
          Return the character encoding (such as "ISO-8859-1") for this ResponseWriter.
abstract  java.lang.String getContentType()
          Return the content type (such as "text/html") for this ResponseWriter.
 void startCDATA()
          

Open an XML CDATA block.

abstract  void startDocument()
          Write whatever text should begin a response.
abstract  void startElement(java.lang.String name, UIComponent component)
          Write the start of an element, up to and including the element name.
abstract  void writeAttribute(java.lang.String name, java.lang.Object value, java.lang.String property)
          Write an attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered.
abstract  void writeComment(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.
abstract  void writeText(char[] text, int off, int len)
          Write text from a character array, after any performing any escaping appropriate for the markup language being rendered.
abstract  void writeText(java.lang.Object text, java.lang.String property)
          Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered.
 void writeText(java.lang.Object text, UIComponent component, java.lang.String property)
          Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered.
abstract  void writeURIAttribute(java.lang.String name, java.lang.Object value, java.lang.String property)
          Write a URI attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any encoding appropriate to the markup language being rendered.
 
Methods inherited from class java.io.Writer
append, append, append, close, write, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResponseWriter

public ResponseWriter()
Method Detail

getContentType

public abstract java.lang.String getContentType()

Return the content type (such as "text/html") for this ResponseWriter. Note: this must not include the "charset=" suffix.


getCharacterEncoding

public abstract java.lang.String getCharacterEncoding()

Return the character encoding (such as "ISO-8859-1") for this ResponseWriter. Please see the IANA for a list of character encodings.


flush

public abstract void flush()
                    throws java.io.IOException

Flush any ouput buffered by the output method to the underlying Writer or OutputStream. This method will not flush the underlying Writer or OutputStream; it simply clears any values buffered by this ResponseWriter.

Specified by:
flush in interface java.io.Flushable
Specified by:
flush in class java.io.Writer
Throws:
java.io.IOException

startDocument

public abstract void startDocument()
                            throws java.io.IOException

Write whatever text should begin a response.

Throws:
java.io.IOException - if an input/output error occurs

endDocument

public abstract void endDocument()
                          throws java.io.IOException

Write whatever text should end a response. If there is an open element that has been created by a call to startElement(), that element will be closed first.

Throws:
java.io.IOException - if an input/output error occurs

startElement

public abstract void startElement(java.lang.String name,
                                  UIComponent component)
                           throws java.io.IOException

Write the start of an element, up to and including the element name. Once this method has been called, clients can call the writeAttribute() or writeURIAttribute() 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(), writeComment(), writeText(), endElement(), endDocument(), close(), flush(), or write().

Parameters:
name - Name of the element to be started
component - The UIComponent (if any) to which this element corresponds
Throws:
java.io.IOException - if an input/output error occurs
java.lang.NullPointerException - if name is null

endElement

public abstract void endElement(java.lang.String name)
                         throws java.io.IOException

Write the end of an element, after closing any open element created by a call to startElement(). Elements must be closed in the inverse order from which they were opened; it is an error to do otherwise.

Parameters:
name - Name of the element to be ended
Throws:
java.io.IOException - if an input/output error occurs
java.lang.NullPointerException - if name is null

writeAttribute

public abstract void writeAttribute(java.lang.String name,
                                    java.lang.Object value,
                                    java.lang.String property)
                             throws java.io.IOException

Write an attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. This method may only be called after a call to startElement(), and before the opened element has been closed.

Parameters:
name - Attribute name to be added
value - Attribute value to be added
property - Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated attribute corresponds
Throws:
IllegalStateException - if this method is called when there is no currently open element
java.io.IOException - if an input/output error occurs
java.lang.NullPointerException - if name is null

writeURIAttribute

public abstract void writeURIAttribute(java.lang.String name,
                                       java.lang.Object value,
                                       java.lang.String property)
                                throws java.io.IOException

Write a URI attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any encoding appropriate to the markup language being rendered. This method may only be called after a call to startElement(), and before the opened element has been closed.

Parameters:
name - Attribute name to be added
value - Attribute value to be added
property - Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated attribute corresponds
Throws:
IllegalStateException - if this method is called when there is no currently open element
java.io.IOException - if an input/output error occurs
java.lang.NullPointerException - if name is null

startCDATA

public void startCDATA()
                throws java.io.IOException

Open an XML CDATA block. Note that XML does not allow nested CDATA blocks, though this method does not enforce that constraint. The default implementation of this method takes no action when invoked.

Throws:
java.io.IOException - if input/output error occures

endCDATA

public void endCDATA()
              throws java.io.IOException

Close an XML CDATA block. The default implementation of this method takes no action when invoked.

Throws:
java.io.IOException - if input/output error occures

writeComment

public abstract void writeComment(java.lang.Object comment)
                           throws java.io.IOException

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.io.IOException - if an input/output error occurs
java.lang.NullPointerException - if comment is null

writeText

public abstract void writeText(java.lang.Object text,
                               java.lang.String property)
                        throws java.io.IOException

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
property - Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated text corresponds
Throws:
java.io.IOException - if an input/output error occurs
java.lang.NullPointerException - if text is null

writeText

public void writeText(java.lang.Object text,
                      UIComponent component,
                      java.lang.String property)
               throws java.io.IOException

Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. This method is equivalent to writeText(java.lang.Object,java.lang.String) but adds a component property to allow custom ResponseWriter implementations to associate a component with an arbitrary portion of text.

The default implementation simply ignores the component argument and calls through to writeText(java.lang.Object,java.lang.String)

Parameters:
text - Text to be written
component - The UIComponent (if any) to which this element corresponds
property - Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated text corresponds
Throws:
java.io.IOException - if an input/output error occurs
java.lang.NullPointerException - if text is null
Since:
1.2

writeText

public abstract void writeText(char[] text,
                               int off,
                               int len)
                        throws java.io.IOException

Write text from a character array, after any 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
off - Starting offset (zero-relative)
len - Number of characters to be written
Throws:
java.lang.IndexOutOfBoundsException - if the calculated starting or ending position is outside the bounds of the character array
java.io.IOException - if an input/output error occurs
java.lang.NullPointerException - if text is null

cloneWithWriter

public abstract ResponseWriter cloneWithWriter(java.io.Writer writer)

Create and return a new instance of this ResponseWriter, using the specified Writer as the output destination.

Parameters:
writer - The Writer that is the output destination


Submit a bug or feature

Copyright © 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.

Generated on 10-February-2011 12:41