KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > values > CheckBasicSetters


1 /*
2  * Copyright (c) 2005, Rob Gordon.
3  */

4 package org.oddjob.values;
5
6 import java.text.SimpleDateFormat JavaDoc;
7 import java.util.Date JavaDoc;
8
9 import org.oddjob.framework.SimpleJob;
10
11 /**
12  *
13  * @author Rob Gordon.
14  */

15 public class CheckBasicSetters extends SimpleJob {
16
17     boolean checkBoolean;
18     byte checkByte;
19     char checkChar;
20     Date JavaDoc checkDate;
21     double checkDouble;
22     float checkFloat;
23     int checkInt;
24     long checkLong;
25     short checkShort;
26     String JavaDoc checkString;
27     
28     public int execute() {
29         if (checkBoolean != true) {
30             throw new IllegalStateException JavaDoc("boolean wrong.");
31         }
32         if (checkByte != 127) {
33             throw new IllegalStateException JavaDoc("byte wrong.");
34         }
35         if (checkChar != 'a') {
36             throw new IllegalStateException JavaDoc("char wrong.");
37         }
38         if (!new SimpleDateFormat JavaDoc("dd-MMM-yy").format(checkDate)
39                 .equals("25-Dec-05")) {
40             throw new IllegalStateException JavaDoc("date wrong.");
41         }
42         if (checkDouble != 9E99) {
43             throw new IllegalStateException JavaDoc("double wrong.");
44         }
45         if (checkFloat != 1.23F) {
46             throw new IllegalStateException JavaDoc("float wrong.");
47         }
48         if (checkInt != 1234567) {
49             throw new IllegalStateException JavaDoc("int wrong.");
50         }
51         if (checkLong != 2345678) {
52             throw new IllegalStateException JavaDoc("int wrong.");
53         }
54         if (checkShort !=123) {
55             throw new IllegalStateException JavaDoc("short wrong.");
56         }
57         if (!checkString.equals("hello")) {
58             throw new IllegalStateException JavaDoc("string wrong.");
59         }
60         return 0;
61     }
62     public void setCheckBoolean(boolean checkBoolean) {
63         this.checkBoolean = checkBoolean;
64     }
65     public void setCheckByte(byte checkByte) {
66         this.checkByte = checkByte;
67     }
68     public void setCheckChar(char checkChar) {
69         this.checkChar = checkChar;
70     }
71     public void setCheckDate(Date JavaDoc checkDate) {
72         this.checkDate = checkDate;
73     }
74     public void setCheckDouble(double checkDouble) {
75         this.checkDouble = checkDouble;
76     }
77     public void setCheckFloat(float checkFloat) {
78         this.checkFloat = checkFloat;
79     }
80     public void setCheckInt(int checkInt) {
81         this.checkInt = checkInt;
82     }
83     public void setCheckLong(long checkLong) {
84         this.checkLong = checkLong;
85     }
86     public void setCheckShort(short checkShort) {
87         this.checkShort = checkShort;
88     }
89     public void setCheckString(String JavaDoc checkString) {
90         this.checkString = checkString;
91     }
92 }
93
Popular Tags