Source Code Cross Referenced for BasicType.java in  » Database-ORM » Speedo_1.4.5 » org » objectweb » speedo » pobjects » basic » 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 » Database ORM » Speedo_1.4.5 » org.objectweb.speedo.pobjects.basic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (C) 2001-2004 France Telecom R&D
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */package org.objectweb.speedo.pobjects.basic;
018:
019:        import junit.framework.Assert;
020:
021:        import java.math.BigDecimal;
022:        import java.math.BigInteger;
023:        import java.io.Serializable;
024:
025:        /**
026:         * This class contains the primitive type that Speedo must support:
027:         * boolean
028:         * byte
029:         * short
030:         * int
031:         * long
032:         * float
033:         * double
034:         * char
035:         * Boolean
036:         * Byte
037:         * Short
038:         * Integer
039:         * Long
040:         * Float
041:         * Double
042:         * Character
043:         * String
044:         * BigDecimal
045:         * BigInteger
046:         *
047:         * @author S.Chassande-Barrioz
048:         */
049:        public class BasicType implements  Serializable {
050:
051:            private boolean boolean_field;
052:            private byte byte_field;
053:            private short short_field;
054:            private int int_field;
055:            private long long_field;
056:            private float float_field;
057:            private double double_field;
058:            private char char_field;
059:
060:            private Boolean oboolean_field;
061:            private Byte obyte_field;
062:            private Short oshort_field;
063:            private Integer oint_field;
064:            private Long olong_field;
065:            private Float ofloat_field;
066:            private Double odouble_field;
067:            private Character ochar_field;
068:
069:            private char[] chararray_field;
070:            private byte[] bytearray_field;
071:            private double[] doubleArray_field;
072:            private String string_field;
073:            private BigDecimal bigdecimal_field;
074:            private BigInteger biginteger_field;
075:
076:            public void assign(long longval) {
077:                this .boolean_field = (longval % 2) == 1;
078:                this .oboolean_field = (boolean_field ? new Boolean(
079:                        boolean_field) : null);
080:
081:                this .byte_field = (byte) longval;
082:                this .obyte_field = (boolean_field ? new Byte(byte_field) : null);
083:
084:                this .char_field = (char) longval;
085:                this .ochar_field = (boolean_field ? new Character(char_field)
086:                        : null);
087:
088:                this .short_field = (short) longval;
089:                this .oshort_field = (boolean_field ? new Short(short_field)
090:                        : null);
091:
092:                this .int_field = (int) longval;
093:                this .oint_field = (boolean_field ? new Integer(int_field)
094:                        : null);
095:
096:                this .long_field = longval;
097:                this .olong_field = (boolean_field ? new Long(long_field) : null);
098:
099:                this .float_field = longval;
100:                this .ofloat_field = (boolean_field ? new Float(float_field)
101:                        : null);
102:
103:                this .double_field = longval;
104:                this .odouble_field = (boolean_field ? new Double(double_field)
105:                        : null);
106:
107:                this .chararray_field = (boolean_field ? new char[] { char_field }
108:                        : null);
109:                this .bytearray_field = (boolean_field ? new byte[] { byte_field }
110:                        : null);
111:                this .doubleArray_field = (boolean_field ? new double[] { double_field }
112:                        : null);
113:                this .string_field = (boolean_field ? "str" + longval : null);
114:                biginteger_field = (boolean_field ? new BigInteger("" + longval)
115:                        : null);
116:                bigdecimal_field = (boolean_field ? new BigDecimal(
117:                        biginteger_field) : null);
118:            }
119:
120:            public void check(long longval) {
121:                boolean isnull = (longval % 2) != 1;
122:                Assert.assertEquals("bad boolean_field value", boolean_field,
123:                        (longval % 2) == 1);
124:                Assert.assertEquals("bad boolean_field value", byte_field,
125:                        (byte) longval);
126:                Assert.assertEquals("bad boolean_field value", char_field,
127:                        (char) longval);
128:                Assert.assertEquals("bad boolean_field value", short_field,
129:                        (short) longval);
130:                Assert.assertEquals("bad boolean_field value", int_field,
131:                        (int) longval);
132:                Assert.assertEquals("bad boolean_field value", long_field,
133:                        longval);
134:                if (isnull) {
135:                    Assert
136:                            .assertNull("oboolean_field not null",
137:                                    oboolean_field);
138:                    Assert.assertNull("obyte_field not null", obyte_field);
139:                    Assert.assertNull("ochar_field not null", ochar_field);
140:                    Assert.assertNull("oshort_field not null", oshort_field);
141:                    Assert.assertNull("oint_field not null", oint_field);
142:                    Assert.assertNull("olong_field not null", olong_field);
143:                    Assert.assertNull("ofloat_field not null", ofloat_field);
144:                    Assert.assertNull("odouble_field not null", odouble_field);
145:                    Assert.assertNull("chararray_field not null",
146:                            chararray_field);
147:                    Assert.assertNull("bytearray_field not null",
148:                            bytearray_field);
149:                    Assert.assertNull("doublearray_field not null",
150:                            doubleArray_field);
151:                    Assert.assertNull("string_field not null", string_field);
152:                    Assert.assertNull("biginteger_field not null",
153:                            biginteger_field);
154:                    Assert.assertNull("bigdecimal_field not null",
155:                            bigdecimal_field);
156:                } else {
157:                    Assert.assertNotNull("oboolean_field null", oboolean_field);
158:                    Assert.assertNotNull("obyte_field null", obyte_field);
159:                    Assert.assertNotNull("ochar_field null", ochar_field);
160:                    Assert.assertNotNull("oshort_field null", oshort_field);
161:                    Assert.assertNotNull("oint_field null", oint_field);
162:                    Assert.assertNotNull("olong_field null", olong_field);
163:                    Assert.assertNotNull("ofloat_field null", ofloat_field);
164:                    Assert.assertNotNull("odouble_field null", odouble_field);
165:                    Assert.assertNotNull("chararray_field null",
166:                            chararray_field);
167:                    Assert.assertNotNull("bytearray_field null",
168:                            bytearray_field);
169:                    Assert.assertNotNull("doubleArray_field null",
170:                            doubleArray_field);
171:                    Assert.assertNotNull("string_field null", string_field);
172:                    Assert.assertNotNull("biginteger_field null",
173:                            biginteger_field);
174:                    Assert.assertNotNull("bigdecimal_field null",
175:                            bigdecimal_field);
176:
177:                    Assert.assertEquals("oboolean_field bad value",
178:                            boolean_field, oboolean_field.booleanValue());
179:                    Assert.assertEquals("obyte_field bad value", byte_field,
180:                            obyte_field.byteValue());
181:                    Assert.assertEquals("ochar_field bad value", char_field,
182:                            ochar_field.charValue());
183:                    Assert.assertEquals("oshort_field bad value", short_field,
184:                            oshort_field.shortValue());
185:                    Assert.assertEquals("oint_field bad value", int_field,
186:                            oint_field.intValue());
187:                    Assert.assertEquals("olong_field bad value", long_field,
188:                            olong_field.longValue());
189:                    Assert.assertEquals("chararray_field bad value", 1,
190:                            chararray_field.length);
191:                    Assert.assertEquals("chararray_field bad value",
192:                            char_field, chararray_field[0]);
193:                    Assert.assertEquals("bytearray_field bad value", 1,
194:                            bytearray_field.length);
195:                    Assert.assertEquals("bytearray_field bad value",
196:                            byte_field, bytearray_field[0]);
197:                    Assert.assertEquals("doubleArray_field bad value", 1,
198:                            doubleArray_field.length);
199:                    Assert.assertEquals("string_field bad value", "str"
200:                            + longval, string_field);
201:                    Assert.assertEquals("biginteger_field bad value",
202:                            new BigInteger("" + longval), biginteger_field);
203:                    BigDecimal expected = new BigDecimal(biginteger_field);
204:                    BigDecimal found = bigdecimal_field;
205:                    Assert.assertTrue("bigdecimal_field bad value, expected "
206:                            + expected + ", found: " + found, expected
207:                            .compareTo(found) == 0);
208:                }
209:            }
210:
211:            public boolean retrieve_boolean_field() {
212:                return boolean_field;
213:            }
214:
215:            public void assign_boolean_field(boolean boolean_field) {
216:                this .boolean_field = boolean_field;
217:            }
218:
219:            public byte retrieve_byte_field() {
220:                return byte_field;
221:            }
222:
223:            public void assign_byte_field(byte byte_field) {
224:                this .byte_field = byte_field;
225:            }
226:
227:            public short retrieve_short_field() {
228:                return short_field;
229:            }
230:
231:            public void assign_short_field(short short_field) {
232:                this .short_field = short_field;
233:            }
234:
235:            public int retrieve_int_field() {
236:                return int_field;
237:            }
238:
239:            public void assign_int_field(int int_field) {
240:                this .int_field = int_field;
241:            }
242:
243:            public long retrieve_long_field() {
244:                return long_field;
245:            }
246:
247:            public void assign_long_field(long long_field) {
248:                this .long_field = long_field;
249:            }
250:
251:            public float retrieve_float_field() {
252:                return float_field;
253:            }
254:
255:            public void assign_float_field(float float_field) {
256:                this .float_field = float_field;
257:            }
258:
259:            public double retrieve_double_field() {
260:                return double_field;
261:            }
262:
263:            public void assign_double_field(double double_field) {
264:                this .double_field = double_field;
265:            }
266:
267:            public char retrieve_char_field() {
268:                return char_field;
269:            }
270:
271:            public void assign_char_field(char char_field) {
272:                this .char_field = char_field;
273:            }
274:
275:            public Boolean retrieve_oboolean_field() {
276:                return oboolean_field;
277:            }
278:
279:            public void assign_oboolean_field(Boolean oboolean_field) {
280:                this .oboolean_field = oboolean_field;
281:            }
282:
283:            public Byte retrieve_obyte_field() {
284:                return obyte_field;
285:            }
286:
287:            public void assign_obyte_field(Byte obyte_field) {
288:                this .obyte_field = obyte_field;
289:            }
290:
291:            public Short retrieve_oshort_field() {
292:                return oshort_field;
293:            }
294:
295:            public void assign_oshort_field(Short oshort_field) {
296:                this .oshort_field = oshort_field;
297:            }
298:
299:            public Integer retrieve_oint_field() {
300:                return oint_field;
301:            }
302:
303:            public void assign_oint_field(Integer oint_field) {
304:                this .oint_field = oint_field;
305:            }
306:
307:            public Long retrieve_olong_field() {
308:                return olong_field;
309:            }
310:
311:            public void assign_olong_field(Long olong_field) {
312:                this .olong_field = olong_field;
313:            }
314:
315:            public Float retrieve_Float_field() {
316:                return ofloat_field;
317:            }
318:
319:            public void assign_Float_field(Float Float_field) {
320:                this .ofloat_field = Float_field;
321:            }
322:
323:            public Double retrieve_Double_field() {
324:                return odouble_field;
325:            }
326:
327:            public void assign_Double_field(Double Double_field) {
328:                this .odouble_field = Double_field;
329:            }
330:
331:            public Character retrieve_ochar_field() {
332:                return ochar_field;
333:            }
334:
335:            public void assign_ochar_field(Character ochar_field) {
336:                this .ochar_field = ochar_field;
337:            }
338:
339:            public String retrieve_string_field() {
340:                return string_field;
341:            }
342:
343:            public void assign_string_field(String string_field) {
344:                this .string_field = string_field;
345:            }
346:
347:            public BigDecimal retrieve_bigdecimal_field() {
348:                return bigdecimal_field;
349:            }
350:
351:            public void assign_bigdecimal_field(BigDecimal bigdecimal_field) {
352:                this .bigdecimal_field = bigdecimal_field;
353:            }
354:
355:            public BigInteger retrieve_biginteger_field() {
356:                return biginteger_field;
357:            }
358:
359:            public void assign_biginteger_field(BigInteger biginteger_field) {
360:                this .biginteger_field = biginteger_field;
361:            }
362:
363:            public char[] retrieve_chararray_field() {
364:                return chararray_field;
365:            }
366:
367:            public void assign_chararray_field(char[] chararray_field) {
368:                this .chararray_field = chararray_field;
369:            }
370:
371:            public byte[] retrieve_bytearray_field() {
372:                return bytearray_field;
373:            }
374:
375:            public void assign_bytearray_field(byte[] bytearray_field) {
376:                this .bytearray_field = bytearray_field;
377:            }
378:
379:            public double[] retrieve_doublearray_field() {
380:                return doubleArray_field;
381:            }
382:
383:            public void assign_doublearray_field(double[] doubleArray_field) {
384:                this.doubleArray_field = doubleArray_field;
385:            }
386:
387:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.