public class PriceFilter implements Predicate { private int lowValue, highValue; private String attributeName = null; private int attributeIndex = -1; public PriceFilter(int lowValue, int highValue, String attributeName) { this.lowValue = lowValue; this.highValue = highValue; this.attributeName = attributeName; } public PriceFilter(int lowValue, int highValue, int attributeIndex) { this.lowValue = lowValue; this.highValue = highValue; this.attributeIndex = attributeIndex; } public boolean evaluate(Object value, String attributeName) { boolean result = true; if (attributeName.equalsIgnoreCase(this.attributeName)) { int attributeValue = ((Integer)value).intValue(); if (attributeValue >= this.lowValue && attributeValue <= this.highValue) { return true; } return false; } return result; } public boolean evaluate(Object value, int attributeIndex) { boolean result = true; if (attributeIndex == this.attributeIndex)) { int attributeValue = ((Integer)value).intValue(); if (attributeValue >= this.lowValue && attributeValue <= this.highValue) { return true; } return false; } return result; } public boolean evaluate (RowSet rowSet) { boolean result = false; CachedRowSet cachedRowSet = (CachedRowSet)rowSet; int attributeValue = -1; if (this.attributeName != null) { attributeValue = cachedRowSet.getInt(this.attributeName); } else if (this.attributeIndex > 0)) { attributeValue = cachedRowSet.getInt(this.attributeIndex); } else { return false; } if (attributeValue >= this.lowValue && attributeValue <= this.highValue) { result = true; } return result; } }