Source Code Cross Referenced for MapConfiguration.java in  » Library » Apache-commons-configuration-1.4-src » org » apache » commons » configuration » 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 » Library » Apache commons configuration 1.4 src » org.apache.commons.configuration 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.commons.configuration;
019:
020:        import java.util.ArrayList;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Map;
024:
025:        /**
026:         * A Map based Configuration.
027:         *
028:         * @author Emmanuel Bourg
029:         * @version $Revision: 515306 $, $Date: 2007-03-06 22:15:00 +0100 (Di, 06 Mrz 2007) $
030:         * @since 1.1
031:         */
032:        public class MapConfiguration extends AbstractConfiguration implements 
033:                Cloneable {
034:            /** The Map decorated by this configuration. */
035:            protected Map map;
036:
037:            /**
038:             * Create a Configuration decorator around the specified Map. The map is
039:             * used to store the configuration properties, any change will also affect
040:             * the Map.
041:             *
042:             * @param map the map
043:             */
044:            public MapConfiguration(Map map) {
045:                this .map = map;
046:            }
047:
048:            /**
049:             * Return the Map decorated by this configuration.
050:             *
051:             * @return the map this configuration is based onto
052:             */
053:            public Map getMap() {
054:                return map;
055:            }
056:
057:            public Object getProperty(String key) {
058:                Object value = map.get(key);
059:                if ((value instanceof  String)
060:                        && (!isDelimiterParsingDisabled())) {
061:                    List list = PropertyConverter.split((String) value,
062:                            getListDelimiter());
063:                    return list.size() > 1 ? list : list.get(0);
064:                } else {
065:                    return value;
066:                }
067:            }
068:
069:            protected void addPropertyDirect(String key, Object value) {
070:                Object previousValue = getProperty(key);
071:
072:                if (previousValue == null) {
073:                    map.put(key, value);
074:                } else if (previousValue instanceof  List) {
075:                    // the value is added to the existing list
076:                    ((List) previousValue).add(value);
077:                } else {
078:                    // the previous value is replaced by a list containing the previous value and the new value
079:                    List list = new ArrayList();
080:                    list.add(previousValue);
081:                    list.add(value);
082:
083:                    map.put(key, list);
084:                }
085:            }
086:
087:            public boolean isEmpty() {
088:                return map.isEmpty();
089:            }
090:
091:            public boolean containsKey(String key) {
092:                return map.containsKey(key);
093:            }
094:
095:            protected void clearPropertyDirect(String key) {
096:                map.remove(key);
097:            }
098:
099:            public Iterator getKeys() {
100:                return map.keySet().iterator();
101:            }
102:
103:            /**
104:             * Returns a copy of this object. The returned configuration will contain
105:             * the same properties as the original. Event listeners are not cloned.
106:             *
107:             * @return the copy
108:             * @since 1.3
109:             */
110:            public Object clone() {
111:                try {
112:                    MapConfiguration copy = (MapConfiguration) super .clone();
113:                    copy.clearConfigurationListeners();
114:                    copy.map = (Map) ConfigurationUtils.clone(map);
115:                    return copy;
116:                } catch (CloneNotSupportedException cex) {
117:                    // cannot happen
118:                    throw new ConfigurationRuntimeException(cex);
119:                }
120:            }
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.