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: struberg $)
35   * @version $Revision: 1188565 $ $Date: 2011-10-25 03:38:53 -0500 (Tue, 25 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          {
50              throw new NullPointerException ("type is null");
51          }
52          
53          if (renderer == null)
54          {
55              throw new NullPointerException ("renderer is null");
56          }
57          
58          this.clientBehaviorRenderers.put (type, renderer);
59      }
60  
61      public abstract void addRenderer(String family, String rendererType, Renderer renderer);
62  
63      public abstract ResponseStream createResponseStream(OutputStream out);
64  
65      public abstract ResponseWriter createResponseWriter(Writer writer, String contentTypeList,
66                                                          String characterEncoding);
67      
68      public ClientBehaviorRenderer getClientBehaviorRenderer(String type)
69      {
70          if (type == null)
71          {
72              throw new NullPointerException ("type is null");
73          }
74          
75          return this.clientBehaviorRenderers.get (type);
76      }
77      
78      public Iterator<String> getClientBehaviorRendererTypes()
79      {
80          return this.clientBehaviorRenderers.keySet().iterator();
81      }
82  
83      /**
84       * <p>
85       * Return an <code>Iterator</code> over the component-family entries supported by this <code>RenderKit</code>
86       * instance.
87       * </p>
88       * 
89       * <p>
90       * The default implementation of this method returns an empty <code>Iterator</code>
91       * </p>
92       * 
93       * @return an iterator over the component families supported by this <code>RenderKit</code>.
94       * 
95       * @since 2.0
96       */
97      public Iterator<String> getComponentFamilies()
98      {
99          List<String> emptyList = Collections.emptyList();
100 
101         return emptyList.iterator();
102     }
103 
104     public abstract Renderer getRenderer(String family, String rendererType);
105 
106     /**
107      * <p>
108      * Return an <code>Iterator</code> over the renderer-type entries for the given component-family.
109      * </p>
110      * 
111      * <p>
112      * If the specified <code>componentFamily</code> is not known to this <code>RenderKit</code> implementation, return
113      * an empty <code>Iterator</code>
114      * </p>
115      * 
116      * <p>
117      * The default implementation of this method returns an empty <code>Iterator</code>
118      * </p>
119      * 
120      * @param componentFamily
121      *            one of the members of the <code>Iterator</code> returned by {@link #getComponentFamilies()}
122      * 
123      * @return an iterator over the renderer-type entries for the given component-family.
124      * 
125      * @since 2.0
126      */
127     public Iterator<String> getRendererTypes(String componentFamily)
128     {
129         List<String> emptyList = Collections.emptyList();
130 
131         return emptyList.iterator();
132     }
133 
134     public abstract ResponseStateManager getResponseStateManager();
135 }