comparison dwtx/jface/text/TypedRegion.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, 2008 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.TypedRegion;
14
15 import dwt.dwthelper.utils;
16
17
18 /**
19 * Default implementation of {@link dwtx.jface.text.ITypedRegion}. A
20 * <code>TypedRegion</code> is a value object.
21 */
22 public class TypedRegion : Region , ITypedRegion {
23
24 /** The region's type */
25 private String fType;
26
27 /**
28 * Creates a typed region based on the given specification.
29 *
30 * @param offset the region's offset
31 * @param length the region's length
32 * @param type the region's type
33 */
34 public TypedRegion(int offset, int length, String type) {
35 super(offset, length);
36 fType= type;
37 }
38
39 /*
40 * @see dwtx.jface.text.ITypedRegion#getType()
41 */
42 public String getType() {
43 return fType;
44 }
45
46 /*
47 * @see java.lang.Object#equals(java.lang.Object)
48 */
49 public bool equals(Object o) {
50 if (o instanceof TypedRegion) {
51 TypedRegion r= (TypedRegion) o;
52 return super.equals(r) && ((fType is null && r.getType() is null) || fType.equals(r.getType()));
53 }
54 return false;
55 }
56
57 /*
58 * @see java.lang.Object#hashCode()
59 */
60 public int hashCode() {
61 int type= fType is null ? 0 : fType.hashCode();
62 return super.hashCode() | type;
63 }
64 }