Source Code Cross Referenced for PreferencesImpl.java in  » Development » rapla » org » rapla » entities » configuration » internal » 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 » Development » rapla » org.rapla.entities.configuration.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*--------------------------------------------------------------------------*
002:         | Copyright (C) 2006 Christopher Kohlhaas                                  |
003:         |                                                                          |
004:         | This program is free software; you can redistribute it and/or modify     |
005:         | it under the terms of the GNU General Public License as published by the |
006:         | Free Software Foundation. A copy of the license has been included with   |
007:         | these distribution in the COPYING file, if not go to www.fsf.org         |
008:         |                                                                          |
009:         | As a special exception, you are granted the permissions to link this     |
010:         | program with every library, which license fulfills the Open Source       |
011:         | Definition as published by the Open Source Initiative (OSI).             |
012:         *--------------------------------------------------------------------------*/
013:        package org.rapla.entities.configuration.internal;
014:
015:        import java.util.HashMap;
016:        import java.util.Iterator;
017:        import java.util.Locale;
018:
019:        import org.rapla.components.util.iterator.FilterIterator;
020:        import org.rapla.components.util.iterator.NestedIterator;
021:        import org.rapla.entities.EntityNotFoundException;
022:        import org.rapla.entities.RaplaObject;
023:        import org.rapla.entities.RaplaType;
024:        import org.rapla.entities.configuration.Preferences;
025:        import org.rapla.entities.dynamictype.DynamicType;
026:        import org.rapla.entities.storage.DynamicTypeDependant;
027:        import org.rapla.entities.storage.EntityReferencer;
028:        import org.rapla.entities.storage.EntityResolver;
029:        import org.rapla.entities.storage.Mementable;
030:        import org.rapla.entities.storage.RefEntity;
031:        import org.rapla.entities.storage.internal.SimpleEntity;
032:
033:        public class PreferencesImpl extends SimpleEntity implements 
034:                Preferences, DynamicTypeDependant, Mementable,
035:                java.io.Serializable {
036:            // Don't forget to increase the serialVersionUID when you change the fields
037:            private static final long serialVersionUID = 1;
038:
039:            HashMap map = new HashMap();
040:
041:            final public RaplaType getRaplaType() {
042:                return TYPE;
043:            }
044:
045:            public void putEntry(String role, RaplaObject entry) {
046:                checkWritable();
047:                if (entry == null) {
048:                    map.remove(role);
049:                } else {
050:                    map.put(role, entry);
051:                }
052:            }
053:
054:            public void putEntry(String role, String entry) {
055:                checkWritable();
056:                if (entry == null) {
057:                    map.remove(role);
058:                } else {
059:                    map.put(role, entry);
060:                }
061:            }
062:
063:            public void resolveEntities(EntityResolver resolver)
064:                    throws EntityNotFoundException {
065:                super .resolveEntities(resolver);
066:                for (Iterator it = getEntityReferencers(); it.hasNext();) {
067:                    Object obj = it.next();
068:                    ((EntityReferencer) obj).resolveEntities(resolver);
069:                }
070:            }
071:
072:            public Object getEntry(String role) {
073:                return map.get(role);
074:            }
075:
076:            public boolean hasEntry(String role) {
077:                return map.get(role) != null;
078:            }
079:
080:            public String getEntryAsString(String role) {
081:                return (String) map.get(role);
082:            }
083:
084:            public String getEntryAsString(String role, String defaultValue) {
085:                String value = getEntryAsString(role);
086:                if (value != null)
087:                    return value;
088:                return defaultValue;
089:            }
090:
091:            public Iterator getPreferenceEntries() {
092:                return map.keySet().iterator();
093:            }
094:
095:            private Iterator getEntityReferencers() {
096:                return new FilterIterator(map.values().iterator()) {
097:                    protected boolean isInIterator(Object obj) {
098:                        return obj instanceof  EntityReferencer;
099:                    }
100:                };
101:            }
102:
103:            public Iterator getReferences() {
104:                return new NestedIterator(getEntityReferencers()) {
105:                    public Iterator getNestedIterator(Object obj) {
106:                        return ((EntityReferencer) obj).getReferences();
107:                    }
108:                };
109:            }
110:
111:            public boolean isRefering(RefEntity object) {
112:                for (Iterator it = getEntityReferencers(); it.hasNext();) {
113:                    if (((EntityReferencer) it.next()).isRefering(object)) {
114:                        return true;
115:                    }
116:                }
117:                return false;
118:            }
119:
120:            public boolean isEmpty() {
121:                return map.keySet().isEmpty();
122:            }
123:
124:            static private void copy(PreferencesImpl source,
125:                    PreferencesImpl dest) {
126:                dest.map.clear();
127:                for (Iterator it = source.map.keySet().iterator(); it.hasNext();) {
128:                    String role = (String) it.next();
129:                    Object entry = source.map.get(role);
130:                    dest.map.put(role, entry);
131:                }
132:            }
133:
134:            public void copy(Object obj) {
135:                super .copy((PreferencesImpl) obj);
136:                copy((PreferencesImpl) obj, this );
137:            }
138:
139:            public Object deepClone() {
140:                PreferencesImpl clone = new PreferencesImpl();
141:                super .deepClone(clone);
142:                copy(this , clone);
143:                return clone;
144:            }
145:
146:            public Object clone() {
147:                PreferencesImpl clone = new PreferencesImpl();
148:                super .clone(clone);
149:                copy(this , clone);
150:                return clone;
151:            }
152:
153:            /**
154:             * @see org.rapla.entities.Named#getName(java.util.Locale)
155:             */
156:            public String getName(Locale locale) {
157:                StringBuffer buf = new StringBuffer();
158:                if (getOwner() != null) {
159:                    buf.append("Preferences of ");
160:                    buf.append(getOwner().getName(locale));
161:                } else {
162:                    buf.append("Rapla Preferences!");
163:                }
164:                return buf.toString();
165:            }
166:
167:            /* (non-Javadoc)
168:             * @see org.rapla.entities.configuration.Preferences#getEntryAsBoolean(java.lang.String, boolean)
169:             */
170:            public boolean getEntryAsBoolean(String role, boolean defaultValue) {
171:                String entry = getEntryAsString(role);
172:                if (entry == null)
173:                    return defaultValue;
174:                return Boolean.valueOf(entry).booleanValue();
175:            }
176:
177:            /* (non-Javadoc)
178:             * @see org.rapla.entities.configuration.Preferences#getEntryAsInteger(java.lang.String, int)
179:             */
180:            public int getEntryAsInteger(String role, int defaultValue) {
181:                String entry = getEntryAsString(role);
182:                if (entry == null)
183:                    return defaultValue;
184:                return Integer.parseInt(entry);
185:            }
186:
187:            public boolean needsChange(DynamicType type) {
188:                for (Iterator it = map.values().iterator(); it.hasNext();) {
189:                    Object obj = it.next();
190:                    if (obj instanceof  DynamicTypeDependant) {
191:                        if (((DynamicTypeDependant) obj).needsChange(type))
192:                            return true;
193:                    }
194:                }
195:                return false;
196:            }
197:
198:            public void commitChange(DynamicType type) {
199:                for (Iterator it = map.values().iterator(); it.hasNext();) {
200:                    Object obj = it.next();
201:                    if (obj instanceof  DynamicTypeDependant) {
202:                        ((DynamicTypeDependant) obj).commitChange(type);
203:                    }
204:                }
205:            }
206:
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.