1 18 19 package sync4j.syncclient.sps.common; 20 21 import java.util.Vector ; 22 23 import sync4j.syncclient.sps.common.*; 24 25 26 34 35 public class FindFilter extends RecordFilter { 36 37 38 40 private DataStore dataStore = null ; 41 private Vector valueToFind = null ; 42 43 private boolean include = false ; 44 private boolean caseSensitive = false ; 45 46 48 58 59 public FindFilter (DataStore dataStore, Vector valueToFind, boolean include, boolean caseSensitive) { 60 61 this.dataStore = dataStore ; 62 this.valueToFind = valueToFind ; 63 this.include = include ; 64 this.caseSensitive = caseSensitive ; 65 66 } 67 68 70 77 public boolean accept (Record record) { 78 79 boolean test = false ; 80 String valueR = null ; 81 String valueF = null ; 82 83 for (int i=0, l = this.valueToFind.size(); i < l; i++) { 84 85 valueR = record.getString(i); 86 87 valueF = (String ) this.valueToFind.elementAt(i); 88 89 if(include && caseSensitive && valueF.length() > 0 90 && (valueR.toUpperCase().indexOf(valueF.toUpperCase()) != -1)) { 91 92 test = true; 93 94 break; 95 96 } else if(!include && caseSensitive && valueF.length() > 0 97 && valueR.toUpperCase().equals(valueF.toUpperCase())) { 98 99 test = true; 100 101 break; 102 103 } else if(!include && !caseSensitive && valueF.length() > 0 104 && valueR.equals(valueF)) { 105 106 test = true; 107 108 break; 109 110 } if(include && !caseSensitive && valueF.length() > 0 111 && (valueR.indexOf(valueF) != -1)) { 112 113 test = true; 114 115 break; 116 117 } 118 119 } 120 121 return test; 122 123 } 124 125 } | Popular Tags |