Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * $Id: ResponseWriter.java,v 1.18 2006/03/24 19:05:33 edburns Exp $
   */
  
  /*
   * The contents of this file are subject to the terms
   * of the Common Development and Distribution License
   * (the License). You may not use this file except in
   * compliance with the License.
  * 
  * You can obtain a copy of the License at
  * https://javaserverfaces.dev.java.net/CDDL.html or
  * legal/CDDLv1.0.txt. 
  * See the License for the specific language governing
  * permission and limitations under the License.
  * 
  * When distributing Covered Code, include this CDDL
  * Header Notice in each file and include the License file
  * at legal/CDDLv1.0.txt.    
  * If applicable, add the following below the CDDL Header,
  * with the fields enclosed by brackets [] replaced by
  * your own identifying information:
  * "Portions Copyrighted [year] [name of copyright owner]"
  * 
  * [Name of File] [ver.__] [Date]
  * 
  * Copyright 2005 Sun Microsystems Inc. All Rights Reserved
  */
 
 package javax.faces.context;
 
 
 import 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.

 
 
 public abstract class ResponseWriter extends Writer {


    

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

 
     public abstract String getContentType();


    

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

 
     public abstract String getCharacterEncoding();


    

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.

 
     public abstract void flush() throws IOException;


    

Write whatever text should begin a response.

Throws:
java.io.IOException if an input/output error occurs
 
     public abstract void startDocument() throws 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
 
     public abstract void endDocument() throws 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 javax.faces.component.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
    public abstract void startElement(String nameUIComponent component)
        throws 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
    public abstract void endElement(String namethrows 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 javax.faces.component.UIComponent associated with the containing element, to which this generated attribute corresponds
Throws:
java.lang.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
    public abstract void writeAttribute(String nameObject value
					String property)
        throws 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 javax.faces.component.UIComponent associated with the containing element, to which this generated attribute corresponds
Throws:
java.lang.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
    public abstract void writeURIAttribute(String nameObject value
					   String property)
        throws 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
    public abstract void writeComment(Object commentthrows 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 javax.faces.component.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
    public abstract void writeText(Object textString property)
        throws 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 javax.faces.component.UIComponent (if any) to which this element corresponds
property Name of the property or attribute (if any) of the javax.faces.component.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
    public void writeText(Object textUIComponent componentString property)
        throws IOException {
	writeText(textproperty);
    }


    

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
    public abstract void writeText(char text[], int offint len)
        throws IOException;


    

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
    public abstract ResponseWriter cloneWithWriter(Writer writer);
New to GrepCode? Check out our FAQ X