Source Code Cross Referenced for ManyMethods.java in  » Database-DBMS » db-derby-10.2 » org » apache » derbyTesting » functionTests » util » 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 DBMS » db derby 10.2 » org.apache.derbyTesting.functionTests.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derbyTesting.functionTests.util.ManyMethods
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to You under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derbyTesting.functionTests.util;
023:
024:        import java.sql.Date;
025:        import java.sql.Time;
026:        import java.sql.Timestamp;
027:
028:        import java.math.BigDecimal;
029:
030:        import java.io.Serializable;
031:
032:        /**
033:         * This class is for testing method calls on user-defined types.  It has
034:         * many different methods for testing different cases.
035:         */
036:
037:        public class ManyMethods implements  Serializable {
038:
039:            int value;
040:            protected int protectedValue;
041:            private int privateValue;
042:            public int publicValue;
043:            public short publicshort;
044:            public Short publicShort;
045:            public byte publicbyte;
046:            public Byte publicByte;
047:            public int publicint;
048:            public Integer publicInteger;
049:            public long publiclong;
050:            public Long publicLong;
051:            public boolean publicboolean;
052:            public Boolean publicBoolean;
053:            public float publicfloat;
054:            public Float publicFloat;
055:            public double publicdouble;
056:            public Double publicDouble;
057:            public String publicString;
058:            public Date publicDate;
059:            public Time publicTime;
060:            public Timestamp publicTimestamp;
061:            public ManyMethods myself;
062:
063:            public static int NONOVERLOADED_INTSTATIC = 1;
064:            public static int OVERLOADED_INTSTATIC = 1;
065:            public static int OVEROVERLOADED_INTSTATIC = 1;
066:
067:            public ManyMethods(int value) {
068:                this .value = value;
069:                this .myself = this ;
070:                protectedValue = value;
071:                privateValue = value;
072:                publicValue = value;
073:                publicint = value;
074:                publicInteger = new Integer(value);
075:                publicshort = (short) value;
076:                publicShort = new Short((short) value);
077:                publicbyte = (byte) value;
078:                publicByte = new Byte((byte) value);
079:                publiclong = (long) value;
080:                publicLong = new Long((long) value);
081:                publicboolean = booleanMethod();
082:                publicBoolean = BooleanMethod();
083:                publicfloat = floatMethod();
084:                publicFloat = FloatMethod();
085:                publicdouble = doubleMethod();
086:                publicDouble = DoubleMethod();
087:                publicString = StringMethod();
088:                publicDate = DateMethod();
089:                publicTime = TimeMethod();
090:                publicTimestamp = TimestampMethod();
091:            }
092:
093:            /*
094:             ** The following methods are for testing signature matching.  Each method
095:             ** takes a single parameter.  The parameter types vary by method.  All
096:             ** of the Java primitive types are covered as well as their wrapper classes.
097:             ** All of the Java classes corresponding to the currently supported SQL
098:             ** types are covered.
099:             */
100:
101:            public String parmType(byte value) {
102:                return "byte parameter";
103:            }
104:
105:            public String parmType(byte[][][] value) {
106:                return "byte[][][] parameter";
107:            }
108:
109:            public String parmType(Byte value) {
110:                return "java.lang.Byte parameter";
111:            }
112:
113:            public String parmType(char value) {
114:                return "char parameter";
115:            }
116:
117:            public String parmType(Character value) {
118:                return "java.lang.Character parameter";
119:            }
120:
121:            public String parmType(double value) {
122:                return "double parameter";
123:            }
124:
125:            public String parmType(Double value) {
126:                return "java.lang.Double parameter";
127:            }
128:
129:            public String parmType(BigDecimal value) {
130:                return "java.math.BigDecimal parameter";
131:            }
132:
133:            public String parmType(float value) {
134:                return "float parameter";
135:            }
136:
137:            public String parmType(Float value) {
138:                return "java.lang.Float parameter";
139:            }
140:
141:            public String parmType(int value) {
142:                return "int parameter";
143:            }
144:
145:            public String parmType(Integer value) {
146:                return "java.lang.Integer parameter";
147:            }
148:
149:            public String parmType(long value) {
150:                return "long parameter";
151:            }
152:
153:            public String parmType(Long value) {
154:                return "java.lang.Long parameter";
155:            }
156:
157:            public String parmType(short value) {
158:                return "short parameter";
159:            }
160:
161:            public String parmType(Short value) {
162:                return "java.lang.Short parameter";
163:            }
164:
165:            public String parmType(boolean value) {
166:                return "boolean parameter";
167:            }
168:
169:            public String parmType(Boolean value) {
170:                return "java.lang.Boolean parameter";
171:            }
172:
173:            public String parmType(String value) {
174:                return "java.lang.String parameter";
175:            }
176:
177:            public String parmType(Date value) {
178:                return "java.sql.Date parameter";
179:            }
180:
181:            public String parmType(Time value) {
182:                return "java.sql.Time parameter";
183:            }
184:
185:            public String parmType(Timestamp value) {
186:                return "java.sql.Timestamp parameter";
187:            }
188:
189:            /*
190:             ** The following methods return all of the java primitive types and
191:             ** their wrapper classes, plus all of the types corresponding to the
192:             ** built-in SQL types.
193:             */
194:            public byte byteMethod() {
195:                return 1;
196:            }
197:
198:            public byte[][][] byteArrayArrayArrayMethod() {
199:                return new byte[3][][];
200:            }
201:
202:            public Byte ByteMethod() {
203:                return new Byte((byte) 1);
204:            }
205:
206:            public char charMethod() {
207:                return 'a';
208:            }
209:
210:            public Character CharacterMethod() {
211:                return new Character('a');
212:            }
213:
214:            public double doubleMethod() {
215:                return 1.5;
216:            }
217:
218:            public Double DoubleMethod() {
219:                return new Double(1.5);
220:            }
221:
222:            public BigDecimal BigDecimalMethod() {
223:                return new BigDecimal(1.4d);
224:            }
225:
226:            public float floatMethod() {
227:                return 2.5F;
228:            }
229:
230:            public Float FloatMethod() {
231:                return new Float(2.5F);
232:            }
233:
234:            public int intMethod() {
235:                return 2;
236:            }
237:
238:            public Integer IntegerMethod() {
239:                return new Integer(2);
240:            }
241:
242:            public long longMethod() {
243:                return 3L;
244:            }
245:
246:            public Long LongMethod() {
247:                return new Long(3L);
248:            }
249:
250:            public short shortMethod() {
251:                return (short) 4;
252:            }
253:
254:            public Short ShortMethod() {
255:                return new Short((short) 4);
256:            }
257:
258:            public boolean booleanMethod() {
259:                return true;
260:            }
261:
262:            public Boolean BooleanMethod() {
263:                return new Boolean(true);
264:            }
265:
266:            public String StringMethod() {
267:                return "A String";
268:            }
269:
270:            public Date DateMethod() {
271:                /* July 2, 1997 */
272:                // deprecated...note, that it was actually august, not july.
273:                // return new Date(97, 7, 2);
274:                return new Date(870505200000L);
275:            }
276:
277:            public Time TimeMethod() {
278:                /* 10:58:33 AM */
279:                // deprecated...
280:                // return new Time(10, 58, 33);
281:                return new Time(68313000L);
282:            }
283:
284:            public Timestamp TimestampMethod() {
285:                /* July 2, 1997 10:59:15.0 AM */
286:                // deprecated...note, actually August, not July, 1997
287:                // return new Timestamp(97, 7, 2, 10, 59, 15, 0);
288:                return new Timestamp(870544755000L);
289:            }
290:
291:            public ManyMethods ManyMethodsMethod() {
292:                return this ;
293:            }
294:
295:            /*
296:             ** The following methods are for testing null arguments.  These methods
297:             ** return Strings with the names of the parameter types, so we can be
298:             ** sure the right method was called.
299:             */
300:            public String isNull(Boolean value) {
301:                if (value == null)
302:                    return "Boolean is null";
303:                else
304:                    return "Boolean is not null";
305:            }
306:
307:            public String isNull(String value) {
308:                if (value == null)
309:                    return "String is null";
310:                else
311:                    return "String is not null";
312:            }
313:
314:            public String isNull(Double value) {
315:                if (value == null)
316:                    return "Double is null";
317:                else
318:                    return "Double is not null";
319:            }
320:
321:            public String isNull(BigDecimal value) {
322:                if (value == null)
323:                    return "BigDecimal is null";
324:                else
325:                    return "BigDecimal is not null";
326:            }
327:
328:            public String isNull(Integer value) {
329:                if (value == null)
330:                    return "Integer is null";
331:                else
332:                    return "Integer is not null";
333:            }
334:
335:            public String isNull(Float value) {
336:                if (value == null)
337:                    return "Float is null";
338:                else
339:                    return "Float is not null";
340:            }
341:
342:            public String isNull(Short value) {
343:                if (value == null)
344:                    return "Short is null";
345:                else
346:                    return "Short is not null";
347:            }
348:
349:            public String isNull(Date value) {
350:                if (value == null)
351:                    return "Date is null";
352:                else
353:                    return "Date is not null";
354:            }
355:
356:            public String isNull(Time value) {
357:                if (value == null)
358:                    return "Time is null";
359:                else
360:                    return "Time is not null";
361:            }
362:
363:            public String isNull(Timestamp value) {
364:                if (value == null)
365:                    return "Timestamp is null";
366:                else
367:                    return "Timestamp is not null";
368:            }
369:
370:            /* Methods with more than one parameter */
371:            public String integerFloatDouble(Integer parm1, Float parm2,
372:                    Double parm3) {
373:                return "integerFloatDouble method";
374:            }
375:
376:            public String stringDateTimeTimestamp(String parm1, Date parm2,
377:                    Time parm3, Timestamp parm4) {
378:                return "stringDateTimeTimestamp method";
379:            }
380:
381:            /* Static methods */
382:            public static int staticMethod() {
383:                return 1;
384:            }
385:
386:            public static int overloadedStaticMethod() {
387:                return 1;
388:            }
389:
390:            public static int overOverloadedStaticMethod() {
391:                return 1;
392:            }
393:
394:            public static Byte staticByteMethod() {
395:                return new Byte((byte) 1);
396:            }
397:
398:            public static Character staticCharacterMethod() {
399:                return new Character('a');
400:            }
401:
402:            public static Double staticDoubleMethod() {
403:                return new Double(1.5);
404:            }
405:
406:            public static BigDecimal staticBigDecimalMethod() {
407:                return new BigDecimal(1.1d);
408:            }
409:
410:            public static Float staticFloatMethod() {
411:                return new Float(2.5F);
412:            }
413:
414:            public static Long staticLongMethod() {
415:                return new Long(3L);
416:            }
417:
418:            public static Short staticShortMethod() {
419:                return new Short((short) 4);
420:            }
421:
422:            public static Integer staticIntegerMethod() {
423:                return new Integer(2);
424:            }
425:
426:            public static Boolean staticBooleanMethod() {
427:                return new Boolean(true);
428:            }
429:
430:            public static String staticStringMethod() {
431:                return "A String";
432:            }
433:
434:            public static Date staticDateMethod() {
435:                /* July 2, 1997 */
436:                return new Date(97, 7, 2);
437:            }
438:
439:            public static Time staticTimeMethod() {
440:                /* 10:58:33 AM */
441:                return new Time(10, 58, 33);
442:            }
443:
444:            public static Timestamp staticTimestampMethod() {
445:                /* July 2, 1997 10:59:15.0 AM */
446:                return new Timestamp(97, 7, 2, 10, 59, 15, 0);
447:            }
448:
449:            public static ManyMethods staticManyMethods(Integer value) {
450:                return new ManyMethods(value.intValue());
451:            }
452:
453:            /* "Cast to sub class" */
454:            public SubClass subClass() {
455:                if (this  instanceof  SubClass) {
456:                    return (SubClass) this ;
457:                } else {
458:                    return null;
459:                }
460:            }
461:
462:            public int[] getIntArray() {
463:                return new int[0];
464:            }
465:
466:            public Object[] getObjectArray() {
467:                return new String[0];
468:            }
469:
470:            /* Methods for negative testing */
471:            protected int protectedMethod() {
472:                return 1;
473:            }
474:
475:            private int privateMethod() {
476:                return 1;
477:            }
478:
479:            int packageMethod() {
480:                return 1;
481:            }
482:
483:            public int exceptionMethod() throws Throwable {
484:                throw new Throwable(
485:                        "This exception should be caught by the runtime system.");
486:            }
487:
488:            /*
489:             ** Some methods for testing interface resolution
490:             */
491:
492:            public static NoMethodInterface getNoMethodInterface() {
493:                return new SubInterfaceClass(67);
494:            }
495:
496:            public static Runnable getRunnable() {
497:                return new SubInterfaceClass(89);
498:            }
499:
500:            public static ExtendingInterface getExtendingInterface() {
501:                return new SubInterfaceClass(235);
502:            }
503:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.