1 4 package org.oddjob.values; 5 6 import java.text.SimpleDateFormat ; 7 import java.util.Date ; 8 9 import org.oddjob.framework.SimpleJob; 10 11 15 public class CheckBasicSetters extends SimpleJob { 16 17 boolean checkBoolean; 18 byte checkByte; 19 char checkChar; 20 Date checkDate; 21 double checkDouble; 22 float checkFloat; 23 int checkInt; 24 long checkLong; 25 short checkShort; 26 String checkString; 27 28 public int execute() { 29 if (checkBoolean != true) { 30 throw new IllegalStateException ("boolean wrong."); 31 } 32 if (checkByte != 127) { 33 throw new IllegalStateException ("byte wrong."); 34 } 35 if (checkChar != 'a') { 36 throw new IllegalStateException ("char wrong."); 37 } 38 if (!new SimpleDateFormat ("dd-MMM-yy").format(checkDate) 39 .equals("25-Dec-05")) { 40 throw new IllegalStateException ("date wrong."); 41 } 42 if (checkDouble != 9E99) { 43 throw new IllegalStateException ("double wrong."); 44 } 45 if (checkFloat != 1.23F) { 46 throw new IllegalStateException ("float wrong."); 47 } 48 if (checkInt != 1234567) { 49 throw new IllegalStateException ("int wrong."); 50 } 51 if (checkLong != 2345678) { 52 throw new IllegalStateException ("int wrong."); 53 } 54 if (checkShort !=123) { 55 throw new IllegalStateException ("short wrong."); 56 } 57 if (!checkString.equals("hello")) { 58 throw new IllegalStateException ("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 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 checkString) { 90 this.checkString = checkString; 91 } 92 } 93 | Popular Tags |