Source Code Cross Referenced for ReturnType.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:        /*
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:        package org.mmbase.util.functions;
011:
012:        import java.util.*;
013:
014:        /**
015:         * Description of the return type of certain function. This wraps a Class object but it has some
016:         * extra members. Can be used as a constructor argument of {@link Function} objects or as an
017:         * argument of {@link Function#setReturnType}.
018:         *
019:         * @author Daniel Ockeloen
020:         * @author Michiel Meeuwissen
021:
022:         * @version $Id: ReturnType.java,v 1.19 2006/10/13 14:22:26 nklasens Exp $
023:         * @since MMBase-1.7
024:         */
025:        public class ReturnType<C> extends Parameter<C> implements 
026:                java.io.Serializable {
027:
028:            /**
029:             * The return type of a function that does not return a thing.
030:             */
031:            public static final ReturnType<Void> VOID = new ReturnType(
032:                    void.class, "Does not return anything");
033:
034:            /**
035:             * The return type of a function that returns a String.
036:             */
037:            public static final ReturnType<String> STRING = new ReturnType(
038:                    String.class, "String");
039:
040:            public static final ReturnType<CharSequence> CHARSEQUENCE = new ReturnType(
041:                    CharSequence.class, "CharSequence");
042:
043:            /**
044:             * The return type of a function that returns a Integer.
045:             */
046:            public static final ReturnType<Integer> INTEGER = new ReturnType(
047:                    Integer.class, "Integer");
048:
049:            /**
050:             * The return type of a function that returns a Long.
051:             */
052:            public static final ReturnType<Long> LONG = new ReturnType(
053:                    Long.class, "Long");
054:
055:            /**
056:             * The return type of a function that returns a Double.
057:             */
058:            public static final ReturnType<Double> DOUBLE = new ReturnType(
059:                    Double.class, "Double");
060:
061:            /**
062:             * The return type of a function that returns a Boolean.
063:             */
064:            public static final ReturnType<Boolean> BOOLEAN = new ReturnType(
065:                    Boolean.class, "Boolean");
066:
067:            /**
068:             * The return type of a function that returns a List.
069:             */
070:            public static final ReturnType LIST = new ReturnType(List.class,
071:                    "List");
072:
073:            /**
074:             * The return type of a function that returns a NodeList.
075:             */
076:            public static final ReturnType<org.mmbase.bridge.NodeList> NODELIST = new ReturnType<org.mmbase.bridge.NodeList>(
077:                    org.mmbase.bridge.NodeList.class, "NodeList");
078:
079:            /**
080:             * The return type of a function that returns a Node.
081:             */
082:            public static final ReturnType<org.mmbase.bridge.Node> NODE = new ReturnType<org.mmbase.bridge.Node>(
083:                    org.mmbase.bridge.Node.class, "Node");
084:
085:            /**
086:             * The return type of a function that returns a Set.
087:             */
088:            public static final ReturnType SET = new ReturnType(Set.class,
089:                    "Set");
090:            /**
091:             * The return type of a function that returns a Set.
092:             */
093:            public static final ReturnType COLLECTION = new ReturnType(
094:                    Collection.class, "Collection");
095:
096:            /**
097:             * The return type of a function that returns a Map.
098:             */
099:            public static final ReturnType MAP = new ReturnType(Map.class,
100:                    "Map");
101:
102:            /**
103:             * The return type of a function is unknown.
104:             */
105:            public static final ReturnType UNKNOWN = new ReturnType(
106:                    Object.class, "unknown");
107:
108:            /**
109:             * The return type of a function is None
110:             */
111:            public static final ReturnType NONE = new ReturnType(Object.class,
112:                    "none");
113:
114:            /**
115:             * Can be return by functions that don't want to return anything. (The function framework
116:             * requires you to return <em>something</em>).
117:             */
118:            public static final Object VOID_VALUE = new Object();
119:
120:            /**
121:             * @since MMBase-1.9
122:             */
123:            public static final ReturnType<?> getReturnType(Class<?> type) {
124:                if (type.equals(void.class)) {
125:                    return VOID;
126:                } else if (type.equals(String.class)) {
127:                    return STRING;
128:                } else if (type.equals(CharSequence.class)) {
129:                    return CHARSEQUENCE;
130:                } else if (type.equals(Integer.class)) {
131:                    return INTEGER;
132:                } else if (type.equals(Long.class)) {
133:                    return LONG;
134:                } else if (type.equals(Double.class)) {
135:                    return DOUBLE;
136:                } else if (type.equals(Boolean.class)) {
137:                    return BOOLEAN;
138:                } else if (type.equals(List.class)) {
139:                    return LIST;
140:                } else if (type.equals(org.mmbase.bridge.NodeList.class)) {
141:                    return NODELIST;
142:                } else if (type.equals(org.mmbase.bridge.Node.class)) {
143:                    return NODE;
144:                } else if (type.equals(Set.class)) {
145:                    return SET;
146:                } else if (type.equals(Collection.class)) {
147:                    return COLLECTION;
148:                } else if (type.equals(Map.class)) {
149:                    return MAP;
150:                } else if (type.equals(Void.class)) {
151:                    return VOID;
152:                } else {
153:                    return new ReturnType(type, type.getName());
154:                }
155:            }
156:
157:            private Map<String, ReturnType> typeStruct = new HashMap<String, ReturnType>();
158:
159:            public ReturnType(Class type, String description) {
160:                super ("RETURN_VALUE", type);
161:                setDescription(description, null);
162:            }
163:
164:            public boolean isRequired() {
165:                return false;
166:            }
167:
168:            /**
169:             * If the return type is like a map or struct (key-values pairs), then you might want to describe the
170:             * types of the values seperately too.
171:             */
172:            public ReturnType addSubType(String name, ReturnType type) {
173:                return typeStruct.put(name, type);
174:            }
175:
176:            /**
177:             * @return Unmodifiable Map containing the 'subtypes' in case the type is Map. An empty Map otherwise.
178:             */
179:            public Map<String, ReturnType> getSubTypes() {
180:                return Collections.unmodifiableMap(typeStruct);
181:            }
182:
183:            public String toString() {
184:                return getDataType().getTypeAsClass().getName();
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.