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


001:        package org.mmbase.util.functions;
002:
003:        import org.mmbase.module.core.*;
004:        import org.mmbase.storage.search.*;
005:        import org.mmbase.storage.search.implementation.*;
006:        import org.mmbase.bridge.*;
007:        import java.util.*;
008:        import org.mmbase.util.logging.Logger;
009:        import org.mmbase.util.logging.Logging;
010:
011:        /**
012:         * A bean can be accessed through the function framework. 
013:         *
014:         * @author Michiel Meeuwissen
015:         * @version $Id: ExampleBean.java,v 1.11 2007/11/25 18:25:49 nklasens Exp $
016:         * @since MMBase-1.8
017:         */
018:        public final class ExampleBean {
019:
020:            private static final Logger log = Logging
021:                    .getLoggerInstance(ExampleBean.class);
022:            private String parameter1;
023:            private Integer parameter2 = 0;
024:            private String parameter3 = "default";
025:            private Node node;
026:            private Cloud cloud;
027:
028:            public void setParameter1(String hoi) {
029:                parameter1 = hoi;
030:            }
031:
032:            public void setParameter2(Integer j) {
033:                parameter2 = j;
034:            }
035:
036:            public Integer getParameter2() {
037:                return parameter2;
038:            }
039:
040:            public void setAnotherParameter(String a) {
041:                parameter3 = a;
042:            }
043:
044:            public String getAnotherParameter() {
045:                return parameter3;
046:            }
047:
048:            /**
049:             * Makes this bean useable as a Node function.
050:             */
051:            public void setNode(Node node) {
052:                this .node = node;
053:            }
054:
055:            /**
056:             * Makes the functions useable in bridge (so with security). See also {@link
057:             * Parameter#CLOUD}. This is an example of a parameter which is automaticly filled by function tags.
058:             */
059:            public void setCloud(Cloud c) {
060:                cloud = c;
061:            }
062:
063:            /**
064:             * A function defined by this class
065:             */
066:            public String stringFunction() {
067:                return "[[" + parameter1 + "/" + parameter3 + "]]";
068:            }
069:
070:            public Integer integerFunction() {
071:                return parameter2 * 3;
072:            }
073:
074:            /**
075:             * A function returning a Map
076:             */
077:            public Map<String, String> mapFunction() {
078:                Map<String, String> map = new HashMap<String, String>();
079:                map.put("bloe", parameter1);
080:                return map;
081:            }
082:
083:            /**
084:             * A function returning a Node as a core object (deprecated).
085:             */
086:            public MMObjectNode nodeFunction1() {
087:                VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
088:                MMObjectNode virtual = builder.getNewNode("admin");
089:                virtual.storeValue("bloe", parameter1);
090:                return virtual;
091:            }
092:
093:            /**
094:             * A function returning a Node as a bridge object, but based on a Map of values.
095:             */
096:            public Node nodeFunction2() {
097:                Map<String, String> map = new HashMap<String, String>();
098:                map.put("bloe", parameter1);
099:                return new org.mmbase.bridge.util.MapNode(map);
100:            }
101:
102:            public Collection<Object> nodeListFunction() {
103:                List<Object> result = new ArrayList<Object>();
104:                result.add(nodeFunction1());
105:                result.add(nodeFunction2());
106:                return result;
107:            }
108:
109:            public NodeList nodeListFunction1() {
110:                Collection<Object> col = nodeListFunction();
111:                col.add(mapFunction());
112:                return new org.mmbase.bridge.util.CollectionNodeList(col);
113:            }
114:
115:            /**
116:             * A real node-function (using the node argument). Returns the next newer node of same type.
117:             * Also a nice example on the difference between core and bridge.
118:             */
119:            public Object successor() {
120:                if (node == null)
121:                    throw new IllegalArgumentException(
122:                            "successor is a node-function");
123:                if (cloud != null) {
124:                    log
125:                            .debug("Using bridge (security restrictions will be honoured)");
126:                    NodeManager nm = node.getNodeManager();
127:                    NodeQuery q = nm.createQuery();
128:                    StepField field = q.getStepField(nm.getField("number"));
129:                    q.setConstraint(q.createConstraint(field,
130:                            FieldCompareConstraint.GREATER, Integer
131:                                    .valueOf(node.getNumber())));
132:                    q.addSortOrder(field, SortOrder.ORDER_ASCENDING);
133:                    q.setMaxNumber(1);
134:                    NodeIterator i = nm.getList(q).nodeIterator();
135:                    return i.hasNext() ? i.nextNode() : null;
136:                } else {
137:                    log.debug("Using core.");
138:                    MMObjectBuilder builder = MMBase.getMMBase().getBuilder(
139:                            node.getNodeManager().getName());
140:                    NodeSearchQuery query = new NodeSearchQuery(builder);
141:                    StepField field = query
142:                            .getField(builder.getField("number"));
143:                    BasicFieldValueConstraint cons = new BasicFieldValueConstraint(
144:                            field, node.getNumber());
145:                    cons.setOperator(FieldCompareConstraint.GREATER);
146:                    query.setConstraint(cons);
147:                    query.addSortOrder(field);
148:                    query.setMaxNumber(1);
149:                    try {
150:                        java.util.Iterator<MMObjectNode> i = builder.getNodes(
151:                                query).iterator();
152:                        return i.hasNext() ? i.next() : null;
153:                    } catch (Exception e) {
154:                        return null;
155:                    }
156:                }
157:            }
158:
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.