KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > gui > controlx > impl > RenderKitImpl


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.gui.controlx.impl;
14
15 import info.magnolia.cms.gui.controlx.RenderKit;
16 import info.magnolia.cms.gui.controlx.Renderer;
17
18 import java.util.HashMap JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import org.apache.commons.collections.Factory;
22 import org.apache.commons.collections.MapUtils;
23
24
25 /**
26  * If a not registered render type is passed a TemplatedRenderer instance is returned.
27  * @author Philipp Bracher
28  * @version $Revision: 6341 $ ($Author: philipp $)
29  */

30 public class RenderKitImpl implements RenderKit {
31
32     /**
33      * The renderers registered.
34      */

35     protected Map JavaDoc renderers;
36
37     /**
38      * Init the layzy map.
39      */

40     public RenderKitImpl() {
41         renderers = MapUtils.lazyMap(new HashMap JavaDoc(), new Factory() {
42
43             public Object JavaDoc create() {
44                 return new TemplatedRenderer();
45             }
46         });
47     }
48
49     /**
50      * @see info.magnolia.cms.gui.controlx.RenderKit#register(java.lang.String, info.magnolia.cms.gui.controlx.Renderer)
51      */

52     public void register(String JavaDoc type, Renderer renderer) {
53         this.renderers.put(type, renderer);
54     }
55
56     /**
57      * @see info.magnolia.cms.gui.controlx.RenderKit#getRenderer(java.lang.String)
58      */

59     public Renderer getRenderer(String JavaDoc type) {
60         // using the lazy map
61
return (Renderer) this.renderers.get(type);
62     }
63
64 }
65
Popular Tags