01: /*
02: * AndExpression.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.storage.filter;
13:
14: import java.util.Map;
15:
16: /**
17: * @author support@sql-workbench.net
18: */
19: public class AndExpression extends ComplexExpression {
20: public AndExpression() {
21: }
22:
23: public boolean evaluate(Map<String, Object> columnValues) {
24: for (FilterExpression expr : filter) {
25: if (!expr.evaluate(columnValues))
26: return false;
27: }
28: return true;
29: }
30:
31: public boolean equals(Object other) {
32: if (other instanceof AndExpression) {
33: return super .equals(other);
34: } else {
35: return false;
36: }
37: }
38:
39: public String toString() {
40: StringBuilder value = new StringBuilder();
41: for (FilterExpression expr : filter) {
42: if (value.length() > 0)
43: value.append(" AND ");
44: value.append(expr.toString());
45: }
46: return value.toString();
47: }
48:
49: }
|