KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > panoptes > swing > propeditors > PropertyEditorRegistry


1 /*
2  * Created on Sep 6, 2003
3  *
4  */

5 package net.sf.panoptes.swing.propeditors;
6
7 import java.util.HashMap JavaDoc;
8
9 import sun.beans.editors.StringEditor;
10
11 /**
12  *
13  *
14  * @author Dag Liodden
15  * @version 0.1
16  */

17 public class PropertyEditorRegistry {
18     
19     
20     private HashMap JavaDoc editors = new HashMap JavaDoc();
21     private static PropertyEditorRegistry instance = null;
22
23     private PropertyEditorRegistry() {
24     }
25     
26     private static PropertyEditorRegistry getInstance() {
27         if (instance == null) instance = new PropertyEditorRegistry();
28         return instance;
29     }
30     
31     public static void registerEditor(String JavaDoc className, Class JavaDoc clazz) {
32         getInstance().editors.put(className, clazz);
33     }
34     
35     public static Class JavaDoc[] getEditor(String JavaDoc className) {
36         if (getInstance().editors.get(className) == null) return new Class JavaDoc[0];
37         else return new Class JavaDoc[] { (Class JavaDoc) getInstance().editors.get(className) };
38     }
39 }
40
Popular Tags