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  package org.apache.myfaces.renderkits;
20  
21  import org.apache.myfaces.renderkit.html.HtmlRenderKitImpl;
22  
23  import javax.faces.context.ResponseStream;
24  import javax.faces.context.ResponseWriter;
25  import javax.faces.render.RenderKit;
26  import javax.faces.render.Renderer;
27  import javax.faces.render.ResponseStateManager;
28  import java.io.IOException;
29  import java.io.OutputStream;
30  import java.io.Writer;
31  
32  /**
33   * @author martin.haimberger
34   */
35  public class OwnRenderKitImpl
36          extends RenderKit {
37  
38      RenderKit renderKit = new HtmlRenderKitImpl();
39  
40      public Renderer getRenderer(String componentFamily, String rendererType) {
41          OwnRenderkitTest.SetIsOwnRenderKit();
42          return renderKit.getRenderer(componentFamily, rendererType);
43      }
44  
45      public void addRenderer(String componentFamily, String rendererType, Renderer renderer) {
46          renderKit.addRenderer(componentFamily, rendererType, renderer);
47      }
48  
49      public ResponseStateManager getResponseStateManager() {
50          return renderKit.getResponseStateManager();
51      }
52  
53      public ResponseWriter createResponseWriter(Writer writer,
54                                                 String contentTypeListString,
55                                                 String characterEncoding) {
56  
57  
58          return renderKit.createResponseWriter(writer, contentTypeListString, characterEncoding);
59      }
60  
61      public ResponseStream createResponseStream(OutputStream outputStream) {
62          final OutputStream output = outputStream;
63  
64          return new ResponseStream() {
65              public void write(int b) throws IOException {
66                  output.write(b);
67              }
68  
69  
70              public void write(byte b[]) throws IOException {
71                  output.write(b);
72              }
73  
74  
75              public void write(byte b[], int off, int len) throws IOException {
76                  output.write(b, off, len);
77              }
78  
79  
80              public void flush() throws IOException {
81                  output.flush();
82              }
83  
84  
85              public void close() throws IOException {
86                  output.close();
87              }
88          };
89      }
90  
91  
92  }