Source Code Cross Referenced for ComparableBoolean.java in  » Profiler » MessAdmin » clime » messadmin » utils » 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 » Profiler » MessAdmin » clime.messadmin.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package clime.messadmin.utils;
002:
003:        import java.io.Serializable;
004:
005:        /**
006:         * Comparable Boolean for JDK <= 1.4. Useless for JDK 5.
007:         * Note that some static methods have been removed, as they where already defined in Boolean.
008:         * This class is not intended as a replacement for java.lang.Boolean!
009:         * 
010:         * (From the JDK documentation:)
011:         * The Boolean class wraps a value of the primitive type 
012:         * <code>boolean</code> in an object. An object of type 
013:         * <code>Boolean</code> contains a single field whose type is 
014:         * <code>boolean</code>. 
015:         * <p>
016:         * In addition, this class provides many methods for 
017:         * converting a <code>boolean</code> to a <code>String</code> and a 
018:         * <code>String</code> to a <code>boolean</code>, as well as other 
019:         * constants and methods useful when dealing with a 
020:         * <code>boolean</code>. 
021:         *
022:         * @author  Arthur van Hoff, C&eacute;drik LIME
023:         * @version 1.51, 05/11/04
024:         * @since   JDK1.0
025:         */
026:        public final class ComparableBoolean implements  Serializable,
027:                Comparable {//extends Boolean
028:
029:            /** 
030:             * The <code>ComparableBoolean</code> object corresponding to the primitive 
031:             * value <code>true</code>. 
032:             */
033:            public static final ComparableBoolean TRUE = new ComparableBoolean(
034:                    true);
035:
036:            /** 
037:             * The <code>ComparableBoolean</code> object corresponding to the primitive 
038:             * value <code>false</code>. 
039:             */
040:            public static final ComparableBoolean FALSE = new ComparableBoolean(
041:                    false);
042:
043:            /**
044:             * The Class object representing the primitive type boolean.
045:             *
046:             * @since   JDK1.1
047:             */
048:            public static final Class TYPE = Boolean.TYPE;
049:
050:            /**
051:             * The value of the Boolean.
052:             *
053:             * @serial
054:             */
055:            private final boolean value;
056:
057:            /** use serialVersionUID from JDK 1.0.2 for interoperability */
058:            //private static final long serialVersionUID = -3665804199014368530L;
059:            /**
060:             * Allocates a <code>ComparableBoolean</code> object representing the 
061:             * <code>value</code> argument. 
062:             *
063:             * <p><b>Note: It is rarely appropriate to use this constructor.
064:             * Unless a <i>new</i> instance is required, the static factory
065:             * {@link #valueOf(boolean)} is generally a better choice. It is
066:             * likely to yield significantly better space and time performance.</b>
067:             * 
068:             * @param   value   the value of the <code>Boolean</code>.
069:             */
070:            private ComparableBoolean(boolean value) {
071:                this .value = value;
072:            }
073:
074:            /**
075:             * Returns the value of this <tt>ComparableBoolean</tt> object as a boolean 
076:             * primitive.
077:             *
078:             * @return  the primitive <code>boolean</code> value of this object.
079:             */
080:            public boolean booleanValue() {
081:                return value;
082:            }
083:
084:            /**
085:             * Returns a <tt>ComparableBoolean</tt> instance representing the specified
086:             * <tt>boolean</tt> value.  If the specified <tt>boolean</tt> value
087:             * is <tt>true</tt>, this method returns <tt>ComparableBoolean.TRUE</tt>;
088:             * if it is <tt>false</tt>, this method returns <tt>ComparableBoolean.FALSE</tt>.
089:             * If a new <tt>ComparableBoolean</tt> instance is not required, this method
090:             * should generally be used in preference to the constructor
091:             * {@link #ComparableBoolean(boolean)}, as this method is likely to yield
092:             * significantly better space and time performance.
093:             *
094:             * @param  b a boolean value.
095:             * @return a <tt>ComparableBoolean</tt> instance representing <tt>b</tt>.
096:             * @since  1.4
097:             */
098:            public static ComparableBoolean valueOf(boolean b) {
099:                return (b ? TRUE : FALSE);
100:            }
101:
102:            /**
103:             * Returns a <tt>String</tt> object representing this ComparableBoolean's
104:             * value.  If this object represents the value <code>true</code>,
105:             * a string equal to <code>"true"</code> is returned. Otherwise, a
106:             * string equal to <code>"false"</code> is returned.
107:             *
108:             * @return  a string representation of this object. 
109:             */
110:            public String toString() {
111:                return value ? "true" : "false";//Boolean.toString(value);//$NON-NLS-1$//$NON-NLS-2$
112:            }
113:
114:            /**
115:             * Returns a hash code for this <tt>ComparableBoolean</tt> object.
116:             *
117:             * @return  the integer <tt>1231</tt> if this object represents 
118:             * <tt>true</tt>; returns the integer <tt>1237</tt> if this 
119:             * object represents <tt>false</tt>. 
120:             */
121:            public int hashCode() {
122:                return value ? 1231 : 1237;//Boolean.valueOf(value).hashCode();
123:            }
124:
125:            /**
126:             * Returns <code>true</code> if and only if the argument is not 
127:             * <code>null</code> and is a <code>ComparableBoolean</code> object that 
128:             * represents the same <code>boolean</code> value as this object. 
129:             *
130:             * @param   obj   the object to compare with.
131:             * @return  <code>true</code> if the Boolean objects represent the 
132:             *          same value; <code>false</code> otherwise.
133:             */
134:            public boolean equals(Object obj) {
135:                if (obj instanceof  ComparableBoolean) {
136:                    return value == ((ComparableBoolean) obj).booleanValue();
137:                }
138:                if (obj instanceof  Boolean) {
139:                    return value == ((Boolean) obj).booleanValue();
140:                }
141:                return false;
142:            }
143:
144:            /**
145:             * Compares this <tt>ComparableBoolean</tt> instance with another.
146:             *
147:             * @param   o the <tt>ComparableBoolean</tt> or <tt>Boolean</tt> instance to be compared
148:             * @return  zero if this object represents the same boolean value as the
149:             *          argument; a positive value if this object represents true
150:             *          and the argument represents false; and a negative value if
151:             *          this object represents false and the argument represents true
152:             * @throws  NullPointerException if the argument is <tt>null</tt>
153:             * @see     Comparable
154:             * @since  1.5
155:             */
156:            public int compareTo(Object o) {
157:                if (o instanceof  ComparableBoolean) {
158:                    Boolean bool = ((ComparableBoolean) o).value ? Boolean.TRUE
159:                            : Boolean.FALSE;//Boolean.valueOf(((ComparableBoolean)o).value);
160:                    return compareTo(bool);
161:                } else if (o instanceof  Boolean) {
162:                    return (((Boolean) o).booleanValue() == value ? 0
163:                            : (value ? 1 : -1));
164:                }
165:                throw new ClassCastException(o.getClass().getName());
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.