KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * ĻON content management system.
3  * Copyright (C) 2002 Guillaume Bort(gbort@msn.com). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  * Copyright 2000-2002 (C) Intalio Inc. All Rights Reserved.
7  *
8  * ĻON is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * ĻON core framework, ĻON content server, ĻON backoffice, ĻON frontoffice
14  * and ĻON admin application are parts of ĻON and are distributed under
15  * same terms of licence.
16  *
17  *
18  * ĻON includes software developed by the Apache Software Foundation (http://www.apache.org/)
19  * and software developed by the Exolab Project (http://www.exolab.org).
20  *
21  * ĻON is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  */

26
27 package org.nextime.ion.frontoffice.bean;
28
29 import java.io.InputStream JavaDoc;
30 import java.util.Enumeration JavaDoc;
31 import java.util.Hashtable JavaDoc;
32 import java.util.Vector JavaDoc;
33
34 import org.apache.struts.digester.Digester;
35
36 public class ResourceXmlBean {
37
38     private String JavaDoc id;
39     private String JavaDoc label;
40     private String JavaDoc directory;
41     private String JavaDoc icon;
42     private static Hashtable JavaDoc roots = new Hashtable JavaDoc();
43
44     protected static ResourceXmlBean parse(InputStream JavaDoc in) throws Exception JavaDoc {
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 JavaDoc id) {
59         return (ResourceXmlBean) roots.get(id);
60     }
61
62     protected static Vector JavaDoc getItems() {
63         Enumeration JavaDoc elts = roots.elements();
64         Vector JavaDoc retour = new Vector JavaDoc();
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     /**
76      * Returns the directory.
77      * @return String
78      */

79     public String JavaDoc getDirectory() {
80         return directory;
81     }
82
83     /**
84      * Returns the icon.
85      * @return String
86      */

87     public String JavaDoc getIcon() {
88         return icon;
89     }
90
91     /**
92      * Returns the id.
93      * @return String
94      */

95     public String JavaDoc getId() {
96         return id;
97     }
98
99     /**
100      * Returns the label.
101      * @return String
102      */

103     public String JavaDoc getLabel() {
104         return label;
105     }
106
107     /**
108      * Sets the directory.
109      * @param directory The directory to set
110      */

111     public void setDirectory(String JavaDoc directory) {
112         this.directory = directory;
113     }
114
115     /**
116      * Sets the icon.
117      * @param icon The icon to set
118      */

119     public void setIcon(String JavaDoc icon) {
120         this.icon = icon;
121     }
122
123     /**
124      * Sets the id.
125      * @param id The id to set
126      */

127     public void setId(String JavaDoc id) {
128         this.id = id;
129     }
130
131     /**
132      * Sets the label.
133      * @param label The label to set
134      */

135     public void setLabel(String JavaDoc label) {
136         this.label = label;
137     }
138
139 }
140
Popular Tags