01: /*
02: * LessOrEqualComparator.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 workbench.util.StringUtil;
15:
16: /**
17: * @author support@sql-workbench.net
18: */
19: public class LessOrEqualComparator implements ColumnComparator {
20: public LessOrEqualComparator() {
21: }
22:
23: public boolean supportsIgnoreCase() {
24: return false;
25: }
26:
27: public String getValueExpression(Object value) {
28: return (value == null ? "" : value.toString());
29: }
30:
31: public String getOperator() {
32: return "\u2264";
33: }
34:
35: public boolean needsValue() {
36: return true;
37: }
38:
39: public boolean comparesEquality() {
40: return false;
41: }
42:
43: public boolean evaluate(Object reference, Object value,
44: boolean ignoreCase) {
45: if (reference == null || value == null)
46: return false;
47: try {
48: return ((Comparable) reference)
49: .compareTo((Comparable) value) >= 0;
50: } catch (Exception e) {
51: return false;
52: }
53: }
54:
55: public boolean supportsType(Class valueClass) {
56: return Comparable.class.isAssignableFrom(valueClass);
57: }
58:
59: public boolean equals(Object other) {
60: return (other instanceof LessOrEqualComparator);
61: }
62:
63: public boolean validateInput(Object value) {
64: return (value instanceof Comparable);
65: }
66: }
|