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