1 18 19 package sync4j.syncclient.sps.common; 20 21 import java.util.Vector ; 22 23 29 public class Record { 30 31 33 private Object [] data; 34 private DataStore dataStore; 35 private int positionKeyField; 36 37 38 public Record(DataStore dataStore, String key) { 40 41 String function = null; 42 Vector positions = null; 43 44 RecordMetadata recordMetadata = null; 45 46 this.data = new Object [dataStore.getRecordMetadata().getFieldMetadata().length]; 47 48 this.dataStore = dataStore; 49 50 recordMetadata = this.dataStore.getRecordMetadata(); 51 52 positions = recordMetadata.getRecordFieldPosition("key"); 53 54 positionKeyField = ((Integer ) positions.elementAt(0)).intValue(); 55 56 this.setField(positionKeyField, key); 57 58 } 59 60 61 63 69 public void setField(int i, String dataField) { 70 this.data[i - 1] = dataField; 71 } 72 73 78 public void setKey(String key) { 79 this.data[positionKeyField] = (Object ) key; 80 } 81 82 87 public void setDataStore(DataStore dataStore) { 88 this.dataStore = dataStore; 89 } 90 91 95 public String getKey() { 96 return (String ) this.getString(positionKeyField); 97 } 98 99 103 public DataStore getDataStore() { 104 return this.dataStore; 105 } 106 107 113 public String getString(int i) { 114 return (String ) this.data[i - 1]; 115 } 116 117 123 public int getInt(int i) { 124 return ((Integer ) this.data[i - 1]).intValue(); 125 } 126 127 130 public int getLength() { 131 return this.data.length; 132 } 133 134 137 public int getPositionKeyField() { 138 return this.positionKeyField; 139 } 140 141 145 public Vector getRecordField(String function) { 146 147 Vector positions = null; 148 Vector values = new Vector (); 149 150 positions = this.dataStore.getRecordMetadata().getRecordFieldPosition(function); 151 152 Integer pos = null; 153 154 int l = positions.size(); 155 156 for (int i=0; i < l; i++) { 157 values.addElement(this.getString(((Integer ) positions.elementAt(i)).intValue())); 158 } 159 160 return values; 161 162 } 163 164 168 public void setRecordField(String function, Vector values) { 169 170 Vector positions = null; 171 172 positions = this.dataStore.getRecordMetadata().getRecordFieldPosition(function); 173 174 int l = positions.size(); 175 176 for (int i=0; i < l; i++) { 177 this.setField(((Integer ) positions.elementAt(i)).intValue(), (String ) values.elementAt(i)); 178 } 179 180 return; 181 182 } 183 184 } | Popular Tags |