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(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(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    @Override
76    @Deprecated
77    public void writeAttribute(final String name, final Object value, final String property) throws IOException {
78      responseWriter.writeAttribute(name, value, property);
79    }
80  
81    @Override
82    @Deprecated
83    public void writeText(final Object text, final String property) throws IOException {
84      responseWriter.writeText(text, property);
85    }
86  
87    @Override
88    public void flush() throws IOException {
89      responseWriter.flush();
90    }
91  
92    @Override
93    public void writeAttribute(final MarkupLanguageAttributes name, final String value, final boolean escape)
94        throws IOException {
95      if (value != null) {
96        responseWriter.writeAttribute(name.getValue(), value, null);
97      }
98    }
99  
100   @Override
101   public void writeAttribute(final MarkupLanguageAttributes name, final HtmlTypes types)
102       throws IOException {
103     responseWriter.writeAttribute(name.getValue(), types.getValue(), null);
104   }
105 
106   @Override
107   public String getContentType() {
108     return responseWriter.getContentType();
109   }
110 
111   @Override
112   public String getCharacterEncoding() {
113     return responseWriter.getCharacterEncoding();
114   }
115 
116   @Override
117   public void startDocument() throws IOException {
118     responseWriter.startDocument();
119   }
120 
121   @Override
122   public void endDocument() throws IOException {
123     responseWriter.endDocument();
124   }
125 
126   @Override
127   public void writeURIAttribute(final String name, final Object value, final String property) throws IOException {
128     responseWriter.writeURIAttribute(name, value, property);
129   }
130 
131   @Override
132   public void writeURIAttribute(MarkupLanguageAttributes name, String string) throws IOException {
133     responseWriter.writeURIAttribute(name.getValue(), string, null);
134   }
135 
136   @Override
137   public void writeText(final char[] text, final int off, final int len) throws IOException {
138     responseWriter.writeText(text, off, len);
139   }
140 
141   @Override
142   public void write(final char[] chars, final int i, final int i1) throws IOException {
143     responseWriter.write(chars, i, i1);
144   }
145 
146   @Override
147   public void close() throws IOException {
148     responseWriter.close();
149   }
150 }