]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/search/OccurrenceMatch.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / search / OccurrenceMatch.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2011 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.ui.search;
12
13 import org.eclipse.jface.text.Region;
14
15 import org.eclipse.search.ui.text.Match;
16
17 public class OccurrenceMatch extends Match {
18
19         private final int fFlags;
20         private Region fOriginalLocation;
21
22         public OccurrenceMatch(JavaElementLine element, int offset, int length, int flags) {
23                 super(element, offset, length);
24                 fFlags= flags;
25                 fOriginalLocation= null;
26         }
27
28         @Override
29         public void setOffset(int offset) {
30                 if (fOriginalLocation == null) {
31                         // remember the original location before changing it
32                         fOriginalLocation= new Region(getOffset(), getLength());
33                 }
34                 super.setOffset(offset);
35         }
36
37         @Override
38         public void setLength(int length) {
39                 if (fOriginalLocation == null) {
40                         // remember the original location before changing it
41                         fOriginalLocation= new Region(getOffset(), getLength());
42                 }
43                 super.setLength(length);
44         }
45
46         public int getOriginalOffset() {
47                 if (fOriginalLocation != null) {
48                         return fOriginalLocation.getOffset();
49                 }
50                 return getOffset();
51         }
52
53         public int getOriginalLength() {
54                 if (fOriginalLocation != null) {
55                         return fOriginalLocation.getLength();
56                 }
57                 return getLength();
58         }
59
60         public int getFlags() {
61                 return fFlags;
62         }
63
64
65 }