Source Code Cross Referenced for FragmentPropertyMap.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » om » page » impl » 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 » Portal » jetspeed 2.1.3 » org.apache.jetspeed.om.page.impl 
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:        package org.apache.jetspeed.om.page.impl;
018:
019:        import java.util.AbstractMap;
020:        import java.util.AbstractSet;
021:        import java.util.Collection;
022:        import java.util.Iterator;
023:        import java.util.Map;
024:        import java.util.Set;
025:
026:        import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
027:
028:        /**
029:         * FragmentPropertyMap
030:         *
031:         * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
032:         * @version $Id$
033:         */
034:        class FragmentPropertyMap extends AbstractMap {
035:            private FragmentImpl fragment;
036:            private FragmentPropertiesEntrySet entrySet;
037:
038:            FragmentPropertyMap(FragmentImpl fragment) {
039:                super ();
040:                this .fragment = fragment;
041:                // populate fragment properties using property members
042:                entrySet = new FragmentPropertiesEntrySet();
043:                Iterator keyIter = fragment.getPropertyMemberKeys().iterator();
044:                while (keyIter.hasNext()) {
045:                    String key = (String) keyIter.next();
046:                    entrySet.add(new FragmentPropertiesEntry(key, fragment
047:                            .getPropertyMember(key)));
048:                }
049:            }
050:
051:            /* (non-Javadoc)
052:             * @see java.util.Map#put(java.lang.Object, java.lang.Object)
053:             */
054:            public Object put(Object key, Object value) {
055:                // implement for modifiable AbstractMap:
056:                // set map entry value or add new map entry
057:                // using iterator to find key entry
058:                FragmentPropertiesEntry entry = new FragmentPropertiesEntry(
059:                        key, value);
060:                Iterator entryIter = entrySet.iterator();
061:                while (entryIter.hasNext()) {
062:                    FragmentPropertiesEntry testEntry = (FragmentPropertiesEntry) entryIter
063:                            .next();
064:                    if (testEntry.equals(entry)) {
065:                        Object oldValue = testEntry.getValue();
066:                        testEntry.setValue(entry.getValue());
067:                        return oldValue;
068:                    }
069:                }
070:                entrySet.add(entry);
071:                return null;
072:            }
073:
074:            /* (non-Javadoc)
075:             * @see java.util.Map#entrySet()
076:             */
077:            public Set entrySet() {
078:                // implement for modifiable AbstractMap
079:                return entrySet;
080:            }
081:
082:            private class FragmentPropertiesEntrySet extends AbstractSet {
083:                private Collection entries = DatabasePageManagerUtils
084:                        .createCollection();
085:
086:                /* (non-Javadoc)
087:                 * @see java.util.Set#add(java.lang.Object)
088:                 */
089:                public boolean add(Object o) {
090:                    // implement for modifiable AbstractSet:
091:                    FragmentPropertiesEntry entry = (FragmentPropertiesEntry) o;
092:                    if (!entries.contains(entry)) {
093:                        // set fragment explicit property member
094:                        fragment.setPropertyMember(entry.getKey().toString(),
095:                                entry.getValue().toString());
096:                        // add entry to set
097:                        entries.add(o);
098:                        return true;
099:                    }
100:                    return false;
101:                }
102:
103:                /* (non-Javadoc)
104:                 * @see java.util.Set#iterator()
105:                 */
106:                public Iterator iterator() {
107:                    // implement for modifiable AbstractSet:
108:                    return new Iterator() {
109:                        private Iterator iter = entries.iterator();
110:                        private FragmentPropertiesEntry last;
111:
112:                        /* (non-Javadoc)
113:                         * @see java.util.Iterator#hasNext()
114:                         */
115:                        public boolean hasNext() {
116:                            // implement for modifiable AbstractSet:
117:                            return iter.hasNext();
118:                        }
119:
120:                        /* (non-Javadoc)
121:                         * @see java.util.Iterator#next()
122:                         */
123:                        public Object next() {
124:                            // implement for modifiable AbstractSet:
125:                            last = (FragmentPropertiesEntry) iter.next();
126:                            return last;
127:                        }
128:
129:                        /* (non-Javadoc)
130:                         * @see java.util.Iterator#remove()
131:                         */
132:                        public void remove() {
133:                            // implement for modifiable AbstractSet:
134:                            // clear fragment explicit property associated with entry
135:                            if (last == null) {
136:                                throw new IllegalStateException(
137:                                        "No preceding call to next() or remove() already invoked");
138:                            }
139:                            FragmentPropertyMap.this .fragment
140:                                    .clearPropertyMember(last.getKey()
141:                                            .toString());
142:                            last = null;
143:                            // remove entry using iterator
144:                            iter.remove();
145:                        }
146:                    };
147:                }
148:
149:                /* (non-Javadoc)
150:                 * @see java.util.Set#size()
151:                 */
152:                public int size() {
153:                    // implement for modifiable AbstractSet:
154:                    return entries.size();
155:                }
156:            }
157:
158:            private class FragmentPropertiesEntry implements  Map.Entry {
159:                private Object key;
160:                private Object value;
161:
162:                public FragmentPropertiesEntry(Object key, Object value) {
163:                    this .key = key;
164:                    this .value = value;
165:                }
166:
167:                /* (non-Javadoc)
168:                 * @see java.util.Map.Entry#getKey()
169:                 */
170:                public Object getKey() {
171:                    return key;
172:                }
173:
174:                /* (non-Javadoc)
175:                 * @see java.util.Map.Entry#getValue()
176:                 */
177:                public Object getValue() {
178:                    return value;
179:                }
180:
181:                /* (non-Javadoc)
182:                 * @see java.util.Map.Entry#setValue(java.lang.Object)
183:                 */
184:                public Object setValue(Object newValue) {
185:                    // set fragment explicit property associated with entry
186:                    FragmentPropertyMap.this .fragment.setPropertyMember(key
187:                            .toString(), newValue.toString());
188:                    // set entry value
189:                    Object oldValue = value;
190:                    value = newValue;
191:                    return oldValue;
192:                }
193:
194:                /* (non-Javadoc)
195:                 * @see java.lang.Object#equals(java.lang.Object)
196:                 */
197:                public boolean equals(Object o) {
198:                    if (o instanceof  FragmentPropertiesEntry) {
199:                        if (key != null) {
200:                            return key.equals(((FragmentPropertiesEntry) o)
201:                                    .getKey());
202:                        }
203:                        return (((FragmentPropertiesEntry) o).getKey() == null);
204:                    }
205:                    return false;
206:                }
207:
208:                /* (non-Javadoc)
209:                 * @see java.lang.Object#hashCode()
210:                 */
211:                public int hashCode() {
212:                    if (key != null) {
213:                        return key.hashCode();
214:                    }
215:                    return 0;
216:                }
217:            }
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.