KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ejb > meta > EnvEntryDescriptor


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6 package org.jfox.ejb.meta;
7
8 import org.jfox.ioc.util.XMLUtils;
9 import org.w3c.dom.Node JavaDoc;
10
11 /**
12  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
13  */

14
15 public class EnvEntryDescriptor extends Descriptor {
16     private String JavaDoc name;
17     private String JavaDoc type;
18     private String JavaDoc value;
19
20     public EnvEntryDescriptor() {
21     }
22
23     public void processXML(Node JavaDoc node) throws EJBDescriptionException {
24         super.processXML(node);
25         setName(XMLUtils.getChildNodeValueOf(node, "env-entry-name"));
26         setType(XMLUtils.getChildNodeValueOf(node, "env-entry-type"));
27         setValue(XMLUtils.getChildNodeValueOf(node, "env-entry-value"));
28     }
29
30     public String JavaDoc getName() {
31         return name;
32     }
33
34     public void setName(String JavaDoc name) {
35         this.name = name;
36     }
37
38     public String JavaDoc getType() {
39         return type;
40     }
41
42     public void setType(String JavaDoc type) {
43         this.type = type;
44     }
45
46     public String JavaDoc getValue() {
47         return value;
48     }
49
50     public void setValue(String JavaDoc value) {
51         this.value = value;
52     }
53
54     public Object JavaDoc getValueObject() {
55         String JavaDoc type = getType();
56         if(value == null || "".equals(value) && !type.equals("java.lang.String"))
57             return null;
58         if(type.equals("java.lang.Boolean"))
59             return new Boolean JavaDoc(value);
60         if(type.equals("java.lang.String"))
61             return value;
62         if(type.equals("java.lang.Integer"))
63             return new Integer JavaDoc(value);
64         if(type.equals("java.lang.Double"))
65             return new Double JavaDoc(value);
66         if(type.equals("java.lang.Byte"))
67             return new Byte JavaDoc(value);
68         if(type.equals("java.lang.Short"))
69             return new Short JavaDoc(value);
70         if(type.equals("java.lang.Long"))
71             return new Long JavaDoc(value);
72         if(type.equals("java.lang.Float"))
73             return new Float JavaDoc(value);
74         else
75             throw new IllegalArgumentException JavaDoc("Illegal type for environment entry: " + type);
76     }
77
78     public boolean equals(Object JavaDoc obj) {
79         if(obj instanceof EnvEntryDescriptor)
80             return name.equals(((EnvEntryDescriptor) obj).name);
81         else
82             return false;
83     }
84
85     public int hashCode() {
86         return name.hashCode();
87     }
88
89     public static void main(String JavaDoc[] args) {
90
91     }
92 }
93
94
Popular Tags