1 | /*
|
---|
2 | * 02/19/2006
|
---|
3 | *
|
---|
4 | * RegExReplaceInfo.java - Information about a regex text match.
|
---|
5 | *
|
---|
6 | * This library is distributed under a modified BSD license. See the included
|
---|
7 | * RSyntaxTextArea.License.txt file for details.
|
---|
8 | */
|
---|
9 | package org.fife.ui.rtextarea;
|
---|
10 |
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Information on how to implement a regular expression "replace" operation.
|
---|
14 | *
|
---|
15 | * @author Robert Futrell
|
---|
16 | * @version 1.0
|
---|
17 | */
|
---|
18 | class RegExReplaceInfo {
|
---|
19 |
|
---|
20 | private String matchedText;
|
---|
21 | private int startIndex;
|
---|
22 | private int endIndex;
|
---|
23 | private String replacement;
|
---|
24 |
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Constructor.
|
---|
28 | *
|
---|
29 | * @param matchedText The text that matched the regular expression.
|
---|
30 | * @param start The start index of the matched text in the
|
---|
31 | * <code>CharSequence</code> searched.
|
---|
32 | * @param end The end index of the matched text in the
|
---|
33 | * <code>CharSequence</code> searched.
|
---|
34 | * @param replacement The text to replace the matched text with. This
|
---|
35 | * string has any matched groups and character escapes replaced.
|
---|
36 | */
|
---|
37 | public RegExReplaceInfo(String matchedText, int start, int end,
|
---|
38 | String replacement) {
|
---|
39 | this.matchedText = matchedText;
|
---|
40 | this.startIndex = start;
|
---|
41 | this.endIndex = end;
|
---|
42 | this.replacement = replacement;
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Returns the end index of the matched text.
|
---|
47 | *
|
---|
48 | * @return The end index of the matched text in the document searched.
|
---|
49 | * @see #getMatchedText()
|
---|
50 | * @see #getEndIndex()
|
---|
51 | */
|
---|
52 | public int getEndIndex() {
|
---|
53 | return endIndex;
|
---|
54 | }
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Returns the text that matched the regular expression.
|
---|
58 | *
|
---|
59 | * @return The matched text.
|
---|
60 | */
|
---|
61 | public String getMatchedText() {
|
---|
62 | return matchedText;
|
---|
63 | }
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Returns the string to replaced the matched text with.
|
---|
67 | *
|
---|
68 | * @return The string to replace the matched text with.
|
---|
69 | */
|
---|
70 | public String getReplacement() {
|
---|
71 | return replacement;
|
---|
72 | }
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Returns the start index of the matched text.
|
---|
76 | *
|
---|
77 | * @return The start index of the matched text in the document searched.
|
---|
78 | * @see #getMatchedText()
|
---|
79 | * @see #getEndIndex()
|
---|
80 | */
|
---|
81 | public int getStartIndex() {
|
---|
82 | return startIndex;
|
---|
83 | }
|
---|
84 |
|
---|
85 | } |
---|