Source Code Cross Referenced for XMLConfigurationEntry.java in  » Net » Coadunation_1.0.1 » com » rift » coad » lib » configuration » xml » 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 » Net » Coadunation_1.0.1 » com.rift.coad.lib.configuration.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * CoadunationLib: The coaduntion implementation library.
003:         * Copyright (C) 2006  Rift IT Contracting
004:         * 
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         * 
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
018:         *
019:         * XMLConfigurationEntry.java
020:         *
021:         * The object that stores the value for the xml configuration entry in memory.
022:         */
023:
024:        // The package
025:        package com.rift.coad.lib.configuration.xml;
026:
027:        /**
028:         * The object that stores the value for the xml configuration entry in memory.
029:         *
030:         * @author Brett Chaldecott
031:         */
032:        public class XMLConfigurationEntry {
033:
034:            // member variables
035:            private String key = null;
036:            private XMLConfigurationType type = null;
037:            private String stringValue = null;
038:            private long longValue = 0;
039:            private boolean booleanValue = false;
040:
041:            /** 
042:             * Creates a new instance of XMLConfigurationEntry 
043:             */
044:            public XMLConfigurationEntry() {
045:            }
046:
047:            /**
048:             * The getter method for the key member variable.
049:             *
050:             * @return The string containing the key value.
051:             */
052:            public String getKey() {
053:                return this .key;
054:            }
055:
056:            /**
057:             * The setter method for the key member variable.
058:             *
059:             * @param key The key value to set.
060:             */
061:            public void setKey(String key) {
062:                this .key = key;
063:            }
064:
065:            /**
066:             * The getter method for the type information.
067:             *
068:             * @return The object containing the type information.
069:             */
070:            public XMLConfigurationType getType() {
071:                return type;
072:            }
073:
074:            /**
075:             * The setter method for the type information.
076:             *
077:             * @parm type The object containing the type information.
078:             */
079:            public void setType(XMLConfigurationType type) {
080:                this .type = type;
081:            }
082:
083:            /**
084:             * The getter method for the string value.
085:             *
086:             * @return The string containing the value.
087:             * @exception XMLConfigurationException
088:             */
089:            public String getStringValue() throws XMLConfigurationException {
090:                if (type == null) {
091:                    throw new XMLConfigurationException(
092:                            "The type has not been initialized");
093:                } else if (XMLConfigurationType.STRING_VALUE == type.getType()) {
094:                    return stringValue;
095:                } else {
096:                    throw new XMLConfigurationException("The value for [" + key
097:                            + "]is not of type [string].");
098:                }
099:            }
100:
101:            /**
102:             * The setter method for the string value.
103:             *
104:             * @param value The string containing the value.
105:             * @exception XMLConfigurationException
106:             */
107:            public void setStringValue(String value)
108:                    throws XMLConfigurationException {
109:                if (type == null) {
110:                    throw new XMLConfigurationException(
111:                            "The type has not been initialized");
112:                } else if (XMLConfigurationType.STRING_VALUE == type.getType()) {
113:                    stringValue = value;
114:                } else {
115:                    throw new XMLConfigurationException(
116:                            "The value is not of type [string].");
117:                }
118:            }
119:
120:            /**
121:             * The getter method for the long value.
122:             *
123:             * @return The long value.
124:             * @exception XMLConfigurationException
125:             */
126:            public long getLongValue() throws XMLConfigurationException {
127:                if (type == null) {
128:                    throw new XMLConfigurationException(
129:                            "The type has not been initialized");
130:                } else if (XMLConfigurationType.LONG_VALUE == type.getType()) {
131:                    return longValue;
132:                } else {
133:                    throw new XMLConfigurationException(
134:                            "The value is not of type [long].");
135:                }
136:            }
137:
138:            /**
139:             * The setter method for the long value.
140:             *
141:             * @param value The long containing the value.
142:             * @exception XMLConfigurationException
143:             */
144:            public void setLongValue(long value)
145:                    throws XMLConfigurationException {
146:                if (type == null) {
147:                    throw new XMLConfigurationException(
148:                            "The type has not been initialized");
149:                } else if (XMLConfigurationType.LONG_VALUE == type.getType()) {
150:                    longValue = value;
151:                } else {
152:                    throw new XMLConfigurationException(
153:                            "The value is not of type [long].");
154:                }
155:            }
156:
157:            /**
158:             * The getter method for the boolean value.
159:             *
160:             * @return The boolean value.
161:             * @exception XMLConfigurationException
162:             */
163:            public boolean getBooleanValue() throws XMLConfigurationException {
164:                if (type == null) {
165:                    throw new XMLConfigurationException(
166:                            "The type has not been initialized");
167:                } else if (XMLConfigurationType.BOOLEAN_VALUE == type.getType()) {
168:                    return booleanValue;
169:                } else {
170:                    throw new XMLConfigurationException(
171:                            "The value is not of type [boolean].");
172:                }
173:            }
174:
175:            /**
176:             * The setter method for the boolean value.
177:             *
178:             * @param value The boolean containing the value.
179:             * @exception XMLConfigurationException
180:             */
181:            public void setBooleanValue(boolean value)
182:                    throws XMLConfigurationException {
183:                if (type == null) {
184:                    throw new XMLConfigurationException(
185:                            "The type has not been initialized");
186:                } else if (XMLConfigurationType.BOOLEAN_VALUE == type.getType()) {
187:                    booleanValue = value;
188:                } else {
189:                    throw new XMLConfigurationException(
190:                            "The value is not of type [boolean].");
191:                }
192:            }
193:
194:            /**
195:             * The operator that will set the internal long or string value
196:             *
197:             * @param value The string containing the value.
198:             * @exception XMLConfigurationException
199:             */
200:            public void setValueFromString(String value)
201:                    throws XMLConfigurationException {
202:                try {
203:                    if (type == null) {
204:                        throw new XMLConfigurationException(
205:                                "The type has not been initialized");
206:                    } else if (XMLConfigurationType.STRING_VALUE == type
207:                            .getType()) {
208:                        stringValue = value;
209:                    } else if (XMLConfigurationType.BOOLEAN_VALUE == type
210:                            .getType()) {
211:                        if (value.trim().equalsIgnoreCase("TRUE")) {
212:                            booleanValue = true;
213:                        } else {
214:                            booleanValue = false;
215:                        }
216:                    } else {
217:                        longValue = Long.parseLong(value);
218:                    }
219:                } catch (Exception ex) {
220:                    throw new XMLConfigurationException(
221:                            "Failed to store the value [" + value
222:                                    + "] because :" + ex.getMessage(), ex);
223:                }
224:            }
225:
226:            /**
227:             * This method will return true if all the member variables have been
228:             * initialized.
229:             *
230:             * @return TRUE if all the member variables have been initialized.
231:             */
232:            public boolean isIntiailized() {
233:                if ((key == null) || (type == null)) {
234:                    return false;
235:                } else if ((type.getType() == XMLConfigurationType.STRING_VALUE)
236:                        && stringValue == null) {
237:                    return false;
238:                }
239:                return true;
240:            }
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.