1 16 package com.blandware.atleap.webapp.taglib.core.grid.util; 17 18 import com.blandware.atleap.common.util.StringUtil; 19 20 27 public class StringFilter extends BaseFilter { 28 29 31 private String firstCondition = FilterConditions.STRING_CONTAINS; 32 private String firstValue = new String (); 33 private String secondCondition = FilterConditions.CONDITION_NOT_SET; 34 private String secondValue = new String (); 35 private String logicCopula = FilterConditions.LOGIC_COPULA_AND; 36 37 42 public StringFilter(String fieldName) { 43 super(fieldName); 44 } 45 46 53 private String createClause(String condition, String compareTo) { 54 if ( condition.equalsIgnoreCase(FilterConditions.OBJECT_IS_NULL) || condition.equalsIgnoreCase(FilterConditions.OBJECT_IS_NOT_NULL) ) { 55 return createNullComparison(condition); 56 } 57 int k = condition.indexOf("{0}"); 58 StringBuffer stringBuffer = new StringBuffer (condition); 59 stringBuffer.replace(k, k + 3, StringUtil.escape(compareTo)); 60 return fieldName + " " + stringBuffer.toString(); 61 } 62 63 69 public void createFirstClause(String condition, String compareTo) { 70 this.firstCondition = condition; 71 this.firstValue = compareTo; 72 setFirstClause(createClause(condition, compareTo)); 73 } 74 75 82 public void createSecondClause(String condition, String compareTo, String logicCopula) { 83 this.secondCondition = condition; 84 this.secondValue = compareTo; 85 this.logicCopula = logicCopula; 86 setSecondClause(createClause(condition, compareTo), logicCopula); 87 } 88 89 95 public void createSecondClause(String condition, String compareTo) { 96 createSecondClause(condition, compareTo, FilterConditions.LOGIC_COPULA_AND); 97 } 98 99 104 public String getFirstCondition() { 105 return firstCondition; 106 } 107 108 113 public String getFirstValue() { 114 return firstValue; 115 } 116 117 122 public String getSecondCondition() { 123 return secondCondition; 124 } 125 126 131 public String getSecondValue() { 132 return secondValue; 133 } 134 135 140 public String getLogicCopula() { 141 return logicCopula; 142 } 143 144 } 145 | Popular Tags |