Source Code Cross Referenced for EnvEntryDesc.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_lib » deployment » api » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » org.objectweb.jonas_lib.deployment.api 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or 1any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * Initial developer: Christophe Ney
022:         * --------------------------------------------------------------------------
023:         * $Id: EnvEntryDesc.java 7351 2005-09-07 17:16:59Z benoitf $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas_lib.deployment.api;
026:
027:        import org.objectweb.jonas_lib.deployment.xml.EnvEntry;
028:
029:        /**
030:         * This class represents the description of an EnvEntry object
031:         * @author Christophe Ney
032:         * @author Florent Benoit
033:         */
034:        public class EnvEntryDesc {
035:
036:            /**
037:             * The env entry name.
038:             */
039:            private String name;
040:
041:            /**
042:             * The env entry type.
043:             */
044:            private Class type;
045:
046:            /**
047:             * The env entry value.
048:             */
049:            private Object value;
050:
051:            /**
052:             * Construct a descriptor for an env-entry tag.
053:             * @param env the env-entry resulting of the xml parsing.
054:             * @throws DeploymentDescException when missing information for
055:             * creating the EnvEntryDesc.
056:             */
057:            public EnvEntryDesc(EnvEntry env) throws DeploymentDescException {
058:                name = env.getEnvEntryName();
059:                String t = env.getEnvEntryType();
060:                String v = null;
061:                if (env.getEnvEntryValue() != null) {
062:                    v = env.getEnvEntryValue();
063:                }
064:                try {
065:                    if (t.equals(Boolean.class.getName())) {
066:                        type = Boolean.class;
067:                        if (v != null) {
068:                            if (v.equalsIgnoreCase("true")) {
069:                                value = Boolean.TRUE;
070:                            } else if (v.equalsIgnoreCase("false")) {
071:                                value = Boolean.FALSE;
072:                            } else {
073:                                throw new DeploymentDescException(
074:                                        v
075:                                                + " is not a valid value for env-entry "
076:                                                + name);
077:                            }
078:                        } else {
079:                            value = Boolean.FALSE;
080:                        }
081:
082:                    } else if (t.equals(String.class.getName())) {
083:                        type = String.class;
084:                        if (v != null) {
085:                            value = v;
086:                        } else {
087:                            value = new String();
088:                        }
089:                    } else if (t.equals(Integer.class.getName())) {
090:                        type = Integer.class;
091:                        if (v != null) {
092:                            value = new Integer(v);
093:                        } else {
094:                            value = new Integer(0);
095:                        }
096:                    } else if (t.equals(Character.class.getName())) {
097:                        type = Character.class;
098:                        if (v != null) {
099:                            if (v.length() != 1) {
100:                                throw new DeploymentDescException(
101:                                        "The value '"
102:                                                + v
103:                                                + "' is not a valid value for env-entry of type java.lang.Character.");
104:                            }
105:                            value = new Character(v.charAt(0));
106:                        } else {
107:                            value = new Character("".charAt(0));
108:                        }
109:                    } else if (t.equals(Double.class.getName())) {
110:                        type = Double.class;
111:                        if (v != null) {
112:                            value = new Double(v);
113:                        } else {
114:                            value = new Double(0);
115:                        }
116:                    } else if (t.equals(Byte.class.getName())) {
117:                        type = Byte.class;
118:                        if (v != null) {
119:                            value = new Byte(v);
120:                        } else {
121:                            value = new Byte("");
122:                        }
123:                    } else if (t.equals(Short.class.getName())) {
124:                        type = Short.class;
125:                        if (v != null) {
126:                            value = new Short(v);
127:                        } else {
128:                            value = new Short("");
129:                        }
130:                    } else if (t.equals(Long.class.getName())) {
131:                        type = Long.class;
132:                        if (v != null) {
133:                            value = new Long(v);
134:                        } else {
135:                            value = new Long(0);
136:                        }
137:                    } else if (t.equals(Float.class.getName())) {
138:                        type = Float.class;
139:                        if (v != null) {
140:                            value = new Float(v);
141:                        } else {
142:                            value = new Float(0);
143:                        }
144:                    } else {
145:                        throw new DeploymentDescException(t
146:                                + " is not a valid type for env-entry " + name);
147:                    }
148:                } catch (NumberFormatException e) {
149:                    throw new DeploymentDescException(v
150:                            + " is not a valid value for env-entry " + name, e);
151:                }
152:
153:            }
154:
155:            /**
156:             * Get the name of the environemt entry.
157:             * @return Name for environment entry
158:             */
159:            public String getName() {
160:                return name;
161:            }
162:
163:            /**
164:             * Get the fully-qualified Java type of the environemt entry.
165:             * Type is needed since value is optional
166:             * The possibles values are:
167:             *   java.lang.Boolean
168:             *   java.lang.Character
169:             *   java.lang.String
170:             *   java.lang.Integer
171:             *   java.lang.Double
172:             *   java.lang.Byte
173:             *   java.lang.Short
174:             *   java.lang.Long
175:             *   java.lang.Float
176:             * @return Class the fully-qualified Java type of the environemt entry.
177:             */
178:            public Class getType() {
179:                return type;
180:            }
181:
182:            /**
183:             * Assessor for existence of value for the descriptor
184:             * @return true if a value is available
185:             */
186:            public boolean hasValue() {
187:                return value != null;
188:            }
189:
190:            /**
191:             * Get the value of the environment entry.
192:             * @return value for the environment entry (must be set)
193:             */
194:            public Object getValue() {
195:                // An env-entry value is optional, so no error should be thrown
196:                /*
197:                 *  if (value == null) {
198:                 *      throw new Error("Value not set for env-entry " + name);
199:                 *  }
200:                 */
201:                return value;
202:            }
203:
204:            /**
205:             * String representation of the object for test purpose
206:             * @return String representation of this object
207:             */
208:            public String toString() {
209:                StringBuffer ret = new StringBuffer();
210:                ret.append("\ngetName()=" + getName());
211:                ret.append("\ngetType()=" + getType());
212:                if (hasValue()) {
213:                    ret.append("\ngetValue()=" + getValue().toString());
214:                }
215:                return ret.toString();
216:            }
217:
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.