diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | java/util/regex/Matcher.java | 18 |
2 files changed, 22 insertions, 1 deletions
@@ -1,3 +1,8 @@ +2008-08-17 Andrew John Hughes <gnu_andrew@member.fsf.org> + + * java/util/regex/Matcher.java: + (toMatchResult()): Implemented. + 2008-08-13 Joshua Sumali <jsumali@redhat.com> * doc/Makefile.am (gjdoc.pod): Generate gjdoc pod from cp-tools.texinfo 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; + } + } |