1 18 19 package sync4j.syncclient.spds; 20 21 import java.util.Vector ; 22 23 import sync4j.syncclient.sps.common.*; 24 25 26 31 public class SyncRecordFunction { 32 33 34 39 public static void setTimestamp(Record record, String timestamp) { 40 41 Vector values = null; 42 values = new Vector (); 43 44 values.addElement(timestamp); 45 46 record.setRecordField("timestamp", values); 47 } 48 49 50 51 56 public static void setModificationType(Record record, String modificationType) { 57 58 Vector values = null; 59 values = new Vector (); 60 61 values.addElement(modificationType); 62 63 record.setRecordField("mtype", values); 64 } 65 66 67 68 72 public static String getTimestamp(Record record) { 73 74 Vector values = null; 75 76 values = record.getRecordField("timestamp"); 77 78 return (String ) values.elementAt(0); 79 } 80 81 85 public static String getModificationType(Record record) { 86 87 Vector values = null; 88 89 values = record.getRecordField("mtype"); 90 91 return (String ) values.elementAt(0); 92 93 } 94 95 96 97 101 public static int getPositionTimestampField(Record record) { 102 103 Vector positions = null; 104 105 RecordMetadata recordMetadata = null; 106 107 recordMetadata = record.getDataStore().getRecordMetadata(); 108 109 positions = recordMetadata.getRecordFieldPosition("timestamp"); 110 111 if (positions.size() > 0) { 112 return Integer.parseInt(String.valueOf(positions.elementAt(0))); 113 } else { 114 return -1; 115 } 116 117 } 118 119 120 121 125 public static int getPositionModificationTypeField(Record record) { 126 127 Vector positions = null; 128 129 RecordMetadata recordMetadata = null; 130 131 recordMetadata = record.getDataStore().getRecordMetadata(); 132 133 positions = recordMetadata.getRecordFieldPosition("mtype"); 134 135 if (positions.size() > 0) { 136 return Integer.parseInt(String.valueOf(positions.elementAt(0))); 137 } else { 138 return -1; 139 } 140 141 } 142 143 144 148 public static int getNumberOperationFields(Record record) { 149 150 int numberOperationFields = 0; 151 152 Vector positions = null; 153 154 RecordMetadata recordMetadata = null; 155 156 recordMetadata = record.getDataStore().getRecordMetadata(); 157 158 positions = recordMetadata.getRecordFieldPosition("key"); 159 160 if (positions.size()>0) { 161 numberOperationFields = positions.size(); 162 } 163 164 positions = recordMetadata.getRecordFieldPosition("timestamp"); 165 166 if (positions.size()>0) { 167 numberOperationFields = numberOperationFields + positions.size(); 168 } 169 170 positions = recordMetadata.getRecordFieldPosition("mtype"); 171 172 if (positions.size()>0) { 173 numberOperationFields = numberOperationFields + positions.size(); 174 } 175 176 return numberOperationFields; 177 178 } 179 180 185 public static int getKeyFieldPosition(RecordMetadata recordMetadata) { 186 Vector positions = null; 187 188 positions = recordMetadata.getRecordFieldPosition("key"); 189 190 if (positions.size() > 0) { 191 return Integer.parseInt(String.valueOf(positions.elementAt(0))); 192 } else { 193 return -1; 194 } 195 } 196 197 202 public static int getModificationTypeFieldPosition(RecordMetadata recordMetadata) { 203 Vector positions = null; 204 205 positions = recordMetadata.getRecordFieldPosition("mtype"); 206 207 if (positions.size() > 0) { 208 return Integer.parseInt(String.valueOf(positions.elementAt(0))); 209 } else { 210 return -1; 211 } 212 } 213 214 } | Popular Tags |