summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java/java/util/regex/Matcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/main/java/java/util/regex/Matcher.java')
-rw-r--r--luni/src/main/java/java/util/regex/Matcher.java40
1 files changed, 6 insertions, 34 deletions
diff --git a/luni/src/main/java/java/util/regex/Matcher.java b/luni/src/main/java/java/util/regex/Matcher.java
index 58bcf9e..cfd4432 100644
--- a/luni/src/main/java/java/util/regex/Matcher.java
+++ b/luni/src/main/java/java/util/regex/Matcher.java
@@ -50,11 +50,6 @@ public final class Matcher implements MatchResult {
private int regionEnd;
/**
- * Holds the position where the next find operation will take place.
- */
- private int findPos;
-
- /**
* Holds the position where the next append operation will take place.
*/
private int appendPos;
@@ -212,7 +207,6 @@ public final class Matcher implements MatchResult {
resetForInput();
matchFound = false;
- findPos = regionStart;
appendPos = 0;
return this;
@@ -377,30 +371,17 @@ public final class Matcher implements MatchResult {
}
/**
- * Returns the next occurrence of the {@link Pattern} in the input. The
- * method starts the search from the given character in the input.
+ * Returns true if there is another match in the input, starting
+ * from the given position. The region is ignored.
*
- * @param start
- * The index in the input at which the find operation is to
- * begin. If this is less than the start of the region, it is
- * automatically adjusted to that value. If it is beyond the end
- * of the region, the method will fail.
- * @return true if (and only if) a match has been found.
+ * @throws IndexOutOfBoundsException if {@code start < 0 || start > input.length()}
*/
public boolean find(int start) {
- findPos = start;
-
- if (findPos < regionStart) {
- findPos = regionStart;
- } else if (findPos >= regionEnd) {
- matchFound = false;
- return false;
+ if (start < 0 || start > input.length()) {
+ throw new IndexOutOfBoundsException("start=" + start + "; length=" + input.length());
}
- matchFound = findImpl(address, input, findPos, matchOffsets);
- if (matchFound) {
- findPos = matchOffsets[1];
- }
+ matchFound = findImpl(address, input, start, matchOffsets);
return matchFound;
}
@@ -414,9 +395,6 @@ public final class Matcher implements MatchResult {
*/
public boolean find() {
matchFound = findNextImpl(address, input, matchOffsets);
- if (matchFound) {
- findPos = matchOffsets[1];
- }
return matchFound;
}
@@ -429,9 +407,6 @@ public final class Matcher implements MatchResult {
*/
public boolean lookingAt() {
matchFound = lookingAtImpl(address, input, matchOffsets);
- if (matchFound) {
- findPos = matchOffsets[1];
- }
return matchFound;
}
@@ -444,9 +419,6 @@ public final class Matcher implements MatchResult {
*/
public boolean matches() {
matchFound = matchesImpl(address, input, matchOffsets);
- if (matchFound) {
- findPos = matchOffsets[1];
- }
return matchFound;
}