01: package net.sourceforge.squirrel_sql.plugins.syntax.oster;
02:
03: /*
04: * This is based on the text editor demonstration class that comes with
05: * the Ostermiller Syntax Highlighter Copyright (C) 2001 Stephen Ostermiller
06: * http://ostermiller.org/contact.pl?regarding=Syntax+Highlighting
07:
08: * Modifications copyright (C) 2003 Colin Bell
09: * colbell@users.sourceforge.net
10: *
11: *
12: * This program is free software; you can redistribute it and/or
13: * modify it under the terms of the GNU General Public License
14: * as published by the Free Software Foundation; either version 2
15: * of the License, or any later version.
16: *
17: * This program is distributed in the hope that it will be useful,
18: * but WITHOUT ANY WARRANTY; without even the implied warranty of
19: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: * GNU General Public License for more details.
21: *
22: * You should have received a copy of the GNU General Public License
23: * along with this program; if not, write to the Free Software
24: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25: */
26: import java.util.Comparator;
27:
28: /**
29: * A wrapper for a position in a document appropriate for storing
30: * in a collection.
31: */
32: class DocPositionComparator implements Comparator<DocPosition> {
33: /**
34: * Does this Comparator equal another?
35: * Since all DocPositionComparators are the same, they
36: * are all equal.
37: *
38: * @return true for DocPositionComparators, false otherwise.
39: */
40: public boolean equals(Object obj) {
41: if (obj instanceof DocPositionComparator) {
42: return true;
43: } else {
44: return false;
45: }
46: }
47:
48: /**
49: * Compare two DocPositions
50: *
51: * @param o1 first DocPosition
52: * @param o2 second DocPosition
53: * @return negative if first < second, 0 if equal, positive if first > second
54: */
55: public int compare(DocPosition d1, DocPosition d2) {
56: return (d1.getPosition() - d2.getPosition());
57: }
58: }
|