1 package org.apache.ojb.broker.accesslayer.conversions; 2 3 17 18 24 public class Boolean2IntFieldConversion implements FieldConversion 25 { 26 private static Integer I_TRUE = new Integer (1); 27 private static Integer I_FALSE = new Integer (0); 28 29 32 public Object javaToSql(Object source) 33 { 34 if (source instanceof Boolean ) 35 { 36 if (source.equals(Boolean.TRUE)) 37 { 38 return I_TRUE; 39 } 40 else 41 { 42 return I_FALSE; 43 } 44 } 45 else 46 { 47 return source; 48 } 49 } 50 51 54 public Object sqlToJava(Object source) 55 { 56 if (source instanceof Integer ) 57 { 58 if (source.equals(I_TRUE)) 59 { 60 return Boolean.TRUE; 61 } 62 else 63 { 64 return Boolean.FALSE; 65 } 66 } 67 else 68 { 69 return source; 70 } 71 } 72 73 } 74 | Popular Tags |