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


001:        /*
002:         * $Id: MandatoryArgumentChecker.java,v 1.22 2007/03/16 09:54:58 agoubard Exp $
003:         *
004:         * Copyright 2003-2007 Orange Nederland Breedband B.V.
005:         * See the COPYRIGHT file for redistribution and use restrictions.
006:         */
007:        package org.xins.common;
008:
009:        /**
010:         * Utility class used to check mandatory method arguments.
011:         *
012:         * @version $Revision: 1.22 $ $Date: 2007/03/16 09:54:58 $
013:         * @author <a href="mailto:ernst@ernstdehaan.com">Ernst de Haan</a>
014:         *
015:         * @since XINS 1.0.0
016:         */
017:        public final class MandatoryArgumentChecker {
018:
019:            /**
020:             * Constructs a new <code>MandatoryArgumentChecker</code>. This constructor
021:             * is private since this no instances of this class should be created.
022:             */
023:            private MandatoryArgumentChecker() {
024:                // empty
025:            }
026:
027:            /**
028:             * Checks if the specified argument value is <code>null</code>. If it is
029:             * <code>null</code>, then an {@link IllegalArgumentException} is thrown.
030:             *
031:             * @param argName
032:             *    the name of the argument, cannot be <code>null</code>.
033:             *
034:             * @param argValue
035:             *    the value of the argument.
036:             *
037:             * @throws IllegalArgumentException
038:             *    if <code>argValue == null</code>.
039:             */
040:            public static void check(String argName, Object argValue)
041:                    throws IllegalArgumentException {
042:
043:                // If both are non-null everything is okay, just short-circuit
044:                if (argName != null && argValue != null) {
045:                    return;
046:                }
047:
048:                // Check if the name is null
049:                if (argName == null) {
050:                    throw Utils.logProgrammingError("argName == null");
051:                }
052:
053:                // Otherwise the value is null
054:                if (argValue == null) {
055:                    throw new IllegalArgumentException(argName + " == null");
056:                }
057:            }
058:
059:            /**
060:             * Checks if any of the two specified argument values is <code>null</code>.
061:             * If at least one value is <code>null</code>, then an
062:             * {@link IllegalArgumentException} is thrown.
063:             *
064:             * @param argName1
065:             *    the name of the first argument, cannot be <code>null</code>.
066:             *
067:             * @param argValue1
068:             *    the value of the first argument.
069:             *
070:             * @param argName2
071:             *    the name of the second argument, cannot be <code>null</code>.
072:             *
073:             * @param argValue2
074:             *    the value of the second argument.
075:             *
076:             * @throws IllegalArgumentException
077:             *    if <code>argValue1 == null || argValue2 == null</code>.
078:             */
079:            public static void check(String argName1, Object argValue1,
080:                    String argName2, Object argValue2)
081:                    throws IllegalArgumentException {
082:
083:                // If all are non-null everything is okay, just short-circuit
084:                if (argName1 != null && argValue1 != null && argName2 != null
085:                        && argValue2 != null) {
086:                    return;
087:                }
088:
089:                String message = "";
090:
091:                // Check if any of the names is null
092:                if (argName1 == null && argName2 == null) {
093:                    message = "argName1 == null && argName2 == null";
094:                    throw Utils.logProgrammingError(message);
095:                }
096:
097:                // Otherwise (at least) one of the values must be null
098:                if (argValue1 == null && argValue2 == null) {
099:                    message = argName1 + " == null && " + argName2 + " == null";
100:                } else {
101:                    check(argName1, argValue1);
102:                    check(argName2, argValue2);
103:                }
104:                throw new IllegalArgumentException(message);
105:            }
106:
107:            /**
108:             * Checks if any of the three specified argument values is
109:             * <code>null</code>. If at least one value is <code>null</code>, then an
110:             * {@link IllegalArgumentException} is thrown.
111:             *
112:             * @param argName1
113:             *    the name of the first argument, cannot be <code>null</code>.
114:             *
115:             * @param argValue1
116:             *    the value of the first argument.
117:             *
118:             * @param argName2
119:             *    the name of the second argument, cannot be <code>null</code>.
120:             *
121:             * @param argValue2
122:             *    the value of the second argument.
123:             *
124:             * @param argName3
125:             *    the name of the third argument, cannot be <code>null</code>.
126:             *
127:             * @param argValue3
128:             *    the value of the third argument.
129:             *
130:             * @throws IllegalArgumentException
131:             *    if <code>argValue1 == null
132:             *          || argValue2 == null
133:             *          || argValue3 == null</code>.
134:             */
135:            public static void check(String argName1, Object argValue1,
136:                    String argName2, Object argValue2, String argName3,
137:                    Object argValue3) throws IllegalArgumentException {
138:
139:                // If all are non-null everything is okay, just short-circuit
140:                if (argName1 != null && argValue1 != null && argName2 != null
141:                        && argValue2 != null && argName3 != null
142:                        && argValue3 != null) {
143:                    return;
144:                }
145:
146:                // Check if any of the names is null
147:                String message = "";
148:                if (argName1 == null && argName2 == null && argName3 == null) {
149:                    message = "argName1 == null && " + "argName2 == null && "
150:                            + "argName3 == null";
151:                    throw Utils.logProgrammingError(message);
152:                }
153:
154:                // Otherwise (at least) one of the values must be null
155:                if (argValue1 == null && argValue2 == null && argValue3 == null) {
156:                    message = argName1 + " == null && " + argName2
157:                            + " == null && " + argName3 + " == null";
158:                } else {
159:                    check(argName1, argValue1, argName2, argValue2);
160:                    check(argName1, argValue1, argName3, argValue3);
161:                    check(argName2, argValue2, argName3, argValue3);
162:                }
163:                throw new IllegalArgumentException(message);
164:            }
165:
166:            /**
167:             * Checks if any of the four specified argument values is
168:             * <code>null</code>. If at least one value is <code>null</code>, then an
169:             * {@link IllegalArgumentException} is thrown.
170:             *
171:             * @param argName1
172:             *    the name of the first argument, cannot be <code>null</code>.
173:             *
174:             * @param argValue1
175:             *    the value of the first argument.
176:             *
177:             * @param argName2
178:             *    the name of the second argument, cannot be <code>null</code>.
179:             *
180:             * @param argValue2
181:             *    the value of the second argument.
182:             *
183:             * @param argName3
184:             *    the name of the third argument, cannot be <code>null</code>.
185:             *
186:             * @param argValue3
187:             *    the value of the third argument.
188:             *
189:             * @param argName4
190:             *    the name of the fourth argument, cannot be <code>null</code>.
191:             *
192:             * @param argValue4
193:             *    the value of the fourth argument.
194:             *
195:             * @throws IllegalArgumentException
196:             *    if <code>argValue1 == null || argValue2 == null
197:             *          || argValue3 == null || argValue4 == null</code>.
198:             */
199:            public static void check(String argName1, Object argValue1,
200:                    String argName2, Object argValue2, String argName3,
201:                    Object argValue3, String argName4, Object argValue4)
202:                    throws IllegalArgumentException {
203:
204:                // If all are non-null everything is okay, just short-circuit
205:                if (argName1 != null && argValue1 != null && argName2 != null
206:                        && argValue2 != null && argName3 != null
207:                        && argValue3 != null && argName4 != null
208:                        && argValue4 != null) {
209:                    return;
210:                }
211:
212:                // Check if any of the names is null
213:                String message = "";
214:                if (argName1 == null && argName2 == null && argName3 == null
215:                        && argName4 == null) {
216:                    message = "argName1 == null && argName2 == null && "
217:                            + "argName3 == null && argName4 == null";
218:                    throw Utils.logProgrammingError(message);
219:                }
220:
221:                // Otherwise (at least) one of the values must be null
222:                if (argValue1 == null && argValue2 == null && argValue3 == null
223:                        && argValue4 == null) {
224:                    message = argName1 + " == null && " + argName2
225:                            + " == null && " + argName3 + " == null && "
226:                            + argName4 + " == null";
227:                } else {
228:                    check(argName1, argValue1, argName2, argValue2, argName3,
229:                            argValue3);
230:                    check(argName1, argValue1, argName2, argValue2, argName4,
231:                            argValue4);
232:                    check(argName2, argValue2, argName3, argValue3, argName4,
233:                            argValue4);
234:                }
235:                throw new IllegalArgumentException(message);
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.