1 package org.jface.stepmt.core.util;
2
3 import org.jface.stepmt.core.Interval;
4 import org.jface.stepmt.core.Region;
5
6 public class TextRegion
7 {
8 private String text;
9 private Region region;
10 private String textAfter;
11 private boolean matchesIdentificator;
12 private boolean matchesPosition;
13
14 public TextRegion(
15 final Region region,
16 final String text,
17 final Interval interval,
18 final boolean matchesIdentificator, boolean matchesPosition)
19 {
20 this.region = region;
21 this.matchesIdentificator = matchesIdentificator;
22 this.matchesPosition = matchesPosition;
23 this.text = interval.textBefore(text);
24 textAfter = interval.textAfter(text);
25 }
26
27 public String getTextAfter()
28 {
29 return textAfter;
30 }
31
32 public String getText()
33 {
34 return text;
35 }
36
37 public Region getRegion()
38 {
39 return region;
40 }
41
42 public boolean isBetterThan(final TextRegion textRegion)
43 {
44 if (textRegion == null)
45 {
46 return true;
47 }
48 if (matchesPosition && !textRegion.matchesPosition)
49 {
50 return true;
51 }
52 if (!matchesPosition && textRegion.matchesPosition)
53 {
54 return false;
55 }
56 if (matchesIdentificator && !textRegion.matchesIdentificator)
57 {
58 return true;
59 }
60 if (!matchesIdentificator && textRegion.matchesIdentificator)
61 {
62 return false;
63 }
64 return text.length() < textRegion.text.length();
65 }
66
67 public int length()
68 {
69 return text.length();
70 }
71 }
This page was automatically generated by Maven