javax.faces.context.ResponseWriterWrapper Maven / Gradle / Ivy
Show all versions of jboss-jsf-api_2.3_spec Show documentation
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package javax.faces.context;
import java.io.IOException;
import java.io.Writer;
import javax.faces.FacesWrapper;
import javax.faces.component.UIComponent;
/**
* Provides a simple implementation
* of {@link ResponseWriter} that
* can be subclassed by developers wishing to provide specialized
* behavior to an existing {@link ResponseWriter} instance. The default
* implementation of all methods is to call through to the wrapped
* {@link ResponseWriter}.
*
* Usage: extend this class and push the implementation being wrapped to the
* constructor and use {@link #getWrapped} to access the instance being wrapped.
*
* @since 1.2
*/
public abstract class ResponseWriterWrapper extends ResponseWriter implements FacesWrapper {
private ResponseWriter wrapped;
/**
* @deprecated Use the other constructor taking the implementation being wrapped.
*/
@Deprecated
public ResponseWriterWrapper() {
}
/**
* If this response writer has been decorated,
* the implementation doing the decorating should push the implementation being wrapped to this constructor.
* The {@link #getWrapped()} will then return the implementation being wrapped.
*
* @param wrapped The implementation being wrapped.
* @since 2.3
*/
public ResponseWriterWrapper(ResponseWriter wrapped) {
this.wrapped = wrapped;
}
@Override
public ResponseWriter getWrapped() {
return wrapped;
}
// -------------------------- Methods from javax.faces.context.ResponseWriter
/**
* The default behavior of this method is to
* call {@link ResponseWriter#getContentType()}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#getContentType()
* @since 1.2
*/
@Override
public String getContentType() {
return getWrapped().getContentType();
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#getCharacterEncoding()}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#getCharacterEncoding()
* @since 1.2
*/
@Override
public String getCharacterEncoding() {
return getWrapped().getCharacterEncoding();
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#flush()}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#flush()
* @since 1.2
*/
@Override
public void flush() throws IOException {
getWrapped().flush();
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#startDocument()}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#startDocument()
* @since 1.2
*/
@Override
public void startDocument() throws IOException {
getWrapped().startDocument();
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#endDocument()}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#endDocument()
* @since 1.2
*/
@Override
public void endDocument() throws IOException {
getWrapped().endDocument();
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#startElement(String, javax.faces.component.UIComponent)}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#startElement(String, javax.faces.component.UIComponent)
* @since 1.2
*/
@Override
public void startElement(String name, UIComponent component)
throws IOException {
getWrapped().startElement(name, component);
}
/**
* The default behavior of this method
* is to call {@link ResponseWriter#startCDATA} on the wrapped
* {@link ResponseWriter} object.
* @since 2.0
* @throws IOException on any read/write error
*/
@Override
public void startCDATA() throws IOException {
getWrapped().startCDATA();
}
/**
* The default behavior of this method
* is to call {@link ResponseWriter#endCDATA} on the wrapped
* {@link ResponseWriter} object.
* @since 2.0
* @throws IOException on any read/write error
*/
@Override
public void endCDATA() throws IOException {
getWrapped().endCDATA();
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#endElement(String)}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#endElement(String)
* @since 1.2
* @throws IOException on any read/write error
*/
@Override
public void endElement(String name) throws IOException {
getWrapped().endElement(name);
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#writeAttribute(String, Object, String)}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#writeAttribute(String, Object, String)
* @since 1.2
*/
@Override
public void writeAttribute(String name, Object value, String property)
throws IOException {
getWrapped().writeAttribute(name, value, property);
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#writeURIAttribute(String, Object, String)}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#writeURIAttribute(String, Object, String)
* @since 1.2
*/
@Override
public void writeURIAttribute(String name, Object value, String property)
throws IOException {
getWrapped().writeURIAttribute(name, value, property);
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#writeComment(Object)}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#writeComment(Object)
* @since 1.2
*/
@Override
public void writeComment(Object comment) throws IOException {
getWrapped().writeComment(comment);
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#writeDoctype}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#writeDoctype
* @since 2.2
*/
@Override
public void writeDoctype(String doctype) throws IOException {
getWrapped().writeDoctype(doctype);
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#writePreamble}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#writePreamble
* @since 2.2
*/
@Override
public void writePreamble(String preamble) throws IOException {
getWrapped().writePreamble(preamble);
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#writeText(Object, String)}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#writeText(Object, String)
* @since 1.2
*/
@Override
public void writeText(Object text, String property) throws IOException {
getWrapped().writeText(text, property);
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#writeText(Object, UIComponent, String)}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#writeText(Object, String)
* @since 1.2
*/
@Override
public void writeText(Object text, UIComponent component, String property)
throws IOException {
getWrapped().writeText(text, component, property);
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#writeText(char[], int, int)}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#writeText(char[], int, int)
* @since 1.2
*/
@Override
public void writeText(char[] text, int off, int len) throws IOException {
getWrapped().writeText(text, off, len);
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#cloneWithWriter(java.io.Writer)}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#cloneWithWriter(java.io.Writer)
* @since 1.2
*/
@Override
public ResponseWriter cloneWithWriter(Writer writer) {
return getWrapped().cloneWithWriter(writer);
}
// --------------------------------------------- Methods from java.io.Writer
/**
* The default behavior of this method is to
* call {@link ResponseWriter#close()}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#close()
* @since 1.2
*/
@Override
public void close() throws IOException {
getWrapped().close();
}
/**
* The default behavior of this method is to
* call {@link ResponseWriter#write(char[], int, int)}
* on the wrapped {@link ResponseWriter} object.
*
* @see ResponseWriter#write(char[], int, int)
* @since 1.2
*/
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
getWrapped().write(cbuf, off, len);
}
}