summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2008-08-16 23:32:13 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2008-08-16 23:32:13 +0000
commit2da98ea13fedabecd2923cbb87f9bc4c1880610c (patch)
treebc1355d84c988a3c673d90a3c00ff7bd36fdc319
parent83f5c80889cf782462a0101f940ed0095708ad22 (diff)
downloadclasspath-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.
-rw-r--r--ChangeLog5
-rw-r--r--java/util/regex/Matcher.java18
2 files changed, 22 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 2daa099fe..81a3053ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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;
+ }
+
}