1 10 11 package com.triactive.jdo; 12 13 import com.triactive.jdo.FieldManager; 14 15 16 26 27 public abstract class GenericFieldManager implements FieldManager 28 { 29 public void storeBooleanField(int field, boolean value) 30 { 31 storeObjectField(field, new Boolean (value)); 32 } 33 34 public boolean fetchBooleanField(int field) 35 { 36 Boolean value = (Boolean )fetchObjectField(field); 37 return value == null ? false : value.booleanValue(); 38 } 39 40 public void storeCharField(int field, char value) 41 { 42 storeObjectField(field, new Character (value)); 43 } 44 45 public char fetchCharField(int field) 46 { 47 Character value = (Character )fetchObjectField(field); 48 return value == null ? '\000' : value.charValue(); 49 } 50 51 public void storeByteField(int field, byte value) 52 { 53 storeObjectField(field, new Byte (value)); 54 } 55 56 public byte fetchByteField(int field) 57 { 58 Number value = (Number )fetchObjectField(field); 59 return value == null ? 0 : value.byteValue(); 60 } 61 62 public void storeShortField(int field, short value) 63 { 64 storeObjectField(field, new Short (value)); 65 } 66 67 public short fetchShortField(int field) 68 { 69 Number value = (Number )fetchObjectField(field); 70 return value == null ? 0 : value.shortValue(); 71 } 72 73 public void storeIntField(int field, int value) 74 { 75 storeObjectField(field, new Integer (value)); 76 } 77 78 public int fetchIntField(int field) 79 { 80 Number value = (Number )fetchObjectField(field); 81 return value == null ? 0 : value.intValue(); 82 } 83 84 public void storeLongField(int field, long value) 85 { 86 storeObjectField(field, new Long (value)); 87 } 88 89 public long fetchLongField(int field) 90 { 91 Number value = (Number )fetchObjectField(field); 92 return value == null ? 0 : value.longValue(); 93 } 94 95 public void storeFloatField(int field, float value) 96 { 97 storeObjectField(field, new Float (value)); 98 } 99 100 public float fetchFloatField(int field) 101 { 102 Number value = (Number )fetchObjectField(field); 103 return value == null ? 0 : value.floatValue(); 104 } 105 106 public void storeDoubleField(int field, double value) 107 { 108 storeObjectField(field, new Double (value)); 109 } 110 111 public double fetchDoubleField(int field) 112 { 113 Number value = (Number )fetchObjectField(field); 114 return value == null ? 0 : value.doubleValue(); 115 } 116 117 public void storeStringField(int field, String value) 118 { 119 storeObjectField(field, value); 120 } 121 122 public String fetchStringField(int field) 123 { 124 return (String )fetchObjectField(field); 125 } 126 127 public abstract void storeObjectField(int field, Object value); 128 129 public abstract Object fetchObjectField(int field); 130 } 131 | Popular Tags |