Source Code Cross Referenced for Convert.java in  » Scripting » Nice » gnu » lists » 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 » Scripting » Nice » gnu.lists 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // -*-Java-*-
002:        // Copyright (c) 2001  Per M.A. Bothner and Brainfood Inc.
003:        // This is free software;  for terms and warranty disclaimer see ./COPYING.
004:
005:        package gnu.lists;
006:
007:        /**
008:         * A class that encapsulates primitive<->Object conversions.
009:         * Applications can override the conversion if desired.
010:         * For example charToObject could use an "intern" table.
011:         */
012:
013:        public class Convert {
014:            public static Convert instance = new Convert();
015:
016:            public static Convert getInstance() {
017:                return instance;
018:            }
019:
020:            public static void setInstance(Convert value) {
021:                instance = value;
022:            };
023:
024:            public Object booleanToObject(boolean value) {
025:                return value ? Boolean.TRUE : Boolean.FALSE;
026:            }
027:
028:            public boolean objectToBoolean(Object obj) {
029:                return !(obj instanceof  Boolean)
030:                        || ((Boolean) obj).booleanValue();
031:            }
032:
033:            public static Object toObject(boolean value) {
034:                return instance.booleanToObject(value);
035:            }
036:
037:            public static boolean toBoolean(Object obj) {
038:                return instance.objectToBoolean(obj);
039:            }
040:
041:            public Object charToObject(char ch) {
042:                return new Character(ch);
043:            }
044:
045:            public char objectToChar(Object obj) {
046:                return ((Character) obj).charValue();
047:            }
048:
049:            public static Object toObject(char ch) {
050:                return instance.charToObject(ch);
051:            }
052:
053:            public static char toChar(Object obj) {
054:                return instance.objectToChar(obj);
055:            }
056:
057:            public Object byteToObject(byte value) {
058:                return new Byte(value);
059:            }
060:
061:            public byte objectToByte(Object obj) {
062:                return ((Number) obj).byteValue();
063:            }
064:
065:            public static Object toObject(byte value) {
066:                return instance.byteToObject(value);
067:            }
068:
069:            public static byte toByte(Object obj) {
070:                return instance.objectToByte(obj);
071:            }
072:
073:            public Object byteToObjectUnsigned(byte value) {
074:                return new Integer(value & 0xFF);
075:            }
076:
077:            public byte objectToByteUnsigned(Object obj) {
078:                return ((Number) obj).byteValue();
079:            }
080:
081:            public static Object toObjectUnsigned(byte value) {
082:                return instance.byteToObjectUnsigned(value);
083:            }
084:
085:            public static byte toByteUnsigned(Object obj) {
086:                return instance.objectToByteUnsigned(obj);
087:            }
088:
089:            public Object shortToObject(short value) {
090:                return new Short(value);
091:            }
092:
093:            public short objectToShort(Object obj) {
094:                return ((Number) obj).shortValue();
095:            }
096:
097:            public static Object toObject(short value) {
098:                return instance.shortToObject(value);
099:            }
100:
101:            public static short toShort(Object obj) {
102:                return instance.objectToShort(obj);
103:            }
104:
105:            public Object shortToObjectUnsigned(short value) {
106:                return new Integer(value & 0xFFFF);
107:            }
108:
109:            public short objectToShortUnsigned(Object obj) {
110:                return ((Number) obj).shortValue();
111:            }
112:
113:            public static Object toObjectUnsigned(short value) {
114:                return instance.shortToObjectUnsigned(value);
115:            }
116:
117:            public static short toShortUnsigned(Object obj) {
118:                return instance.objectToShortUnsigned(obj);
119:            }
120:
121:            public Object intToObject(int value) {
122:                return new Integer(value);
123:            }
124:
125:            public int objectToInt(Object obj) {
126:                return ((Number) obj).intValue();
127:            }
128:
129:            public static Object toObject(int value) {
130:                return instance.intToObject(value);
131:            }
132:
133:            public static int toInt(Object obj) {
134:                return instance.objectToInt(obj);
135:            }
136:
137:            public Object intToObjectUnsigned(int value) {
138:                if (value >= 0)
139:                    return new Integer(value);
140:                else
141:                    return new Long((long) value & 0xffffffffL);
142:            }
143:
144:            public int objectToIntUnsigned(Object obj) {
145:                return ((Number) obj).intValue();
146:            }
147:
148:            public static Object toObjectUnsigned(int value) {
149:                return instance.intToObjectUnsigned(value);
150:            }
151:
152:            public static int toIntUnsigned(Object obj) {
153:                return instance.objectToIntUnsigned(obj);
154:            }
155:
156:            public Object longToObject(long value) {
157:                return new Long(value);
158:            }
159:
160:            public long objectToLong(Object obj) {
161:                return ((Number) obj).longValue();
162:            }
163:
164:            public static Object toObject(long value) {
165:                return instance.longToObject(value);
166:            }
167:
168:            public static long toLong(Object obj) {
169:                return instance.objectToLong(obj);
170:            }
171:
172:            public Object longToObjectUnsigned(long value) {
173:                return new Long(value); // FIXME use BigInteger?
174:            }
175:
176:            public long objectToLongUnsigned(Object obj) {
177:                return ((Number) obj).longValue();
178:            }
179:
180:            public static Object toObjectUnsigned(long value) {
181:                return instance.longToObjectUnsigned(value);
182:            }
183:
184:            public static long toLongUnsigned(Object obj) {
185:                return instance.objectToLongUnsigned(obj);
186:            }
187:
188:            public Object floatToObject(float value) {
189:                return new Float(value);
190:            }
191:
192:            public float objectToFloat(Object obj) {
193:                return ((Number) obj).floatValue();
194:            }
195:
196:            public static Object toObject(float value) {
197:                return instance.floatToObject(value);
198:            }
199:
200:            public static float toFloat(Object obj) {
201:                return instance.objectToFloat(obj);
202:            }
203:
204:            public Object doubleToObject(double value) {
205:                return new Double(value);
206:            }
207:
208:            public double objectToDouble(Object obj) {
209:                return ((Number) obj).doubleValue();
210:            }
211:
212:            public static Object toObject(double value) {
213:                return instance.doubleToObject(value);
214:            }
215:
216:            public static double toDouble(Object obj) {
217:                return instance.objectToDouble(obj);
218:            }
219:
220:            public static double parseDouble(String str) {
221:                // We assume that if collections are available the Double.parseDouble
222:                // is also available.
223:                return Double.parseDouble(str);
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.