Mercurial > projects > dwt-addons
comparison dwtx/jface/text/Region.d @ 129:eb30df5ca28b
Added JFace Text sources
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 23 Aug 2008 19:10:48 +0200 |
parents | |
children | c4fb132a086c |
comparison
equal
deleted
inserted
replaced
128:8df1d4193877 | 129:eb30df5ca28b |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2007 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 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.jface.text.Region; | |
14 | |
15 import dwt.dwthelper.utils; | |
16 | |
17 | |
18 /** | |
19 * The default implementation of the {@link dwtx.jface.text.IRegion} interface. | |
20 */ | |
21 public class Region : IRegion { | |
22 | |
23 /** The region offset */ | |
24 private int fOffset; | |
25 /** The region length */ | |
26 private int fLength; | |
27 | |
28 /** | |
29 * Create a new region. | |
30 * | |
31 * @param offset the offset of the region | |
32 * @param length the length of the region | |
33 */ | |
34 public Region(int offset, int length) { | |
35 fOffset= offset; | |
36 fLength= length; | |
37 } | |
38 | |
39 /* | |
40 * @see dwtx.jface.text.IRegion#getLength() | |
41 */ | |
42 public int getLength() { | |
43 return fLength; | |
44 } | |
45 | |
46 /* | |
47 * @see dwtx.jface.text.IRegion#getOffset() | |
48 */ | |
49 public int getOffset() { | |
50 return fOffset; | |
51 } | |
52 | |
53 /* | |
54 * @see java.lang.Object#equals(java.lang.Object) | |
55 */ | |
56 public bool equals(Object o) { | |
57 if (o instanceof IRegion) { | |
58 IRegion r= (IRegion) o; | |
59 return r.getOffset() is fOffset && r.getLength() is fLength; | |
60 } | |
61 return false; | |
62 } | |
63 | |
64 /* | |
65 * @see java.lang.Object#hashCode() | |
66 */ | |
67 public int hashCode() { | |
68 return (fOffset << 24) | (fLength << 16); | |
69 } | |
70 | |
71 /* | |
72 * @see java.lang.Object#toString() | |
73 */ | |
74 public String toString() { | |
75 return "[" + fOffset + '+' + fLength + ']'; //$NON-NLS-1$ | |
76 } | |
77 } |