KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > wap > renderkit > WmlRenderKitImpl


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.wap.renderkit;
17
18 import javax.faces.render.Renderer;
19 import javax.faces.render.RenderKit;
20
21 import javax.faces.render.ResponseStateManager;
22
23 import java.util.*;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27
28 /**
29  * @author <a HREF="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author: matzew $)
30  * @version $Revision: 1.1 $ $Date: 2004/12/30 09:37:27 $
31  * $Log: WmlRenderKitImpl.java,v $
32  * Revision 1.1 2004/12/30 09:37:27 matzew
33  * added a new RenderKit for WML. Thanks to Jirí Žaloudek
34  *
35  */

36 public class WmlRenderKitImpl extends RenderKit {
37     private static Log log = LogFactory.getLog(WmlRenderKitImpl.class);
38     
39     private Map renderers;
40     private ResponseStateManager rsm;
41     
42     /** Creates a new instance of RenderKitImpl */
43     public WmlRenderKitImpl() {
44         log.debug("created object " + this.getClass().getName());
45         renderers = new HashMap();
46         rsm = new WmlResponseStateManagerImpl();
47         //rsm = new com.sun.faces.renderkit.ResponseStateManagerImpl();
48
}
49     
50     public void addRenderer(String JavaDoc family, String JavaDoc rendererType, javax.faces.render.Renderer renderer) {
51         renderers.put(family + "." + rendererType, renderer);
52     }
53     
54     public Renderer getRenderer(String JavaDoc family, String JavaDoc rendererType) {
55         log.debug("getRenderer() family:" + family + " renderType:" + rendererType);
56         Renderer renderer = (Renderer)renderers.get(family + "." + rendererType);
57         if (renderer == null){
58             log.warn("Unsupported component-family/renderer-type: " + family + "/" + rendererType);
59         }
60         return(renderer);
61     }
62     
63     public ResponseStateManager getResponseStateManager() {
64         return(rsm);
65     }
66     
67     public javax.faces.context.ResponseStream createResponseStream(java.io.OutputStream JavaDoc outputStream) {
68         throw new UnsupportedOperationException JavaDoc(this.getClass().getName() + " UnsupportedOperationException");
69     }
70     
71     public javax.faces.context.ResponseWriter createResponseWriter(java.io.Writer JavaDoc writer, String JavaDoc contentTypeList, String JavaDoc characterEncoding) {
72         log.debug("createResponseWriter()");
73         if (contentTypeList == null) {
74             log.info("No content type list given, creating WmlResponseWriterImpl with default content type.");
75             return new WmlResponseWriterImpl(writer, null, characterEncoding);
76         }
77         
78         StringTokenizer st = new StringTokenizer(contentTypeList, ",");
79         while (st.hasMoreTokens()) {
80             String JavaDoc contentType = st.nextToken().trim();
81             return new WmlResponseWriterImpl(writer, contentType, characterEncoding);
82         }
83         
84         throw new IllegalArgumentException JavaDoc("ContentTypeList does not contain a supported content type: " + contentTypeList);
85     }
86     
87 }
88
Popular Tags