1 16 package com.blandware.atleap.webapp.taglib.core.grid.util; 17 18 import org.apache.commons.lang.builder.ToStringBuilder; 19 import org.apache.commons.lang.builder.ToStringStyle; 20 import org.apache.commons.logging.Log; 21 import org.apache.commons.logging.LogFactory; 22 23 import java.util.Collections ; 24 import java.util.LinkedList ; 25 import java.util.List ; 26 27 36 public abstract class BaseFilter implements GridFilter { 37 38 40 protected final Log log = LogFactory.getLog(BaseFilter.class); 41 42 45 protected String fieldName; 46 47 50 protected List rowIterators = Collections.synchronizedList(new LinkedList ()); 51 52 55 private String firstClause = new String (); 56 57 60 private String secondClause = new String (); 61 62 65 private String clause = new String (); 66 67 69 74 public BaseFilter(String fieldName) { 75 this.fieldName = fieldName; 76 } 77 78 83 public String getFieldName() { 84 return fieldName; 85 } 86 87 92 public List getRowIterators() { 93 return rowIterators; 94 } 95 96 101 public void setRowIterators(List rowIterators) { 102 this.rowIterators = rowIterators; 103 } 104 105 110 public void addRowIterator(String rowIteratorId) { 111 this.rowIterators.add(rowIteratorId); 112 } 113 114 120 protected String createNullComparison(String condition) { 121 return fieldName + " " + condition; 122 } 123 124 129 protected void setFirstClause(String firstClause) { 130 this.firstClause = firstClause; 131 } 132 133 139 protected void setSecondClause(String secondClause, String logicCopula) { 140 this.secondClause = " " + logicCopula + " " + secondClause; 141 } 142 143 150 public String getClause(String rowIteratorId) { 151 152 if ( (rowIteratorId == null) || (rowIterators.size() == 0) || (rowIterators.contains(rowIteratorId)) ) { 153 if ( firstClause.length() != 0 ) { 154 clause = "(" + firstClause + secondClause + ")"; 155 } else { 156 clause = null; 157 } 158 return clause; 159 } else { 160 return null; 161 } 162 } 163 164 169 public String getClause() { 170 return getClause(null); 171 } 172 173 public String toString() { 174 return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); 175 } 176 } 177 | Popular Tags |