Source Code Cross Referenced for AllFieldTypesTest.java in  » Database-ORM » openjpa » org » apache » openjpa » persistence » kernel » common » apps » 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 » openjpa » org.apache.openjpa.persistence.kernel.common.apps 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.    
018:         */
019:        package org.apache.openjpa.persistence.kernel.common.apps;
020:
021:        import java.math.BigDecimal;
022:        import java.math.BigInteger;
023:        import java.util.Arrays;
024:        import java.util.Calendar;
025:        import java.util.Date;
026:        import javax.persistence.Entity;
027:        import javax.persistence.GeneratedValue;
028:        import javax.persistence.GenerationType;
029:        import javax.persistence.Id;
030:        import javax.persistence.Table;
031:        import javax.persistence.Temporal;
032:        import javax.persistence.TemporalType;
033:
034:        import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
035:
036:        /**
037:         * Used in testing; should be enhanced.
038:         */
039:        @Entity
040:        @Table(name="ALL_FLDTYPETEST")
041:        public class AllFieldTypesTest {
042:
043:            @Id
044:            @GeneratedValue(strategy=GenerationType.AUTO)
045:            private int id;
046:
047:            private int testint;
048:            private long testlong;
049:            private short testshort;
050:            private float testfloat;
051:            private double testdouble;
052:            private byte testbyte;
053:            private boolean testboolean;
054:            private char testchar;
055:            private String testString;
056:            private String testBigString;
057:            @Temporal(TemporalType.DATE)
058:            private Date testDate;
059:            @Temporal(TemporalType.DATE)
060:            private Calendar testCalendar;
061:            private Object testObject;
062:            private BigInteger testBigInteger;
063:            private BigDecimal testBigDecimal;
064:
065:            public AllFieldTypesTest() {
066:                testfloat = 1f;
067:                testdouble = 1.0;
068:            }
069:
070:            public Date getTestDate() {
071:                return this .testDate;
072:            }
073:
074:            public void setTestDate(Date testDate) {
075:                this .testDate = testDate;
076:            }
077:
078:            public void setTestCalendar(Calendar testCalendar) {
079:                this .testCalendar = testCalendar;
080:            }
081:
082:            public Calendar getTestCalendar() {
083:                return this .testCalendar;
084:            }
085:
086:            public Object getTestObject() {
087:                return this .testObject;
088:            }
089:
090:            public void setTestObject(Object testObject) {
091:                this .testObject = testObject;
092:            }
093:
094:            public char getTestchar() {
095:                return this .testchar;
096:            }
097:
098:            public void setTestchar(char testchar) {
099:                this .testchar = testchar;
100:            }
101:
102:            public int getTestint() {
103:                return this .testint;
104:            }
105:
106:            public void setTestint(int testint) {
107:                this .testint = testint;
108:            }
109:
110:            public short getTestshort() {
111:                return this .testshort;
112:            }
113:
114:            public void setTestshort(short testshort) {
115:                this .testshort = testshort;
116:            }
117:
118:            public long getTestlong() {
119:                return this .testlong;
120:            }
121:
122:            public void setTestlong(long testlong) {
123:                this .testlong = testlong;
124:            }
125:
126:            public boolean getTestboolean() {
127:                return this .testboolean;
128:            }
129:
130:            public void setTestboolean(boolean testboolean) {
131:                this .testboolean = testboolean;
132:            }
133:
134:            public float getTestfloat() {
135:                return this .testfloat;
136:            }
137:
138:            public void setTestfloat(float testfloat) {
139:                this .testfloat = testfloat;
140:            }
141:
142:            public double getTestdouble() {
143:                return this .testdouble;
144:            }
145:
146:            public void setTestdouble(double testdouble) {
147:                this .testdouble = testdouble;
148:            }
149:
150:            public String getTestString() {
151:                return this .testString;
152:            }
153:
154:            public void setTestString(String testString) {
155:                this .testString = testString;
156:            }
157:
158:            public void setTestBigString(String testBigString) {
159:                this .testBigString = testBigString;
160:            }
161:
162:            public String getTestBigString() {
163:                return this .testBigString;
164:            }
165:
166:            public byte getTestbyte() {
167:                return this .testbyte;
168:            }
169:
170:            public void setTestbyte(byte testbyte) {
171:                this .testbyte = testbyte;
172:            }
173:
174:            public BigInteger getTestBigInteger() {
175:                return this .testBigInteger;
176:            }
177:
178:            public void setTestBigInteger(BigInteger testBigInteger) {
179:                this .testBigInteger = testBigInteger;
180:            }
181:
182:            public BigDecimal getTestBigDecimal() {
183:                return this .testBigDecimal;
184:            }
185:
186:            public void setTestBigDecimal(BigDecimal testBigDecimal) {
187:                this .testBigDecimal = testBigDecimal;
188:            }
189:
190:            public void randomize(boolean objects, boolean blobs) {
191:                testint = AbstractTestCase.randomInt().intValue();
192:                testlong = AbstractTestCase.randomLong().longValue();
193:                testshort = AbstractTestCase.randomShort().shortValue();
194:                testfloat = AbstractTestCase.randomFloat().floatValue();
195:                testdouble = AbstractTestCase.randomDouble().doubleValue();
196:                testbyte = AbstractTestCase.randomByte().byteValue();
197:                testboolean = AbstractTestCase.randomBoolean().booleanValue();
198:                testchar = AbstractTestCase.randomChar().charValue();
199:
200:                if (objects) {
201:                    testString = AbstractTestCase.randomString();
202:                    testDate = AbstractTestCase.randomDate();
203:
204:                    testCalendar = Calendar.getInstance();
205:                    testCalendar.setTime(AbstractTestCase.randomDate());
206:
207:                    testBigInteger = AbstractTestCase.randomBigInteger();
208:                    testBigDecimal = AbstractTestCase.randomBigDecimal();
209:                }
210:
211:                if (blobs && objects) {
212:                    testObject = AbstractTestCase.randomBlob();
213:                    testBigString = AbstractTestCase.randomClob();
214:                }
215:            }
216:
217:            public String toString() {
218:                return "\n{" + "testint="
219:                        + testint
220:                        + ";"
221:                        + "testlong="
222:                        + testlong
223:                        + ";"
224:                        + "testshort="
225:                        + testshort
226:                        + ";"
227:                        + "testfloat="
228:                        + testfloat
229:                        + ";"
230:                        + "testdouble="
231:                        + testdouble
232:                        + ";"
233:                        + "testbyte="
234:                        + testbyte
235:                        + ";"
236:                        + "testboolean="
237:                        + testboolean
238:                        + ";"
239:                        + "testchar="
240:                        + testchar
241:                        + ";"
242:                        + "testString="
243:                        + testString
244:                        + ";"
245:                        + "testBigString="
246:                        + testBigString
247:                        + ";"
248:                        + "testDate="
249:                        + testDate
250:                        + ";"
251:                        + "testCalendar="
252:                        + testCalendar
253:                        + ";"
254:                        + "testObject="
255:                        + testObject
256:                        + "("
257:                        + ((testObject instanceof  byte[]) ? "(byte[])"
258:                                + ((byte[]) testObject).length + ""
259:                                : (testObject == null ? "null" : testObject
260:                                        .getClass().getName())) + ")" + ";"
261:                        + "testBigInteger=" + testBigInteger + ";"
262:                        + "testBigDecimal=" + testBigDecimal + ";" + "}";
263:            }
264:
265:            public int hashCode() {
266:                return (int) ((testint
267:                        + testlong
268:                        + testshort
269:                        + testfloat
270:                        + testdouble
271:                        + testbyte
272:                        + (testboolean ? 1 : 0)
273:                        + testchar
274:                        + (testString == null ? 0 : testString.hashCode())
275:                        + (testBigString == null ? 0 : testBigString.hashCode())
276:                        + (testDate == null ? 0 : testDate.hashCode())
277:                        + (testCalendar == null ? 0 : testCalendar.hashCode())
278:                        + (testObject == null ? 0 : testObject.hashCode())
279:                        + (testBigInteger == null ? 0 : testBigInteger
280:                                .hashCode()) + (testBigDecimal == null ? 0
281:                        : testBigDecimal.hashCode())))
282:                        % Integer.MAX_VALUE;
283:            }
284:
285:            public boolean equals(Object other) {
286:                if (other == null && !(other instanceof  AllFieldTypesTest))
287:                    return false;
288:
289:                AllFieldTypesTest o = (AllFieldTypesTest) other;
290:
291:                return o.testint == testint && o.testlong == testlong
292:                        && o.testshort == testshort && o.testfloat == testfloat
293:                        && o.testdouble == testdouble && o.testbyte == testbyte
294:                        && o.testboolean == testboolean
295:                        && o.testchar == testchar
296:                        && eq(o.testString, testString)
297:                        && eq(o.testBigString, testBigString)
298:                        && eq(o.testDate, testDate)
299:                        && eq(o.testCalendar, testCalendar)
300:                        && eq(o.testObject, testObject)
301:                        && eq(o.testBigInteger, o.testBigInteger)
302:                        && eq(o.testBigDecimal, o.testBigDecimal);
303:            }
304:
305:            private boolean eq(Object a, Object b) {
306:                if (a == b)
307:                    return true;
308:                if (a == null && b != null)
309:                    return false;
310:                if (a != null && b == null)
311:                    return false;
312:
313:                // OK, this is stupid, but we want to special-case blobs
314:                // thay are byte arrays, since new byte [] { 1, 2} does not
315:                // equals inew byte [] { 1, 2}
316:                if (a instanceof  byte[] && b instanceof  byte[])
317:                    return Arrays.equals((byte[]) a, (byte[]) b);
318:
319:                return a.equals(b);
320:            }
321:        }
w___w_w___.___ja___v__a__2__s.co__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.