This adds an implementation of toMatchResult()
to java.util.regex.Matcher.

ChangeLog:

2008-08-17  Andrew John Hughes  <[EMAIL PROTECTED]>

        * java/util/regex/Matcher.java:
        (toMatchResult()): Implemented.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
Index: java/util/regex/Matcher.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/regex/Matcher.java,v
retrieving revision 1.21
diff -u -u -r1.21 Matcher.java
--- java/util/regex/Matcher.java        12 May 2008 20:43:55 -0000      1.21
+++ java/util/regex/Matcher.java        16 Aug 2008 23:06:30 -0000
@@ -171,7 +171,7 @@
        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 @@
     return this;
   }
 
+  /**
+   * Returns a read-only snapshot of the current state of
+   * the [EMAIL PROTECTED] Matcher} as a [EMAIL PROTECTED] MatchResult}.  Any
+   * subsequent changes to this instance are not reflected
+   * in the returned [EMAIL PROTECTED] MatchResult}.
+   *
+   * @return a [EMAIL PROTECTED] MatchResult} instance representing the
+   *         current state of the [EMAIL PROTECTED] Matcher}.
+   */
+  public MatchResult toMatchResult()
+  {
+    Matcher snapshot = new Matcher(pattern, input);
+    snapshot.match = (REMatch) match.clone();
+    return snapshot;
+  }
+
 }

Reply via email to