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


001:        /*
002:         * $Id: Boolean.java,v 1.19 2007/08/27 11:18:20 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.types.standard;
008:
009:        import org.xins.common.types.Type;
010:        import org.xins.common.types.TypeValueException;
011:        import org.xins.common.MandatoryArgumentChecker;
012:
013:        /**
014:         * Standard type <em>_boolean</em>.
015:         *
016:         * @version $Revision: 1.19 $ $Date: 2007/08/27 11:18:20 $
017:         * @author <a href="mailto:ernst@ernstdehaan.com">Ernst de Haan</a>
018:         *
019:         * @since XINS 1.0.0
020:         */
021:        public final class Boolean extends Type {
022:
023:            /**
024:             * The only instance of this class. This field is never <code>null</code>.
025:             */
026:            public static final Boolean SINGLETON = new org.xins.common.types.standard.Boolean();
027:
028:            /**
029:             * Constructs a new <code>Boolean</code>.
030:             * This constructor is private, the field {@link #SINGLETON} should be
031:             * used.
032:             */
033:            private Boolean() {
034:                super ("_boolean", java.lang.Boolean.class);
035:            }
036:
037:            /**
038:             * Converts the specified non-<code>null</code> string value to a
039:             * <code>boolean</code>.
040:             *
041:             * @param string
042:             *    the string to convert, cannot be <code>null</code>.
043:             *
044:             * @return
045:             *    the <code>boolean</code> value.
046:             *
047:             * @throws IllegalArgumentException
048:             *    if <code>string == null</code>.
049:             *
050:             * @throws TypeValueException
051:             *    if the specified string does not represent a valid value for this
052:             *    type.
053:             */
054:            public static boolean fromStringForRequired(String string)
055:                    throws IllegalArgumentException, TypeValueException {
056:                if ("true".equals(string)) {
057:                    return true;
058:                } else if ("false".equals(string)) {
059:                    return false;
060:                } else if (string == null) {
061:                    throw new IllegalArgumentException("string == null");
062:                } else {
063:                    throw new TypeValueException(SINGLETON, string);
064:                }
065:            }
066:
067:            /**
068:             * Converts the specified string value to a <code>java.lang.Boolean</code>
069:             * value.
070:             *
071:             * @param string
072:             *    the string to convert, can be <code>null</code>.
073:             *
074:             * @return
075:             *    the {@link java.lang.Boolean}, or <code>null</code> if
076:             *    <code>string == null</code>.
077:             *
078:             * @throws TypeValueException
079:             *    if the specified string does not represent a valid value for this
080:             *    type.
081:             */
082:            public static java.lang.Boolean fromStringForOptional(String string)
083:                    throws TypeValueException {
084:                if ("true".equals(string)) {
085:                    return java.lang.Boolean.TRUE;
086:                } else if ("false".equals(string)) {
087:                    return java.lang.Boolean.FALSE;
088:                } else if (string == null) {
089:                    return null;
090:                } else {
091:                    throw new TypeValueException(SINGLETON, string);
092:                }
093:            }
094:
095:            /**
096:             * Converts the specified <code>Boolean</code> to a string.
097:             *
098:             * @param value
099:             *    the value to convert, can be <code>null</code>.
100:             *
101:             * @return
102:             *    the textual representation of the value, or <code>null</code> if and
103:             *    only if <code>value == null</code>.
104:             */
105:            public static String toString(java.lang.Boolean value) {
106:                if (value == null) {
107:                    return null;
108:                } else {
109:                    return toString(value.booleanValue());
110:                }
111:            }
112:
113:            /**
114:             * Converts the specified <code>boolean</code> to a string.
115:             *
116:             * @param value
117:             *    the value to convert.
118:             *
119:             * @return
120:             *    the textual representation of the value, never <code>null</code>.
121:             */
122:            public static String toString(boolean value) {
123:                return value ? "true" : "false";
124:            }
125:
126:            /**
127:             * Determines if the specified <code>String</code> value is considered
128:             * valid for this type (implementation method).
129:             *
130:             * <p>This method is called from {@link #isValidValue(String)}. When
131:             * called from that method, it is guaranteed that the argument is not
132:             * <code>null</code>.
133:             *
134:             * @param string
135:             *    the <code>String</code> value that should be checked for validity,
136:             *    never <code>null</code>.
137:             *
138:             * @return
139:             *    <code>true</code> if and only if the specified <code>String</code>
140:             *    value is valid, <code>false</code> otherwise.
141:             */
142:            protected boolean isValidValueImpl(String string) {
143:                return "true".equals(string) || "false".equals(string);
144:            }
145:
146:            /**
147:             * Converts from a <code>String</code> to an instance of the value class
148:             * for this type (implementation method).
149:             *
150:             * <p>This method is not required to check the validity of the specified
151:             * value (since {@link #isValidValueImpl(String)} should have been called
152:             * before) but if it does, then it may throw a {@link TypeValueException}.
153:             *
154:             * @param string
155:             *    the string to convert to an instance of the value class, guaranteed
156:             *    to be not <code>null</code> and guaranteed to have been passed to
157:             *    {@link #isValidValueImpl(String)} without getting an exception.
158:             *
159:             * @return
160:             *    an instance of the value class, cannot be <code>null</code>.
161:             */
162:            protected Object fromStringImpl(String string) {
163:                return "true".equals(string) ? java.lang.Boolean.TRUE
164:                        : java.lang.Boolean.FALSE;
165:            }
166:
167:            /**
168:             * Generates a string representation of the specified value for this type.
169:             * The specified value must be an instance of the value class for this type
170:             * (see {@link #getValueClass()}). Also, it may have to fall within a
171:             * certain range of valid values, depending on the type.
172:             *
173:             * @param value
174:             *    the value, cannot be <code>null</code>.
175:             *
176:             * @return
177:             *    the string representation of the specified value for this type,
178:             *    cannot be <code>null</code>.
179:             *
180:             * @throws IllegalArgumentException
181:             *    if <code>value == null</code>.
182:             *
183:             * @throws ClassCastException
184:             *    if <code>getValueClass().isInstance(value) == false</code>.
185:             *
186:             * @throws TypeValueException
187:             *    if the specified value is not in the allowed range.
188:             */
189:            public String toString(Object value)
190:                    throws IllegalArgumentException, ClassCastException,
191:                    TypeValueException {
192:                MandatoryArgumentChecker.check("value", value);
193:                java.lang.Boolean b = (java.lang.Boolean) value;
194:                return b.toString();
195:            }
196:
197:            public String getDescription() {
198:                return "A boolean, either 'true' or 'false'.";
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.