1 16 package org.jahia.services.homepages; 17 18 import java.util.Hashtable ; 19 20 26 public class HomepageTypes { 27 28 public static final int HOMEPAGE_LINK = 1; 29 public static final int HOMEPAGE_COPY = 2; 30 public static final int HOMEPAGE_NEW = 3; 31 32 private static HomepageTypes instance; 33 private Hashtable types; 34 private Hashtable typeLabels; 35 private Hashtable classesNames; 36 37 38 41 protected HomepageTypes() 42 { 43 types = new Hashtable (); 44 types.put("LINK",new Integer (HOMEPAGE_LINK)); 45 types.put("COPY",new Integer (HOMEPAGE_COPY)); 46 types.put("NEW",new Integer (HOMEPAGE_NEW)); 47 48 typeLabels = new Hashtable (); 49 typeLabels.put(new Integer (HOMEPAGE_LINK),"LINK"); 50 typeLabels.put(new Integer (HOMEPAGE_COPY),"COPY"); 51 typeLabels.put(new Integer (HOMEPAGE_NEW),"NEW"); 52 53 classesNames = new Hashtable (); 54 classesNames.put( new Integer (HOMEPAGE_LINK), "org.jahia.services.homepages.JahiaHomepageLink"); 55 classesNames.put( new Integer (HOMEPAGE_COPY), "org.jahia.services.homepages.JahiaHomepageCopy"); 56 classesNames.put( new Integer (HOMEPAGE_NEW), "org.jahia.services.homepages.JahiaHomepageNew"); 57 } 58 59 64 public static synchronized HomepageTypes getInstance() 65 { 66 if (instance == null) { 67 instance = new HomepageTypes(); 68 } 69 return instance; 70 } 71 72 77 public Hashtable getTypes() 78 { 79 if ( types == null ) 80 return null; 81 82 85 Hashtable hash = new Hashtable (); 86 hash.put("LINK",new Integer (HOMEPAGE_LINK)); 87 88 return hash; 89 } 90 91 97 public int getType(String key) 98 { 99 if ( key == null ) 100 return -1; 101 102 Integer type = (Integer ) types.get(key); 103 104 if ( type == null ) 105 return -1; 106 107 return type.intValue(); 108 } 109 110 116 public String getTypeName(int type) 117 { 118 Integer I = new Integer (type); 119 String name = (String )typeLabels.get(I); 120 121 if ( name == null ) 122 return "UNKNOWN"; 123 124 return name; 125 } 126 127 128 133 public Hashtable getClassesNames() 134 { 135 if ( classesNames == null ) 136 classesNames = new Hashtable (); 137 138 Hashtable hash = (Hashtable ) classesNames.clone(); 139 return hash; 140 141 } 142 143 } | Popular Tags |