1 package org.nextime.ion.backoffice.bean; 2 3 import java.io.InputStream ; 4 import java.util.Enumeration ; 5 import java.util.Hashtable ; 6 import java.util.Vector ; 7 8 import org.apache.struts.digester.Digester; 9 10 public class ResourceXmlBean { 11 12 private String id; 13 private String label; 14 private String directory; 15 private String icon; 16 private static Hashtable roots = new Hashtable (); 17 18 protected static ResourceXmlBean parse(InputStream in) throws Exception { 19 ResourceXmlBean bean = new ResourceXmlBean(); 20 Digester digester = new Digester(); 21 digester.push(bean); 22 digester.setValidating(false); 23 digester.addObjectCreate( 24 "resources-description/resources", 25 "org.nextime.ion.backoffice.bean.ResourceXmlBean"); 26 digester.addSetProperties("resources-description/resources"); 27 digester.addSetNext("resources-description/resources", "addResource"); 28 digester.parse(in); 29 return bean; 30 } 31 32 protected static ResourceXmlBean getResource(String id) { 33 return (ResourceXmlBean) roots.get(id); 34 } 35 36 protected static Vector getItems() { 37 Enumeration elts = roots.elements(); 38 Vector retour = new Vector (); 39 while (elts.hasMoreElements()) { 40 retour.add(elts.nextElement()); 41 } 42 return retour; 43 } 44 45 public static void addResource(ResourceXmlBean bean) { 46 roots.put(bean.getId(), bean); 47 } 48 49 53 public String getDirectory() { 54 return directory; 55 } 56 57 61 public String getIcon() { 62 return icon; 63 } 64 65 69 public String getId() { 70 return id; 71 } 72 73 77 public String getLabel() { 78 return label; 79 } 80 81 85 public void setDirectory(String directory) { 86 this.directory = directory; 87 } 88 89 93 public void setIcon(String icon) { 94 this.icon = icon; 95 } 96 97 101 public void setId(String id) { 102 this.id = id; 103 } 104 105 109 public void setLabel(String label) { 110 this.label = label; 111 } 112 113 } 114 | Popular Tags |