01: /*
02: * Copyright (C) 2003 Gerd Wagner
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or any later version.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: */
18: package net.sourceforge.squirrel_sql.fw.completion;
19:
20: public abstract class CompletionInfo implements
21: Comparable<CompletionInfo> {
22: private String _upperCaseCompletionString;
23:
24: public abstract String getCompareString();
25:
26: public String getCompletionString() {
27: return getCompareString();
28: }
29:
30: public int compareTo(CompletionInfo other) {
31: if (null == _upperCaseCompletionString) {
32: _upperCaseCompletionString = getCompareString()
33: .toUpperCase();
34: }
35:
36: if (null == other._upperCaseCompletionString) {
37: other._upperCaseCompletionString = other.getCompareString()
38: .toUpperCase();
39: }
40:
41: return _upperCaseCompletionString
42: .compareTo(other._upperCaseCompletionString);
43: }
44:
45: /**
46: * Param must be an upper case string if not the result will always be false
47: */
48: public boolean upperCaseCompletionStringStartsWith(String testString) {
49: if (null == _upperCaseCompletionString) {
50: _upperCaseCompletionString = getCompareString()
51: .toUpperCase();
52: }
53:
54: return _upperCaseCompletionString.startsWith(testString);
55: }
56:
57: /**
58: * Param must be an upper case string if not the result will always be false
59: */
60: public boolean upperCaseCompletionStringEquals(String testString) {
61: if (null == _upperCaseCompletionString) {
62: _upperCaseCompletionString = getCompareString()
63: .toUpperCase();
64: }
65:
66: return _upperCaseCompletionString.equals(testString);
67: }
68:
69: /**
70: * Default implementation
71: */
72: public boolean hasColumns() {
73: return false;
74: }
75:
76: public String toString() {
77: return getCompletionString();
78: }
79: }
|