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 javax.faces.render;
20  
21  import java.io.OutputStream;
22  import java.io.Writer;
23  import java.util.Collections;
24  import java.util.HashMap;
25  import java.util.Iterator;
26  import java.util.List;
27  
28  import javax.faces.context.ResponseStream;
29  import javax.faces.context.ResponseWriter;
30  
31  /**
32   * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
33   * 
34   * @author Manfred Geiler (latest modification by $Author: bommel $)
35   * @version $Revision: 1187700 $ $Date: 2011-10-22 07:19:37 -0500 (Sat, 22 Oct 2011) $
36   */
37  public abstract class RenderKit
38  {
39      private HashMap<String, ClientBehaviorRenderer> clientBehaviorRenderers;
40      
41      public RenderKit ()
42      {
43          this.clientBehaviorRenderers = new HashMap<String, ClientBehaviorRenderer>();
44      }
45      
46      public void addClientBehaviorRenderer(String type, ClientBehaviorRenderer renderer)
47      {
48          if (type == null) {
49              throw new NullPointerException ("type is null");
50          }
51          
52          if (renderer == null) {
53              throw new NullPointerException ("renderer is null");
54          }
55          
56          this.clientBehaviorRenderers.put (type, renderer);
57      }
58  
59      public abstract void addRenderer(String family, String rendererType, Renderer renderer);
60  
61      public abstract ResponseStream createResponseStream(OutputStream out);
62  
63      public abstract ResponseWriter createResponseWriter(Writer writer, String contentTypeList, String characterEncoding);
64      
65      public ClientBehaviorRenderer getClientBehaviorRenderer(String type)
66      {
67          if (type == null) {
68              throw new NullPointerException ("type is null");
69          }
70          
71          return this.clientBehaviorRenderers.get (type);
72      }
73      
74      public Iterator<String> getClientBehaviorRendererTypes()
75      {
76          return this.clientBehaviorRenderers.keySet().iterator();
77      }
78  
79      /**
80       * <p>
81       * Return an <code>Iterator</code> over the component-family entries supported by this <code>RenderKit</code>
82       * instance.
83       * </p>
84       * 
85       * <p>
86       * The default implementation of this method returns an empty <code>Iterator</code>
87       * </p>
88       * 
89       * @return an iterator over the component families supported by this <code>RenderKit</code>.
90       * 
91       * @since 2.0
92       */
93      public Iterator<String> getComponentFamilies()
94      {
95          List<String> emptyList = Collections.emptyList();
96  
97          return emptyList.iterator();
98      }
99  
100     public abstract Renderer getRenderer(String family, String rendererType);
101 
102     /**
103      * <p>
104      * Return an <code>Iterator</code> over the renderer-type entries for the given component-family.
105      * </p>
106      * 
107      * <p>
108      * If the specified <code>componentFamily</code> is not known to this <code>RenderKit</code> implementation, return
109      * an empty <code>Iterator</code>
110      * </p>
111      * 
112      * <p>
113      * The default implementation of this method returns an empty <code>Iterator</code>
114      * </p>
115      * 
116      * @param componentFamily
117      *            one of the members of the <code>Iterator</code> returned by {@link #getComponentFamilies()}
118      * 
119      * @return an iterator over the renderer-type entries for the given component-family.
120      * 
121      * @since 2.0
122      */
123     public Iterator<String> getRendererTypes(String componentFamily)
124     {
125         List<String> emptyList = Collections.emptyList();
126 
127         return emptyList.iterator();
128     }
129 
130     public abstract ResponseStateManager getResponseStateManager();
131 }