Source Code Cross Referenced for XMLConfiguration.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:         * XMLConfiguration.java
020:         *
021:         * The class containing the configuration information for a specific class.
022:         */
023:
024:        // package
025:        package com.rift.coad.lib.configuration.xml;
026:
027:        // java imports
028:        import java.util.Map;
029:        import java.util.HashMap;
030:        import java.util.Set;
031:
032:        // coadunation imports
033:        import com.rift.coad.lib.configuration.Configuration;
034:        import com.rift.coad.lib.configuration.ConfigurationException;
035:
036:        /**
037:         * The class containing the configuration information for a specific class.
038:         *
039:         * @author Brett Chaldecott
040:         */
041:        public class XMLConfiguration implements  Configuration {
042:
043:            // the classes member varialbes
044:            private String className = null;
045:            private Map entries = null;
046:
047:            /** 
048:             * Creates a new instance of XMLConfiguration 
049:             *
050:             * @param className The name of the class.
051:             */
052:            public XMLConfiguration(String className) {
053:                this .className = className;
054:                this .entries = new HashMap();
055:            }
056:
057:            /**
058:             * This method returns the name of the class.
059:             *
060:             * @return The string containing the name of the class.
061:             */
062:            public String getClassName() {
063:                return className;
064:            }
065:
066:            /**
067:             * This method returns TRUE if the key supplied is present in the data.
068:             *
069:             * @return TRUE if the key has been found.
070:             * @param key The key to perform the search for.
071:             * @exception ConfigurationException
072:             */
073:            public boolean containsKey(String key)
074:                    throws ConfigurationException {
075:                return entries.containsKey(key);
076:            }
077:
078:            /**
079:             * This method returns the list of keys
080:             *
081:             * @return The set containing the list of keys.
082:             * @exception ConfigurationException
083:             */
084:            public Set getKeys() throws ConfigurationException {
085:                return entries.keySet();
086:            }
087:
088:            /**
089:             * This method returns true if the object is a string.
090:             *
091:             * @return TRUE if string, FALSE if not.
092:             * @param key The key to check the string type of.
093:             * @exception ConfigurationException
094:             */
095:            public boolean isString(String key) throws ConfigurationException {
096:                XMLConfigurationEntry entry = (XMLConfigurationEntry) entries
097:                        .get(key);
098:                if (entry == null) {
099:                    throw new ConfigurationException("The entry [" + key
100:                            + "] does not exist");
101:                }
102:                if (entry.getType().getType() == XMLConfigurationType.STRING_VALUE) {
103:                    return true;
104:                }
105:                return false;
106:            }
107:
108:            /**
109:             * The method that returns the string value for the requested key
110:             *
111:             * @return The string containing the configuration information.
112:             * @param key The key to retrieve the value for.
113:             * @exception ConfigurationException
114:             */
115:            public String getString(String key) throws ConfigurationException {
116:                XMLConfigurationEntry entry = (XMLConfigurationEntry) entries
117:                        .get(key);
118:                if (entry == null) {
119:                    throw new ConfigurationException("The entry [" + key
120:                            + "] does not exist");
121:                }
122:                return entry.getStringValue();
123:            }
124:
125:            /**
126:             * The method that returns the string value for the requested key
127:             *
128:             * @return The string containing the configuration information.
129:             * @param key The key to retrieve the value for.
130:             * @param defValue The default value.
131:             * @exception ConfigurationException
132:             */
133:            public String getString(String key, String defValue)
134:                    throws ConfigurationException {
135:                XMLConfigurationEntry entry = (XMLConfigurationEntry) entries
136:                        .get(key);
137:                if (entry == null) {
138:                    return defValue;
139:                }
140:                return entry.getStringValue();
141:            }
142:
143:            /**
144:             * This method set the configuration value for the key.
145:             *
146:             * @param key The key to set the value for.
147:             * @param value The new value to set.
148:             * @exception ConfigurationException
149:             */
150:            public void setString(String key, String value)
151:                    throws ConfigurationException {
152:                throw new ConfigurationException("Not Implemented");
153:            }
154:
155:            /**
156:             * This method returns true if the object is a long.
157:             *
158:             * @return TRUE if long, FALSE if not.
159:             * @param key The key to check the long type of.
160:             * @exception ConfigurationException
161:             */
162:            public boolean isLong(String key) throws ConfigurationException {
163:                XMLConfigurationEntry entry = (XMLConfigurationEntry) entries
164:                        .get(key);
165:                if (entry == null) {
166:                    throw new ConfigurationException("The entry [" + key
167:                            + "] does not exist");
168:                }
169:                if (entry.getType().getType() == XMLConfigurationType.LONG_VALUE) {
170:                    return true;
171:                }
172:                return false;
173:            }
174:
175:            /**
176:             * The method that will retrieve the long value from the configuration file.
177:             *
178:             * @return The long value.
179:             * @param key identifying the long value.
180:             * @exception ConfigurationException
181:             */
182:            public long getLong(String key) throws ConfigurationException {
183:                XMLConfigurationEntry entry = (XMLConfigurationEntry) entries
184:                        .get(key);
185:                if (entry == null) {
186:                    throw new ConfigurationException("The entry [" + key
187:                            + "] does not exist");
188:                }
189:                return entry.getLongValue();
190:            }
191:
192:            /**
193:             * The method that will retrieve the long value from the configuration file.
194:             *
195:             * @return The long value.
196:             * @param key identifying the long value.
197:             * @param defValue The default long value.
198:             * @exception ConfigurationException
199:             */
200:            public long getLong(String key, long defValue)
201:                    throws ConfigurationException {
202:                XMLConfigurationEntry entry = (XMLConfigurationEntry) entries
203:                        .get(key);
204:                if (entry == null) {
205:                    return defValue;
206:                }
207:                return entry.getLongValue();
208:            }
209:
210:            /**
211:             * The method to set a configuration key value.
212:             *
213:             * @param key The key to set the value for.
214:             * @param value The value for the key.
215:             * @exception ConfigurationException
216:             */
217:            public void setLong(String key, long value)
218:                    throws ConfigurationException {
219:                throw new ConfigurationException("Not Implemented");
220:            }
221:
222:            /**
223:             * This method returns true if the object is a boolean.
224:             *
225:             * @return TRUE if long, FALSE if not.
226:             * @param key The key to check the long type of.
227:             * @exception ConfigurationException
228:             */
229:            public boolean isBoolean(String key) throws ConfigurationException {
230:                XMLConfigurationEntry entry = (XMLConfigurationEntry) entries
231:                        .get(key);
232:                if (entry == null) {
233:                    throw new ConfigurationException("The entry [" + key
234:                            + "] does not exist");
235:                }
236:                if (entry.getType().getType() == XMLConfigurationType.BOOLEAN_VALUE) {
237:                    return true;
238:                }
239:                return false;
240:            }
241:
242:            /**
243:             * The method that will retrieve the boolean value from the configuration.
244:             *
245:             * @return TRUE of FALSE
246:             * @param key identifying the boolean value.
247:             * @exception ConfigurationException
248:             */
249:            public boolean getBoolean(String key) throws ConfigurationException {
250:                XMLConfigurationEntry entry = (XMLConfigurationEntry) entries
251:                        .get(key);
252:                if (entry == null) {
253:                    throw new ConfigurationException("The entry [" + key
254:                            + "] does not exist");
255:                }
256:                return entry.getBooleanValue();
257:            }
258:
259:            /**
260:             * The method that will retrieve the boolean value from the configuration.
261:             *
262:             * @return The boolean value.
263:             * @param key identifying the boolean value.
264:             * @param defValue The default boolean value.
265:             * @exception ConfigurationException
266:             */
267:            public boolean getBoolean(String key, boolean defValue)
268:                    throws ConfigurationException {
269:                XMLConfigurationEntry entry = (XMLConfigurationEntry) entries
270:                        .get(key);
271:                if (entry == null) {
272:                    return defValue;
273:                }
274:                return entry.getBooleanValue();
275:            }
276:
277:            /**
278:             * The method to set a configuration key value.
279:             *
280:             * @param key The key to set the value for.
281:             * @param value The value for the key.
282:             * @exception ConfigurationException
283:             */
284:            public void setBoolean(String key, boolean value)
285:                    throws ConfigurationException {
286:                throw new ConfigurationException("Not implemented");
287:            }
288:
289:            /**
290:             * This method will save the configuration information.
291:             *
292:             * @exception ConfigurationException
293:             */
294:            public void saveConfiguration() throws ConfigurationException {
295:                throw new ConfigurationException("Not Implemented");
296:            }
297:
298:            /**
299:             * This method adds the configuration entry to the list.
300:             *
301:             * @param entry The entry to add to the configuration list.
302:             */
303:            public void addConfigurationEntry(XMLConfigurationEntry entry) {
304:                entries.put(entry.getKey(), entry);
305:            }
306:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.