Source Code Cross Referenced for VirtualNode.java in  » Database-ORM » MMBase » org » mmbase » bridge » implementation » 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.implementation 
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.implementation;
012:
013:        import java.util.*;
014:
015:        import org.mmbase.bridge.*;
016:        import org.mmbase.bridge.util.*;
017:        import org.mmbase.module.core.VirtualBuilder;
018:        import org.mmbase.module.core.MMObjectNode;
019:        import org.mmbase.module.core.MMBase;
020:        import org.mmbase.util.functions.*;
021:        import org.mmbase.util.logging.Logger;
022:        import org.mmbase.util.logging.Logging;
023:        import org.w3c.dom.Document;
024:
025:        /**
026:         * Implementation of Node. Simply wraps virtual node of core into an bridge Node. This class can be
027:         * used even if you don't know the precise implementation of the Cloud object (in contradiction to {@link BasicNode}, and therefore has a public constructor
028:         * {@link #VirtualNode(org.mmbase.module.core.VirtualNode, Cloud)}.
029:         *
030:         * @author Michiel Meeuwissen
031:         * @version $Id: VirtualNode.java,v 1.27 2008/02/03 17:33:57 nklasens Exp $
032:         * @see org.mmbase.bridge.Node
033:         * @see org.mmbase.module.core.VirtualNode
034:         * @since MMBase-1.8
035:         */
036:        public class VirtualNode extends AbstractNode implements  Node {
037:
038:            private static final Logger log = Logging
039:                    .getLoggerInstance(VirtualNode.class);
040:
041:            final protected org.mmbase.module.core.VirtualNode noderef;
042:
043:            /**
044:             * This is normally, but not always, a VirtualBuilder. It is not for some builders which have
045:             * besides real nodes also virtual nodes, like typedef (cluster nodes) and typerel (allowed relations because of inheritance).
046:             */
047:            final protected NodeManager nodeManager;
048:            final protected Cloud cloud;
049:
050:            protected VirtualNode(Cloud cloud,
051:                    org.mmbase.module.core.VirtualNode node, NodeManager nm) {
052:                this .cloud = cloud;
053:                this .noderef = node;
054:                nodeManager = nm;
055:
056:            }
057:
058:            public VirtualNode(org.mmbase.module.core.VirtualNode node,
059:                    Cloud cloud) {
060:                this (cloud, node, new VirtualNodeManager(node, cloud));
061:            }
062:
063:            /**
064:             * Makes a Node from a map of values. Sadly, this uses a local MMBase, so you can't use this with
065:             * e.g. RMMCI, but I didn't feel like reimplementating Node completely..
066:             * See {@link org.mmbase.bridge.util.MapNode}, which <em>is</em> a complete reimplementation (with no core dependencies).
067:             */
068:            public VirtualNode(Map values, Cloud cloud) {
069:                this (getVirtualNode(values), cloud);
070:            }
071:
072:            @Override
073:            public String toString() {
074:                return "BridgeVirtualNode " + noderef;
075:            }
076:
077:            protected static org.mmbase.module.core.VirtualNode getVirtualNode(
078:                    Map values) {
079:                VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
080:                org.mmbase.module.core.VirtualNode node = new org.mmbase.module.core.VirtualNode(
081:                        builder);
082:                Iterator i = values.entrySet().iterator();
083:                while (i.hasNext()) {
084:                    Map.Entry entry = (Map.Entry) i.next();
085:                    String name = entry.getKey().toString();
086:                    Object value = entry.getValue();
087:                    node.storeValue(name, value);
088:                }
089:                return node;
090:            }
091:
092:            /**
093:             * Returns the MMObjectNode on which the VirtualNode was based
094:             */
095:            public org.mmbase.module.core.VirtualNode getNodeRef() {
096:                return noderef;
097:            }
098:
099:            @Override
100:            public boolean isRelation() {
101:                return false;
102:            }
103:
104:            @Override
105:            public Relation toRelation() {
106:                return (Relation) this ;
107:            }
108:
109:            @Override
110:            public boolean isNodeManager() {
111:                return false;
112:            }
113:
114:            @Override
115:            public NodeManager toNodeManager() {
116:                return (NodeManager) this ;
117:            }
118:
119:            @Override
120:            public boolean isRelationManager() {
121:                return false;
122:            }
123:
124:            @Override
125:            public RelationManager toRelationManager() {
126:                return (RelationManager) this ;
127:            }
128:
129:            /**
130:             * Obtains a reference to the underlying MMObjectNode.
131:             * If the underlying node was deleted, this returns a virtual node with
132:             * no info except the (original) node number.
133:             * @return the underlying MMObjectNode
134:             * @throws NotFoundException if no node was specified. This generally means the
135:             */
136:            protected final MMObjectNode getNode() {
137:                return noderef;
138:            }
139:
140:            public Cloud getCloud() {
141:                return cloud;
142:            }
143:
144:            public NodeManager getNodeManager() {
145:                return nodeManager;
146:            }
147:
148:            @Override
149:            public int getNumber() {
150:                return noderef.getNumber();
151:            }
152:
153:            protected void edit(int action) {
154:                throw new UnsupportedOperationException(
155:                        "Cannot edit virtual node");
156:            }
157:
158:            @Override
159:            public boolean isNull(String fieldName) {
160:                return noderef.isNull(fieldName);
161:            }
162:
163:            @Override
164:            public void setSize(String fieldName, long size) {
165:                noderef.setSize(fieldName, size);
166:            }
167:
168:            public long getSize(String fieldName) {
169:                return noderef.getSize(fieldName);
170:            }
171:
172:            @Override
173:            protected void setValueWithoutChecks(String fieldName, Object value) {
174:                // cannot edit virtual node.
175:                // should not come here..
176:                getNode().setValue(fieldName, value);
177:            }
178:
179:            public Object getValueWithoutProcess(String fieldName) {
180:                Object result = getNode().getValue(fieldName);
181:                return result;
182:            }
183:
184:            @Override
185:            public boolean getBooleanValue(String fieldName) {
186:                Boolean result = Boolean.valueOf(noderef
187:                        .getBooleanValue(fieldName));
188:                return result.booleanValue();
189:            }
190:
191:            @Override
192:            public Date getDateValue(String fieldName) {
193:                Date result = noderef.getDateValue(fieldName);
194:                return result;
195:            }
196:
197:            @Override
198:            public List getListValue(String fieldName) {
199:                List result = noderef.getListValue(fieldName);
200:                return result;
201:            }
202:
203:            /**
204:             * Returns the Node value of a certain field, but in the case of a VirtualNode this can also occasionally be <code>null</code>
205:             * because the node can have been deleted.
206:             */
207:            @Override
208:            public Node getNodeValue(String fieldName) {
209:                if (fieldName == null || fieldName.equals("number")) {
210:                    return this ;
211:                }
212:                Node result = null;
213:                MMObjectNode mmobjectNode = getNode().getNodeValue(fieldName);
214:                if (mmobjectNode != null) {
215:                    try {
216:                        result = cloud.getNode(mmobjectNode.getNumber());
217:                    } catch (NotFoundException nfe) {
218:                        // don't know when this happens, perhaps the node was deleted in the mean time?
219:                        log.debug(nfe.getMessage());
220:                        return null;
221:                    }
222:                }
223:                return result;
224:            }
225:
226:            @Override
227:            public int getIntValue(String fieldName) {
228:                Integer result = getNode().getIntValue(fieldName);
229:                return result.intValue();
230:
231:            }
232:
233:            @Override
234:            public float getFloatValue(String fieldName) {
235:                Float result = getNode().getFloatValue(fieldName);
236:                return result.floatValue();
237:            }
238:
239:            @Override
240:            public long getLongValue(String fieldName) {
241:                Long result = getNode().getLongValue(fieldName);
242:                return result.longValue();
243:            }
244:
245:            @Override
246:            public double getDoubleValue(String fieldName) {
247:                Double result = getNode().getDoubleValue(fieldName);
248:                return result.doubleValue();
249:            }
250:
251:            @Override
252:            public byte[] getByteValue(String fieldName) {
253:                byte[] result = getNode().getByteValue(fieldName);
254:                return result;
255:            }
256:
257:            @Override
258:            public java.io.InputStream getInputStreamValue(String fieldName) {
259:                java.io.InputStream result = getNode().getInputStreamValue(
260:                        fieldName);
261:                return result;
262:            }
263:
264:            @Override
265:            public String getStringValue(String fieldName) {
266:                String result = getNode().getStringValue(fieldName);
267:                return result;
268:            }
269:
270:            @Override
271:            public Document getXMLValue(String fieldName) {
272:                Document result = getNode().getXMLValue(fieldName);
273:                return result;
274:            }
275:
276:            public Collection<Function<?>> getFunctions() {
277:                return getNode().getFunctions();
278:            }
279:
280:            @Override
281:            protected Function<?> getNodeFunction(String functionName) {
282:                return getNode().getFunction(functionName);
283:            }
284:
285:            @Override
286:            public Parameters createParameters(String functionName) {
287:                return getNode().getFunction(functionName).createParameters();
288:            }
289:
290:            @Override
291:            protected FieldValue createFunctionValue(Object result) {
292:                return new BasicFunctionValue(getCloud(), result);
293:            }
294:
295:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.