| 1 6 package com.nightlabs.ipanema.person.search; 7 8 import java.util.HashMap ; 9 import java.util.Map ; 10 11 17 public class PersonSearchFilterItemEditorHelperRegistry { 18 19 23 private Map itemEditorHelpers = new HashMap (); 24 25 32 public void addItemEditor(Class structFieldClass, PersonSearchFilterItemEditorHelper editorHelper) { 33 itemEditorHelpers.put(structFieldClass,editorHelper); 34 } 35 36 42 public void removeItemEditor(Class structFieldClass) { 43 if (!itemEditorHelpers.containsKey(structFieldClass)) 44 return; 45 itemEditorHelpers.remove(structFieldClass); 46 } 47 48 49 56 public PersonSearchFilterItemEditorHelper getEditorHelper(Class structFieldClass) 57 throws PersonSearchFilterItemEditorHelperNotFoundException { 58 PersonSearchFilterItemEditorHelper editorHelper = (PersonSearchFilterItemEditorHelper)itemEditorHelpers.get(structFieldClass); 59 if (editorHelper != null) 60 return editorHelper.newInstance(); 61 else 62 throw new PersonSearchFilterItemEditorHelperNotFoundException("Registry does not contain an entry for "+structFieldClass.getName()); 63 } 64 65 66 private static PersonSearchFilterItemEditorHelperRegistry sharedInstance; 67 68 public static PersonSearchFilterItemEditorHelperRegistry getSharedInstance() { 69 if (sharedInstance == null) { 70 sharedInstance = new PersonSearchFilterItemEditorHelperRegistry(); 71 } 72 return sharedInstance; 73 } 74 75 } 76 | Popular Tags |