Source Code Cross Referenced for AttributeValueMap.java in  » Workflow-Engines » obe-1.0 » org » obe » spi » util » 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 » Workflow Engines » obe 1.0 » org.obe.spi.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.obe.spi.util;
002:
003:        import org.obe.client.api.repository.RepositoryException;
004:        import org.obe.engine.util.Comparators;
005:        import org.obe.spi.model.AttributeInstance;
006:        import org.obe.spi.model.AttributeReadOnlyException;
007:        import org.obe.spi.model.AttributedEntity;
008:        import org.obe.xpdl.model.data.Type;
009:
010:        import java.util.*;
011:
012:        /**
013:         * Provides keyed access to attribute values by adapting an
014:         * {@link AttributedEntity}. Instances of this class are maps whose keys are
015:         * attribute names and whose values are the corresponding attribute values.
016:         *
017:         * @author Adrian Price
018:         */
019:        public class AttributeValueMap implements  Map {
020:            private final Map _delegate;
021:            private Set _entries;
022:
023:            private static class AttributeValueEntry implements  Map.Entry {
024:                private final Map.Entry _delegate;
025:
026:                AttributeValueEntry(Map.Entry delegate) {
027:                    _delegate = delegate;
028:                }
029:
030:                public int hashCode() {
031:                    return _delegate.hashCode();
032:                }
033:
034:                public Object getKey() {
035:                    return _delegate.getKey();
036:                }
037:
038:                public Object getValue() {
039:                    return ((AttributeInstance) _delegate.getValue())
040:                            .getValue();
041:                }
042:
043:                public boolean equals(Object obj) {
044:                    return _delegate.equals(obj);
045:                }
046:
047:                public Object setValue(Object value) {
048:                    AttributeInstance attrInst = (AttributeInstance) _delegate
049:                            .getValue();
050:                    Object oldValue = attrInst.getValue();
051:                    try {
052:                        attrInst.setValue(Type.DEFAULT_TYPE, value);
053:                    } catch (AttributeReadOnlyException e) {
054:                        throw new UnsupportedOperationException(e.getMessage());
055:                    }
056:                    return oldValue;
057:                }
058:            }
059:
060:            private static class AttributeValueEntrySet implements  Set {
061:                private final Set _delegate;
062:
063:                private AttributeValueEntrySet(Set delegate) {
064:                    _delegate = delegate;
065:                }
066:
067:                public int hashCode() {
068:                    return _delegate.hashCode();
069:                }
070:
071:                public int size() {
072:                    return _delegate.size();
073:                }
074:
075:                public void clear() {
076:                    _delegate.clear();
077:                }
078:
079:                public boolean isEmpty() {
080:                    return _delegate.isEmpty();
081:                }
082:
083:                public Object[] toArray() {
084:                    Object[] a = _delegate.toArray();
085:                    for (int i = 0; i < a.length; i++) {
086:                        a[i] = new AttributeValueEntry((Entry) a[i]);
087:                    }
088:                    return a;
089:                }
090:
091:                public Object[] toArray(Object[] a) {
092:                    a = _delegate.toArray(a);
093:                    for (int i = 0; i < a.length; i++) {
094:                        a[i] = new AttributeValueEntry((Entry) a[i]);
095:                    }
096:                    return a;
097:                }
098:
099:                public boolean add(Object o) {
100:                    return _delegate.add(o);
101:                }
102:
103:                public boolean contains(Object o) {
104:                    return _delegate.contains(o);
105:                }
106:
107:                public boolean equals(Object obj) {
108:                    return _delegate.equals(obj);
109:                }
110:
111:                public boolean remove(Object o) {
112:                    return _delegate.remove(o);
113:                }
114:
115:                public boolean addAll(Collection coll) {
116:                    return _delegate.addAll(coll);
117:                }
118:
119:                public boolean containsAll(Collection coll) {
120:                    return _delegate.containsAll(coll);
121:                }
122:
123:                public boolean removeAll(Collection coll) {
124:                    return _delegate.removeAll(coll);
125:                }
126:
127:                public boolean retainAll(Collection coll) {
128:                    return _delegate.retainAll(coll);
129:                }
130:
131:                public Iterator iterator() {
132:                    return new AttributeValueEntrySetIterator(_delegate
133:                            .iterator());
134:                }
135:            }
136:
137:            private static class AttributeValueEntrySetIterator implements 
138:                    Iterator {
139:                private final Iterator _delegate;
140:
141:                AttributeValueEntrySetIterator(Iterator delegate) {
142:                    _delegate = delegate;
143:                }
144:
145:                public void remove() {
146:                    _delegate.remove();
147:                }
148:
149:                public boolean hasNext() {
150:                    return _delegate.hasNext();
151:                }
152:
153:                public Object next() {
154:                    return new AttributeValueEntry((Entry) _delegate.next());
155:                }
156:            }
157:
158:            public AttributeValueMap(AttributedEntity entity)
159:                    throws RepositoryException {
160:
161:                _delegate = entity.getAttributeInstances();
162:            }
163:
164:            public int hashCode() {
165:                return _delegate.hashCode();
166:            }
167:
168:            public int size() {
169:                return _delegate.size();
170:            }
171:
172:            public void clear() {
173:                _delegate.clear();
174:            }
175:
176:            public boolean isEmpty() {
177:                return _delegate.isEmpty();
178:            }
179:
180:            public boolean containsKey(Object key) {
181:                return _delegate.containsKey(key);
182:            }
183:
184:            public boolean containsValue(Object value) {
185:                Collection values = _delegate.values();
186:                for (Iterator iter = values.iterator(); iter.hasNext();) {
187:                    AttributeInstance attrInst = (AttributeInstance) iter
188:                            .next();
189:                    if (Comparators.equals(attrInst.getValue(), value)) {
190:                        return true;
191:                    }
192:                }
193:                return false;
194:            }
195:
196:            public boolean equals(Object obj) {
197:                return _delegate.equals(obj);
198:            }
199:
200:            public Collection values() {
201:                Collection attrs = _delegate.values();
202:                Collection values = new ArrayList(attrs.size());
203:                for (Iterator iter = attrs.iterator(); iter.hasNext();) {
204:                    AttributeInstance attrInst = (AttributeInstance) iter
205:                            .next();
206:                    values.add(attrInst.getValue());
207:                }
208:                return values;
209:            }
210:
211:            public void putAll(Map t) {
212:                _delegate.putAll(t);
213:            }
214:
215:            public Set entrySet() {
216:                if (_entries == null) {
217:                    Set entries = _delegate.entrySet();
218:                    _entries = new AttributeValueEntrySet(entries);
219:                }
220:                return _entries;
221:            }
222:
223:            public Set keySet() {
224:                return _delegate.keySet();
225:            }
226:
227:            public Object get(Object key) {
228:                AttributeInstance attrInst = (AttributeInstance) _delegate
229:                        .get(key);
230:                return attrInst == null ? null : attrInst.getValue();
231:            }
232:
233:            public Object remove(Object key) {
234:                return _delegate.remove(key);
235:            }
236:
237:            public Object put(Object key, Object value) {
238:                return _delegate.put(key, value);
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.