diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-08-16 23:32:13 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-08-16 23:32:13 +0000 |
commit | 2da98ea13fedabecd2923cbb87f9bc4c1880610c (patch) | |
tree | bc1355d84c988a3c673d90a3c00ff7bd36fdc319 /java/util/regex/Matcher.java | |
parent | 83f5c80889cf782462a0101f940ed0095708ad22 (diff) | |
download | classpath-2da98ea13fedabecd2923cbb87f9bc4c1880610c.tar.gz |
Implement java.util.regex.Matcher#toMatchResult()
2008-08-17 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/util/regex/Matcher.java:
(toMatchResult()): Implemented.
Diffstat (limited to 'java/util/regex/Matcher.java')
-rw-r--r-- | java/util/regex/Matcher.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/java/util/regex/Matcher.java b/java/util/regex/Matcher.java index cc2a2e5e9..a6f34a63b 100644 --- a/java/util/regex/Matcher.java +++ b/java/util/regex/Matcher.java @@ -171,7 +171,7 @@ public final class Matcher implements MatchResult int endIndex = match.getEndIndex(); // Are we stuck at the same position? if (!first && endIndex == position) - { + { match = null; // Not at the end of the input yet? if (position < input.length() - 1) @@ -590,4 +590,20 @@ public final class Matcher implements MatchResult return this; } + /** + * Returns a read-only snapshot of the current state of + * the {@link Matcher} as a {@link MatchResult}. Any + * subsequent changes to this instance are not reflected + * in the returned {@link MatchResult}. + * + * @return a {@link MatchResult} instance representing the + * current state of the {@link Matcher}. + */ + public MatchResult toMatchResult() + { + Matcher snapshot = new Matcher(pattern, input); + snapshot.match = (REMatch) match.clone(); + return snapshot; + } + } |