KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > SourceRange


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.core;
12
13 import org.eclipse.jdt.core.ISourceRange;
14
15 /**
16  * @see ISourceRange
17  */

18 public class SourceRange implements ISourceRange {
19
20 protected int offset, length;
21
22 public SourceRange(int offset, int length) {
23     this.offset = offset;
24     this.length = length;
25 }
26 /*
27  * @see Object#equals(Object)
28  */

29 public boolean equals(Object JavaDoc obj) {
30     if (!(obj instanceof ISourceRange))
31         return false;
32     ISourceRange sourceRange = (ISourceRange) obj;
33     return sourceRange.getOffset() == this.offset && sourceRange.getLength() == this.length;
34 }
35 /**
36  * @see ISourceRange
37  */

38 public int getLength() {
39     return this.length;
40 }
41 /**
42  * @see ISourceRange
43  */

44 public int getOffset() {
45     return this.offset;
46 }
47 /*
48  * @see Object#hashCode()
49  */

50 public int hashCode() {
51     return this.length ^ this.offset;
52 }
53 public String JavaDoc toString() {
54     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
55     buffer.append("[offset="); //$NON-NLS-1$
56
buffer.append(this.offset);
57     buffer.append(", length="); //$NON-NLS-1$
58
buffer.append(this.length);
59     buffer.append("]"); //$NON-NLS-1$
60
return buffer.toString();
61 }
62 }
63
Popular Tags