Source Code Cross Referenced for XmlBeansSettingsImpl.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » settings » 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 Services » soapui 1.7.5 » com.eviware.soapui.impl.settings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
003:         *
004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
006:         *  the Free Software Foundation.
007:         *
008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
010:         *  See the GNU Lesser General Public License for more details at gnu.org.
011:         */
012:
013:        package com.eviware.soapui.impl.settings;
014:
015:        import java.util.HashMap;
016:        import java.util.HashSet;
017:        import java.util.List;
018:        import java.util.Map;
019:        import java.util.Set;
020:
021:        import com.eviware.soapui.config.SettingConfig;
022:        import com.eviware.soapui.config.SettingsConfig;
023:        import com.eviware.soapui.model.ModelItem;
024:        import com.eviware.soapui.model.settings.Settings;
025:        import com.eviware.soapui.model.settings.SettingsListener;
026:
027:        /**
028:         * Settings implementation for XmlBeans generated SettingsConfig
029:         * 
030:         * @author Ole.Matzura
031:         */
032:
033:        public class XmlBeansSettingsImpl implements  Settings {
034:            private final Settings parent;
035:            private final SettingsConfig config;
036:            private final Map<String, SettingConfig> values = new HashMap<String, SettingConfig>();
037:            private final Set<SettingsListener> listeners = new HashSet<SettingsListener>();
038:            private final ModelItem item;
039:            private final SettingsListener settingsListener = new WeakSettingsListener(
040:                    new InternalSettingsListener());
041:
042:            public XmlBeansSettingsImpl(ModelItem item, Settings parent,
043:                    SettingsConfig config) {
044:                this .item = item;
045:                this .config = config;
046:                this .parent = parent;
047:
048:                List<SettingConfig> settingList = config.getSettingList();
049:                for (SettingConfig setting : settingList) {
050:                    values.put(setting.getId(), setting);
051:                }
052:
053:                if (parent != null) {
054:                    parent.addSettingsListener(settingsListener);
055:                }
056:            }
057:
058:            public boolean isSet(String id) {
059:                return values.containsKey(id);
060:            }
061:
062:            public String getString(String id, String defaultValue) {
063:                if (values.containsKey(id))
064:                    return values.get(id).getStringValue();
065:                return parent == null ? defaultValue : parent.getString(id,
066:                        defaultValue);
067:            }
068:
069:            public void setString(String id, String value) {
070:                String oldValue = getString(id, null);
071:
072:                if (oldValue == null && value == null)
073:                    return;
074:
075:                if (value != null && value.equals(oldValue))
076:                    return;
077:
078:                if (value == null) {
079:                    clearSetting(id);
080:                } else {
081:                    if (!values.containsKey(id)) {
082:                        SettingConfig setting = config.addNewSetting();
083:                        setting.setId(id);
084:                        values.put(id, setting);
085:                    }
086:
087:                    values.get(id).setStringValue(value);
088:                }
089:
090:                notifySettingChanged(id, value, oldValue);
091:            }
092:
093:            private void notifySettingChanged(String id, String value,
094:                    String oldValue) {
095:                SettingsListener[] l = listeners
096:                        .toArray(new SettingsListener[listeners.size()]);
097:                for (SettingsListener listener : l) {
098:                    listener.settingChanged(id, value, oldValue);
099:                }
100:            }
101:
102:            public boolean getBoolean(String id) {
103:                if (values.containsKey(id))
104:                    return Boolean
105:                            .parseBoolean(values.get(id).getStringValue());
106:
107:                return parent == null ? false : parent.getBoolean(id);
108:            }
109:
110:            public long getLong(String id, long defaultValue) {
111:                if (values.containsKey(id)) {
112:                    try {
113:                        return Long.parseLong(values.get(id).getStringValue());
114:                    } catch (NumberFormatException e) {
115:                    }
116:                }
117:
118:                return parent == null ? defaultValue : parent.getLong(id,
119:                        defaultValue);
120:            }
121:
122:            public void setBoolean(String id, boolean value) {
123:                setString(id, Boolean.toString(value));
124:            }
125:
126:            public void addSettingsListener(SettingsListener listener) {
127:                listeners.add(listener);
128:            }
129:
130:            public void removeSettingsListener(SettingsListener listener) {
131:                listeners.remove(listener);
132:            }
133:
134:            public void clearSetting(String id) {
135:                if (values.containsKey(id)) {
136:                    int ix = config.getSettingList().indexOf(values.get(id));
137:                    config.removeSetting(ix);
138:                    values.remove(id);
139:                }
140:            }
141:
142:            public ModelItem getModelItem() {
143:                return item;
144:            }
145:
146:            public void release() {
147:                if (listeners != null)
148:                    listeners.clear();
149:
150:                if (parent != null)
151:                    parent.removeSettingsListener(settingsListener);
152:            }
153:
154:            private final class InternalSettingsListener implements 
155:                    SettingsListener {
156:                public void settingChanged(String name, String newValue,
157:                        String oldValue) {
158:                    if (!values.containsKey(name)) {
159:                        notifySettingChanged(name, newValue, oldValue);
160:                    }
161:                }
162:            }
163:
164:            public void setLong(String id, long value) {
165:                setString(id, Long.toString(value));
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.