01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: DocumentPosition.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.datastructures;
09:
10: public class DocumentPosition implements Cloneable {
11: private String mLineContent;
12: private int mLine = -1;
13: private int mColumn = -1;
14:
15: public DocumentPosition(String lineContent, int line, int column) {
16: assert lineContent != null;
17: assert line >= 0;
18: assert column >= 0;
19:
20: mLineContent = lineContent;
21: mLine = line;
22: mColumn = column;
23: }
24:
25: public String getLineContent() {
26: return mLineContent;
27: }
28:
29: public int getLine() {
30: return mLine;
31: }
32:
33: public int getColumn() {
34: return mColumn;
35: }
36:
37: public boolean equals(Object other) {
38: if (this == other) {
39: return true;
40: }
41:
42: if (null == other) {
43: return false;
44: }
45:
46: if (!(other instanceof Pair)) {
47: return false;
48: }
49:
50: DocumentPosition other_documentposition = (DocumentPosition) other;
51:
52: return mLineContent.equals(other_documentposition.mLineContent)
53: && mLine == other_documentposition.mLine
54: && mColumn == other_documentposition.mColumn;
55: }
56:
57: public Pair clone() throws CloneNotSupportedException {
58: return (Pair) super .clone();
59: }
60:
61: public int hashCode() {
62: return mLineContent.hashCode() * mLine * mColumn;
63: }
64: }
|