1 18 19 20 21 22 package sync4j.syncclient.sps.palm; 23 24 import java.io.*; 25 import java.util.Vector ; 26 27 import palm.conduit.*; 28 29 30 38 public class PalmRecord extends AbstractRecord { 39 40 42 private int recordSize = 0; 43 44 private String key = null; 45 private Vector store = new Vector (); 46 47 49 public String getKey() { 50 return this.key; 51 } 52 53 public String getStoreField(int i) { 54 return (String ) store.elementAt(i); 55 } 56 57 public int getSize() { 58 return this.store.size(); 59 } 60 61 public String getField(int position) { 62 return (String ) this.store.elementAt(position); 63 } 64 65 public int getRecordSize() { 66 return this.recordSize; 67 } 68 69 public void setKey(String key) { 70 this.key = key; 71 } 72 73 public void setField(int position, String value) { 74 this.store.setElementAt((Object ) value, position); 75 } 76 77 public void addStoreField(String field) { 78 this.store.addElement(field); 79 } 80 81 public void setRecordSize(int recordSize) { 82 this.recordSize = recordSize; 83 } 84 85 public void writeData(DataOutputStream out) throws IOException { 86 String fieldValue = null; 87 88 if (this.key != null) { 89 out.write(key.getBytes()); 90 out.write(0); 91 } 92 93 int l = store.size(); 94 95 for (int i=0; i < l; i++) { 96 fieldValue = (String ) store.elementAt(i); 97 98 if (fieldValue == null) { 99 fieldValue = ""; 100 } 101 102 out.write(fieldValue.getBytes()); 103 out.write(0); 104 } 105 } 106 107 112 public void readData(DataInputStream in) throws IOException { 113 Vector tmpStore = new Vector (); 114 115 this.key = readCString(in); 116 117 int l = this.recordSize; 118 119 for(int i=0; i < l; i++) { 120 tmpStore.addElement(readCString(in)); 121 } 122 123 this.store = tmpStore; 124 } 125 } | Popular Tags |