View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.internal.webapp;
21  
22  import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
23  import org.apache.myfaces.tobago.renderkit.html.HtmlTypes;
24  import org.apache.myfaces.tobago.renderkit.html.MarkupLanguageAttributes;
25  import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
26  
27  import javax.faces.component.UIComponent;
28  import javax.faces.context.ResponseWriter;
29  import java.io.IOException;
30  import java.io.Writer;
31  
32  public class TobagoResponseWriterWrapper extends TobagoResponseWriter {
33  
34    private ResponseWriter responseWriter;
35  
36    public TobagoResponseWriterWrapper(final ResponseWriter responseWriter) {
37      this.responseWriter = responseWriter;
38    }
39  
40    @Override
41    public void startElement(final String name, final UIComponent component) throws IOException {
42      responseWriter.startElement(name, component);
43    }
44  
45    @Override
46    public void startElement(final HtmlElements name) throws IOException {
47      responseWriter.startElement(name.getValue(), null);
48    }
49  
50    @Override
51    public void endElement(final String name) throws IOException {
52      responseWriter.endElement(name);
53    }
54  
55    @Override
56    public void endElement(final HtmlElements name) throws IOException {
57      responseWriter.endElement(name.getValue());
58    }
59  
60    @Override
61    public void write(final String string) throws IOException {
62      responseWriter.write(string);
63    }
64  
65    @Override
66    public void writeComment(final Object comment) throws IOException {
67      responseWriter.writeComment(comment);
68    }
69  
70    @Override
71    public ResponseWriter cloneWithWriter(final Writer writer) {
72      return responseWriter.cloneWithWriter(writer);
73    }
74  
75    /**
76     * @deprecated since 1.0.11
77     */
78    @Override
79    @Deprecated
80    public void writeAttribute(final String name, final Object value, final String property) throws IOException {
81      responseWriter.writeAttribute(name, value, property);
82    }
83  
84    /**
85     * @deprecated since 1.0.11
86     */
87    @Override
88    @Deprecated
89    public void writeText(final Object text, final String property) throws IOException {
90      responseWriter.writeText(text, property);
91    }
92  
93    @Override
94    public void flush() throws IOException {
95      responseWriter.flush();
96    }
97  
98    @Override
99    public void writeAttribute(final MarkupLanguageAttributes name, final String value, final boolean escape)
100       throws IOException {
101     if (value != null) {
102       responseWriter.writeAttribute(name.getValue(), value, null);
103     }
104   }
105 
106   @Override
107   public void writeAttribute(final MarkupLanguageAttributes name, final HtmlTypes types)
108       throws IOException {
109     responseWriter.writeAttribute(name.getValue(), types.getValue(), null);
110   }
111 
112   @Override
113   public String getContentType() {
114     return responseWriter.getContentType();
115   }
116 
117   @Override
118   public String getCharacterEncoding() {
119     return responseWriter.getCharacterEncoding();
120   }
121 
122   @Override
123   public void startDocument() throws IOException {
124     responseWriter.startDocument();
125   }
126 
127   @Override
128   public void endDocument() throws IOException {
129     responseWriter.endDocument();
130   }
131 
132   @Override
133   public void writeURIAttribute(final String name, final Object value, final String property) throws IOException {
134     responseWriter.writeURIAttribute(name, value, property);
135   }
136 
137   @Override
138   public void writeURIAttribute(final MarkupLanguageAttributes name, final String string) throws IOException {
139     responseWriter.writeURIAttribute(name.getValue(), string, null);
140   }
141 
142   @Override
143   public void writeText(final char[] text, final int off, final int len) throws IOException {
144     responseWriter.writeText(text, off, len);
145   }
146 
147   @Override
148   public void write(final char[] chars, final int i, final int i1) throws IOException {
149     responseWriter.write(chars, i, i1);
150   }
151 
152   @Override
153   public void close() throws IOException {
154     responseWriter.close();
155   }
156 }