KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > backoffice > bean > ResourceXmlBean


1 package org.nextime.ion.backoffice.bean;
2
3 import java.io.InputStream JavaDoc;
4 import java.util.Enumeration JavaDoc;
5 import java.util.Hashtable JavaDoc;
6 import java.util.Vector JavaDoc;
7
8 import org.apache.struts.digester.Digester;
9
10 public class ResourceXmlBean {
11
12     private String JavaDoc id;
13     private String JavaDoc label;
14     private String JavaDoc directory;
15     private String JavaDoc icon;
16     private static Hashtable JavaDoc roots = new Hashtable JavaDoc();
17
18     protected static ResourceXmlBean parse(InputStream JavaDoc in) throws Exception JavaDoc {
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 JavaDoc id) {
33         return (ResourceXmlBean) roots.get(id);
34     }
35
36     protected static Vector JavaDoc getItems() {
37         Enumeration JavaDoc elts = roots.elements();
38         Vector JavaDoc retour = new Vector JavaDoc();
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     /**
50      * Returns the directory.
51      * @return String
52      */

53     public String JavaDoc getDirectory() {
54         return directory;
55     }
56
57     /**
58      * Returns the icon.
59      * @return String
60      */

61     public String JavaDoc getIcon() {
62         return icon;
63     }
64
65     /**
66      * Returns the id.
67      * @return String
68      */

69     public String JavaDoc getId() {
70         return id;
71     }
72
73     /**
74      * Returns the label.
75      * @return String
76      */

77     public String JavaDoc getLabel() {
78         return label;
79     }
80
81     /**
82      * Sets the directory.
83      * @param directory The directory to set
84      */

85     public void setDirectory(String JavaDoc directory) {
86         this.directory = directory;
87     }
88
89     /**
90      * Sets the icon.
91      * @param icon The icon to set
92      */

93     public void setIcon(String JavaDoc icon) {
94         this.icon = icon;
95     }
96
97     /**
98      * Sets the id.
99      * @param id The id to set
100      */

101     public void setId(String JavaDoc id) {
102         this.id = id;
103     }
104
105     /**
106      * Sets the label.
107      * @param label The label to set
108      */

109     public void setLabel(String JavaDoc label) {
110         this.label = label;
111     }
112
113 }
114
Popular Tags