Source Code Cross Referenced for ParameterDefinition.java in  » Web-Services » Gomba » org » gomba » 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 » Web Services » Gomba » org.gomba 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.gomba;
002:
003:        import java.util.HashMap;
004:        import java.util.Map;
005:
006:        import org.gomba.domains.BLOBColumnDomain;
007:        import org.gomba.domains.CLOBColumnDomain;
008:        import org.gomba.domains.ColumnDomain;
009:        import org.gomba.domains.HeaderDomain;
010:        import org.gomba.domains.ParamDomain;
011:        import org.gomba.domains.ParamValuesDomain;
012:        import org.gomba.domains.PathDomain;
013:        import org.gomba.domains.RequestScopeDomain;
014:        import org.gomba.domains.SystemPropertiesDomain;
015:
016:        /**
017:         * Represents a parameter.
018:         * 
019:         * @author Flavio Tordini
020:         * @version $Id: ParameterDefinition.java,v 1.1.1.1 2004/06/16 13:15:12
021:         *                flaviotordini Exp $
022:         */
023:        public class ParameterDefinition {
024:
025:            private final static Map domains = new HashMap();
026:
027:            private final ParameterDomain domain;
028:
029:            private final String name;
030:
031:            private final Class type;
032:
033:            private final Object defaultValue;
034:
035:            private final boolean nullable;
036:
037:            static {
038:                try {
039:
040:                    registerDomain(new ParamDomain());
041:                    registerDomain(new ParamValuesDomain());
042:                    registerDomain(new PathDomain());
043:                    registerDomain(new HeaderDomain());
044:                    registerDomain(new RequestScopeDomain());
045:                    registerDomain(new ColumnDomain());
046:                    registerDomain(new BLOBColumnDomain());
047:                    registerDomain(new CLOBColumnDomain());
048:                    registerDomain(new SystemPropertiesDomain());
049:                    // add new domains here
050:
051:                } catch (Exception e) {
052:                    System.err.println(e.getMessage());
053:                    e.printStackTrace();
054:                }
055:            }
056:
057:            private static final void registerDomain(ParameterDomain domain)
058:                    throws Exception {
059:                Object previous = domains.put(domain.getName(), domain);
060:                if (previous != null) {
061:                    throw new Exception("A domain with name '"
062:                            + domain.getName() + "' is already registered.");
063:                }
064:            }
065:
066:            /**
067:             * Constructor. Valid parameter domains: path, param, paramValues, header,
068:             * column, requestScope.
069:             * 
070:             * @param domain
071:             *                   The parameter domain.
072:             * @param name
073:             *                   The parameter name.
074:             * @param type
075:             *                   The parameter Java type. May be null.
076:             * @param defaultValue
077:             *                   The parameter default value. May be null.
078:             */
079:            public ParameterDefinition(final String domain, final String name,
080:                    final Class type, final Object defaultValue,
081:                    final boolean nullable) throws Exception {
082:                if (domain == null) {
083:                    throw new IllegalArgumentException("Domain cannot be null.");
084:                }
085:                if (name == null) {
086:                    throw new IllegalArgumentException("Name cannot be null.");
087:                }
088:
089:                // the default value requires also the type to be specified
090:                if (type == null && defaultValue != null) {
091:                    throw new IllegalArgumentException(
092:                            "Cannot specify a default value without specifying the parameter type.");
093:                }
094:
095:                // make sure the default value type matches the parameter type
096:                if (type != null && defaultValue != null
097:                        && defaultValue.getClass() != type) {
098:                    throw new IllegalArgumentException(
099:                            "The default value does not match the parameter type.");
100:                }
101:
102:                this .domain = (ParameterDomain) domains.get(domain);
103:                if (this .domain == null) {
104:                    throw new IllegalArgumentException("Invalid domain: "
105:                            + domain);
106:                }
107:                this .name = name;
108:                this .type = type;
109:                this .defaultValue = defaultValue;
110:                this .nullable = nullable;
111:            }
112:
113:            /**
114:             * @return Returns the domain.
115:             */
116:            public ParameterDomain getDomain() {
117:                return this .domain;
118:            }
119:
120:            /**
121:             * @return Returns the name.
122:             */
123:            public String getName() {
124:                return this .name;
125:            }
126:
127:            /**
128:             * @return Returns the type, if any.
129:             */
130:            public Class getType() {
131:                return this .type;
132:            }
133:
134:            /**
135:             * @return Returns the defaultValue.
136:             */
137:            public Object getDefaultValue() {
138:                return this .defaultValue;
139:            }
140:
141:            /**
142:             * @return Returns true if the parameter is nullable.
143:             */
144:            public boolean isNullable() {
145:                return this .nullable;
146:            }
147:
148:            /**
149:             * @see java.lang.Object#toString()
150:             */
151:            public String toString() {
152:                StringBuffer sb = new StringBuffer();
153:                sb.append(this .domain.getName()).append('.').append(this .name);
154:                if (this .type != null) {
155:                    sb.append(' ').append(this .type.getName());
156:                    if (this .defaultValue != null) {
157:                        sb.append(' ').append(this.defaultValue);
158:                    }
159:                }
160:                return sb.toString();
161:            }
162:
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.