01: /*
02: * NotStartsWithComparator.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 NotStartsWithComparator implements ColumnComparator {
18: public NotStartsWithComparator() {
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 "does not start with";
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: String v = (String) value;
51: String ref = (String) reference;
52: if (ignoreCase)
53: return !v.toLowerCase().startsWith(ref.toLowerCase());
54: else
55: return !v.startsWith(ref);
56: } catch (Exception e) {
57: return false;
58: }
59: }
60:
61: public boolean supportsType(Class valueClass) {
62: return (CharSequence.class.isAssignableFrom(valueClass));
63: }
64:
65: public boolean equals(Object other) {
66: return (other instanceof NotStartsWithComparator);
67: }
68:
69: }
|