Source Code Cross Referenced for PropertyHolder.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » util » properties » 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 » ERP CRM Financial » Kuali Financial System » org.kuali.core.util.properties 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         * http://www.opensource.org/licenses/ecl1.php
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.kuali.core.util.properties;
017:
018:        import java.util.Iterator;
019:        import java.util.Properties;
020:
021:        import org.kuali.core.exceptions.DuplicateKeyException;
022:        import org.kuali.core.exceptions.PropertiesException;
023:
024:        /**
025:         * This class is a Property container. It is able to load properties from various property-sources.
026:         * 
027:         * 
028:         */
029:        public class PropertyHolder {
030:            Properties heldProperties;
031:
032:            /**
033:             * Default constructor.
034:             */
035:            public PropertyHolder() {
036:                this .heldProperties = new Properties();
037:            }
038:
039:            /**
040:             * @return true if this container currently has no properties
041:             */
042:            public boolean isEmpty() {
043:                return this .heldProperties.isEmpty();
044:            }
045:
046:            /**
047:             * @param key
048:             * @return true if a property with the given key exists in this container
049:             * @throws IllegalArgumentException if the given key is null
050:             */
051:            public boolean containsKey(String key) {
052:                validateKey(key);
053:
054:                return this .heldProperties.containsKey(key);
055:            }
056:
057:            /**
058:             * @param key
059:             * @return the current value of the property with the given key, or null if no property exists with that key
060:             * @throws IllegalArgumentException if the given key is null
061:             */
062:            public String getProperty(String key) {
063:                validateKey(key);
064:
065:                return this .heldProperties.getProperty(key);
066:            }
067:
068:            /**
069:             * Associates the given value with the given key
070:             * 
071:             * @param key
072:             * @param value
073:             * @throws IllegalArgumentException if the given key is null
074:             * @throws IllegalArgumentException if the given value is null
075:             * @throws DuplicateKeyException if a property with the given key already exists
076:             */
077:            public void setProperty(String key, String value) {
078:                validateKey(key);
079:                validateValue(value);
080:
081:                if (containsKey(key)) {
082:                    throw new DuplicateKeyException("duplicate key '" + key
083:                            + "'");
084:                }
085:                this .heldProperties.setProperty(key, value);
086:            }
087:
088:            /**
089:             * Removes the property with the given key from this container
090:             * 
091:             * @param key
092:             * @throws IllegalArgumentException if the given key is null
093:             */
094:            public void clearProperty(String key) {
095:                validateKey(key);
096:
097:                this .heldProperties.remove(key);
098:            }
099:
100:            /**
101:             * Copies all name,value pairs from the given PropertySource instance into this container.
102:             * 
103:             * @param source
104:             * @throws IllegalStateException if the source is invalid (improperly initialized)
105:             * @throws DuplicateKeyException the first time a given property has the same key as an existing property
106:             * @throws PropertiesException if unable to load properties from the given source
107:             */
108:            public void loadProperties(PropertySource source) {
109:                if (source == null) {
110:                    throw new IllegalArgumentException("invalid (null) source");
111:                }
112:
113:                Properties newProperties = source.loadProperties();
114:
115:                for (Iterator i = newProperties.keySet().iterator(); i
116:                        .hasNext();) {
117:                    String key = (String) i.next();
118:                    setProperty(key, newProperties.getProperty(key));
119:                }
120:            }
121:
122:            /**
123:             * Removes all properties from this container.
124:             */
125:            public void clearProperties() {
126:                this .heldProperties.clear();
127:            }
128:
129:            /**
130:             * @return iterator over the keys of all properties in this container
131:             */
132:            public Iterator getKeys() {
133:                return this .heldProperties.keySet().iterator();
134:            }
135:
136:            /**
137:             * @param key
138:             * @throws IllegalArgumentException if the given key is null
139:             */
140:            private void validateKey(String key) {
141:                if (key == null) {
142:                    throw new IllegalArgumentException("invalid (null) key");
143:                }
144:            }
145:
146:            /**
147:             * @param value
148:             * @throws IllegalArgumentException if the given value is null
149:             */
150:            private void validateValue(String value) {
151:                if (value == null) {
152:                    throw new IllegalArgumentException("invalid (null) value");
153:                }
154:            }
155:
156:            public Properties getHeldProperties() {
157:                return heldProperties;
158:            }
159:
160:            public void setHeldProperties(Properties heldProperties) {
161:                this.heldProperties = heldProperties;
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.