1 26 27 package org.nextime.ion.frontoffice.bean; 28 29 import java.io.InputStream ; 30 import java.util.Enumeration ; 31 import java.util.Hashtable ; 32 import java.util.Vector ; 33 34 import org.apache.struts.digester.Digester; 35 36 public class ResourceXmlBean { 37 38 private String id; 39 private String label; 40 private String directory; 41 private String icon; 42 private static Hashtable roots = new Hashtable (); 43 44 protected static ResourceXmlBean parse(InputStream in) throws Exception { 45 ResourceXmlBean bean = new ResourceXmlBean(); 46 Digester digester = new Digester(); 47 digester.push(bean); 48 digester.setValidating(false); 49 digester.addObjectCreate( 50 "resources-description/resources", 51 "org.nextime.ion.frontoffice.bean.ResourceXmlBean"); 52 digester.addSetProperties("resources-description/resources"); 53 digester.addSetNext("resources-description/resources", "addResource"); 54 digester.parse(in); 55 return bean; 56 } 57 58 protected static ResourceXmlBean getResource(String id) { 59 return (ResourceXmlBean) roots.get(id); 60 } 61 62 protected static Vector getItems() { 63 Enumeration elts = roots.elements(); 64 Vector retour = new Vector (); 65 while (elts.hasMoreElements()) { 66 retour.add(elts.nextElement()); 67 } 68 return retour; 69 } 70 71 public static void addResource(ResourceXmlBean bean) { 72 roots.put(bean.getId(), bean); 73 } 74 75 79 public String getDirectory() { 80 return directory; 81 } 82 83 87 public String getIcon() { 88 return icon; 89 } 90 91 95 public String getId() { 96 return id; 97 } 98 99 103 public String getLabel() { 104 return label; 105 } 106 107 111 public void setDirectory(String directory) { 112 this.directory = directory; 113 } 114 115 119 public void setIcon(String icon) { 120 this.icon = icon; 121 } 122 123 127 public void setId(String id) { 128 this.id = id; 129 } 130 131 135 public void setLabel(String label) { 136 this.label = label; 137 } 138 139 } 140 | Popular Tags |