1 17 18 package org.objectweb.jac.aspects.gui; 19 20 import java.util.Collection ; 21 import org.objectweb.jac.core.rtti.CollectionItem; 22 import org.objectweb.jac.core.rtti.FieldItem; 23 24 public class FilterCriteria { 25 public FilterCriteria(int column, FieldItem field) { 26 this.column = column; 27 this.field = field; 28 } 29 30 35 public boolean match(ExtendedTableModel model, int row) { 36 Object modelValue = model.getObject(row,column); 37 if (field instanceof CollectionItem) { 38 return !active || 39 (modelValue!=null && ((Collection )modelValue).contains(value)); 40 } else { 41 return !active || 42 (value==null && modelValue==null) || 43 (value!=null && value.equals(modelValue)); 44 } 45 } 46 47 48 int column; 49 public int getColumn() { 50 return column; 51 } 52 53 FieldItem field; 54 public FieldItem getField() { 55 return field; 56 } 57 58 59 boolean active = false; 60 public boolean isActive() { 61 return active; 62 } 63 public void setActive(boolean active) { 64 this.active = active; 65 } 66 67 Object value; 68 public void setValue(Object value) { 69 this.value = value; 70 } 71 public Object getValue() { 72 return value; 73 } 74 75 public String toString() { 76 return column+(active?("=="+value):"(off)"); 77 } 78 79 public boolean equals(Object o) { 80 if (!(o instanceof FilterCriteria)) 81 return false; 82 FilterCriteria criteria = (FilterCriteria)o; 83 return criteria.column==column && criteria.active==active; 84 } 85 86 public int hashCode() { 87 return column ^ (active ? 0 : 2^31); 88 } 89 } 90 | Popular Tags |