Source Code Cross Referenced for TransientPropertySet.java in  » Web-Framework » argun » biz » hammurapi » web » 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 » Web Framework » argun » biz.hammurapi.web.properties 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * argun 1.0
003:         * Web 2.0 delivery framework 
004:         * Copyright (C) 2007  Hammurapi Group
005:         *
006:         * This program 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 of the License, or (at your option) any later version.
010:         *
011:         * This program 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  USA
019:         *
020:         * URL: http://www.hammurapi.biz
021:         * e-Mail: support@hammurapi.biz 
022:         */
023:        package biz.hammurapi.web.properties;
024:
025:        import java.util.HashMap;
026:        import java.util.HashSet;
027:        import java.util.Iterator;
028:        import java.util.Map;
029:        import java.util.Set;
030:
031:        import org.w3c.dom.Element;
032:
033:        import biz.hammurapi.xml.dom.AbstractDomObject;
034:
035:        public class TransientPropertySet implements  PropertySet {
036:            private Map map = new HashMap();
037:
038:            public TransientPropertySet() {
039:                // Default constructor
040:            }
041:
042:            public TransientPropertySet(Map source) {
043:                if (source != null) {
044:                    map.putAll(source);
045:                }
046:            }
047:
048:            public Set getPropertyNames() {
049:                return new HashSet(map.entrySet());
050:            }
051:
052:            public PropertySet getSubset(String prefix) {
053:                return new PropertySubSet(this , prefix);
054:            }
055:
056:            public void remove(String name) {
057:                map.remove(name);
058:            }
059:
060:            public void set(String name, Object value) {
061:                map.put(name, value);
062:            }
063:
064:            public Object get(String name) {
065:                Object ret = map.get(name);
066:                if (ret == null) {
067:                    Iterator mit = mounts.entrySet().iterator();
068:                    while (mit.hasNext()) {
069:                        Map.Entry entry = (Map.Entry) mit.next();
070:                        String prefix = (String) entry.getKey();
071:                        if (name.startsWith(prefix)) {
072:                            ret = ((PropertySet) entry.getValue()).get(name
073:                                    .substring(prefix.length()));
074:                            if (ret != null) {
075:                                return ret;
076:                            }
077:                        }
078:                    }
079:                }
080:                return ret;
081:            }
082:
083:            public void clear() {
084:                map.clear();
085:            }
086:
087:            public void load(PropertySet source) {
088:                Iterator it = source.getPropertyNames().iterator();
089:                while (it.hasNext()) {
090:                    String key = (String) it.next();
091:                    set(key, source.get(key));
092:                }
093:            }
094:
095:            private Map mounts = new HashMap();
096:
097:            public void mount(String prefix, PropertySet source) {
098:                mounts.put(prefix, source);
099:            }
100:
101:            public void toDom(Element holder) {
102:                Iterator pit = getPropertyNames().iterator();
103:                while (pit.hasNext()) {
104:                    String pName = (String) pit.next();
105:                    Object pValue = get(pName);
106:                    Element pe = AbstractDomObject.addTextElement(holder,
107:                            "property", pValue.toString());
108:                    pe.setAttribute("name", pName);
109:                    pe.setAttribute("type", pValue.getClass().getName());
110:                }
111:            }
112:
113:            public void setAll(PropertySet source) {
114:                Iterator nit = source.getPropertyNames().iterator();
115:                while (nit.hasNext()) {
116:                    String pName = (String) nit.next();
117:                    set(pName, source.get(pName));
118:                }
119:            }
120:
121:            /**
122:             * @return true if other property set entries are equal to this property set entries. 
123:             * Other Property set attribute
124:             */
125:            public boolean compareProperties(PropertySet otherSet) {
126:                Set myNames = new HashSet(getPropertyNames());
127:                Set otherNames = new HashSet(otherSet.getPropertyNames());
128:                if (!myNames.equals(otherNames)) {
129:                    return false;
130:                }
131:
132:                Iterator nit = myNames.iterator();
133:                while (nit.hasNext()) {
134:                    String pName = (String) nit.next();
135:                    Object myValue = get(pName);
136:                    Object otherValue = otherSet.get(pName);
137:                    if (myValue == null) {
138:                        if (otherValue != null) {
139:                            return false;
140:                        }
141:                    } else if (!myValue.equals(otherValue)) {
142:                        return false;
143:                    }
144:                }
145:
146:                return true;
147:            }
148:
149:            public boolean containsAll(PropertySet subSet) {
150:                Set myNames = new HashSet(getPropertyNames());
151:                Set subsetNames = new HashSet(subSet.getPropertyNames());
152:                if (!myNames.containsAll(subsetNames)) {
153:                    return false;
154:                }
155:
156:                Iterator nit = subsetNames.iterator();
157:                while (nit.hasNext()) {
158:                    String pName = (String) nit.next();
159:                    Object myValue = get(pName);
160:                    Object subsetValue = subSet.get(pName);
161:                    if (myValue == null) {
162:                        if (subsetValue != null) {
163:                            return false;
164:                        }
165:                    } else if (!myValue.equals(subsetValue)) {
166:                        return false;
167:                    }
168:                }
169:
170:                return true;
171:            }
172:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.