1 18 19 package sync4j.syncclient.sps.jdbc; 20 21 import sync4j.syncclient.sps.common.*; 22 23 import java.util.Vector ; 24 25 33 34 public class FindFilter extends RecordFilter { 35 36 38 private DataStore dataStore = null ; 39 private Vector valueToFind = null ; 40 41 private boolean include = false; 42 private boolean caseSensitive = false; 43 44 46 55 public FindFilter (DataStore dataStore, Vector valueToFind, boolean include, boolean caseSensitive) { 56 57 this.dataStore = dataStore ; 58 this.valueToFind = valueToFind ; 59 this.include = include ; 60 this.caseSensitive = caseSensitive ; 61 } 62 63 65 72 public boolean accept (Record record) { 73 74 boolean test = false; 75 76 String valueR = null; 77 String valueF = null; 78 79 80 for (int i=0, l = this.valueToFind.size(); i < l; i++) { 81 82 valueR = record.getString(i); 83 valueF = (String ) this.valueToFind.elementAt(i); 84 85 if(include && caseSensitive && valueF.length() > 0 86 && (valueR.toUpperCase().indexOf(valueF.toUpperCase()) != -1)) { 87 test = true; 88 break; 89 } else if(!include && caseSensitive && valueF.length() > 0 90 && valueR.toUpperCase().equals(valueF.toUpperCase())) { 91 test = true; 92 break; 93 } else if(!include && !caseSensitive && valueF.length() > 0 94 && valueR.equals(valueF)) { 95 test = true; 96 break; 97 } if(include && !caseSensitive && valueF.length() > 0 98 && (valueR.indexOf(valueF) != -1)) { 99 test = true; 100 break; 101 } 102 103 } 104 105 return test; 106 107 } 108 109 } | Popular Tags |