Source Code Cross Referenced for NodeMap.java in  » Database-ORM » MMBase » org » mmbase » bridge » 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 » Database ORM » MMBase » org.mmbase.bridge.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:        This software is OSI Certified Open Source Software.
004:        OSI Certified is a certification mark of the Open Source Initiative.
005:
006:        The license (Mozilla version 1.0) can be read at the MMBase site.
007:        See http://www.MMBase.org/license
008:
009:         */
010:
011:        package org.mmbase.bridge.util;
012:
013:        import java.util.*;
014:
015:        import org.mmbase.bridge.*;
016:
017:        /**
018:         * A Map representing a Node. This class can be used if you need a bridge Node object to look like a
019:         * Map (where the keys are the fields).
020:         *
021:         * This object is also still a Node object.
022:         *
023:         * @author  Michiel Meeuwissen
024:         * @version $Id: NodeMap.java,v 1.4 2007/02/11 20:05:50 nklasens Exp $
025:         * @since   MMBase-1.8
026:         */
027:
028:        public class NodeMap extends NodeWrapper implements  Map<String, Object> {
029:
030:            /**
031:             * @param node The Node which is wrapped, and is presented as a Map.
032:             */
033:            public NodeMap(Node node) {
034:                super (node);
035:            }
036:
037:            // javadoc inherited
038:            public void clear() {
039:                // the fields of a node are fixed by it's nodemanager.
040:                throw new UnsupportedOperationException(
041:                        "You cannot remove fields from a Node.");
042:            }
043:
044:            // javadoc inherited
045:            public boolean containsKey(Object key) {
046:                if (key instanceof  String) {
047:                    return getNodeManager().hasField((String) key);
048:                } else {
049:                    return false;
050:                }
051:            }
052:
053:            // javadoc inherited
054:            // code copied from AbstractMap
055:            public boolean containsValue(Object value) {
056:                Iterator<Entry<String, Object>> i = entrySet().iterator();
057:                if (value == null) {
058:                    while (i.hasNext()) {
059:                        Entry<String, Object> e = i.next();
060:                        if (e.getValue() == null) {
061:                            return true;
062:                        }
063:                    }
064:                } else {
065:                    while (i.hasNext()) {
066:                        Entry<String, Object> e = i.next();
067:                        if (value.equals(e.getValue())) {
068:                            return true;
069:                        }
070:                    }
071:                }
072:                return false;
073:            }
074:
075:            // javadoc inherited
076:            public Object remove(Object key) {
077:                throw new UnsupportedOperationException(
078:                        "You cannot remove fields from a Node.");
079:            }
080:
081:            // javadoc inherited
082:            public Set<Entry<String, Object>> entrySet() {
083:                return new AbstractSet<Entry<String, Object>>() {
084:                    FieldList fields = getNodeManager().getFields();
085:
086:                    @Override
087:                    public Iterator<Entry<String, Object>> iterator() {
088:                        return new Iterator<Entry<String, Object>>() {
089:                            FieldIterator i = fields.fieldIterator();
090:
091:                            public boolean hasNext() {
092:                                return i.hasNext();
093:                            }
094:
095:                            public Entry<String, Object> next() {
096:                                return new Map.Entry<String, Object>() {
097:                                    Field field = i.nextField();
098:
099:                                    public String getKey() {
100:                                        return field.getName();
101:                                    }
102:
103:                                    public Object getValue() {
104:                                        return NodeMap.this .getValue(field
105:                                                .getName());
106:                                    }
107:
108:                                    public Object setValue(Object value) {
109:                                        Object r = getValue();
110:                                        NodeMap.this .setValue(field.getName(),
111:                                                value);
112:                                        return r;
113:                                    }
114:                                };
115:                            }
116:
117:                            public void remove() {
118:                                throw new UnsupportedOperationException(
119:                                        "You cannot remove fields from a Node.");
120:                            }
121:                        };
122:                    }
123:
124:                    @Override
125:                    public int size() {
126:                        return fields.size();
127:                    }
128:                };
129:            }
130:
131:            // javadoc inherited
132:            // todo: could be modifiable?
133:            public Collection<Object> values() {
134:                return new AbstractCollection<Object>() {
135:                    FieldList fields = getNodeManager().getFields();
136:
137:                    @Override
138:                    public Iterator<Object> iterator() {
139:                        return new Iterator<Object>() {
140:                            FieldIterator i = fields.fieldIterator();
141:
142:                            public boolean hasNext() {
143:                                return i.hasNext();
144:                            }
145:
146:                            public Object next() {
147:                                Field field = i.nextField();
148:                                return NodeMap.this .getValue(field.getName());
149:                            }
150:
151:                            public void remove() {
152:                                throw new UnsupportedOperationException(
153:                                        "You cannot remove fields from a Node.");
154:                            }
155:                        };
156:                    }
157:
158:                    @Override
159:                    public int size() {
160:                        return fields.size();
161:                    }
162:                };
163:            }
164:
165:            // javadoc inherited
166:            public Set<String> keySet() {
167:                return new AbstractSet<String>() {
168:                    FieldList fields = getNodeManager().getFields();
169:
170:                    @Override
171:                    public Iterator<String> iterator() {
172:                        return new Iterator<String>() {
173:                            FieldIterator i = fields.fieldIterator();
174:
175:                            public boolean hasNext() {
176:                                return i.hasNext();
177:                            }
178:
179:                            public String next() {
180:                                Field field = i.nextField();
181:                                return field.getName();
182:                            }
183:
184:                            public void remove() {
185:                                throw new UnsupportedOperationException(
186:                                        "You cannot remove fields from a Node.");
187:                            }
188:                        };
189:                    }
190:
191:                    @Override
192:                    public int size() {
193:                        return fields.size();
194:                    }
195:                };
196:            }
197:
198:            // javadoc inherited
199:            public void putAll(Map<? extends String, ? extends Object> map) {
200:                for (java.util.Map.Entry<? extends String, ? extends Object> e : map
201:                        .entrySet()) {
202:                    put(e.getKey(), e.getValue());
203:                }
204:            }
205:
206:            // javadoc inherited
207:            public Object put(String key, Object value) {
208:                Object r = getValue(key);
209:                setValue(key, value);
210:                return r;
211:            }
212:
213:            // javadoc inherited
214:            public Object get(Object key) {
215:                return getValue((String) key);
216:            }
217:
218:            // javadoc inherited
219:            public boolean isEmpty() {
220:                return false;
221:            }
222:
223:            // javadoc inherited
224:            public int size() {
225:                return getNodeManager().getFields().size();
226:            }
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.