summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <ahughes@redhat.com>2012-04-03 12:18:23 +0100
committerAndrew John Hughes <ahughes@redhat.com>2012-04-03 12:18:23 +0100
commit639a440219817e5bf9f92c5f1c9d34042ee9d6e1 (patch)
tree331af12a56a79a8cab8a4a45e05071010e357946
parentff4476344a8af63c973f99a388a8ef5a3e08f106 (diff)
downloadclasspath-639a440219817e5bf9f92c5f1c9d34042ee9d6e1.tar.gz
Implement Matcher.usePattern(Pattern).
2012-03-22 Andrew John Hughes <ahughes@redhat.com> * java/util/regex/Matcher.java: (usePattern(Pattern)): Implemented. Signed-off-by: Andrew John Hughes <ahughes@redhat.com>
-rw-r--r--ChangeLog5
-rw-r--r--java/util/regex/Matcher.java24
2 files changed, 28 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index c7533ff6a..171149052 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-03-22 Andrew John Hughes <ahughes@redhat.com>
+
+ * java/util/regex/Matcher.java:
+ (usePattern(Pattern)): Implemented.
+
2012-03-25 Gerald Pfeifer <gerald@pfeifer.com>
PR libgcj/52694
diff --git a/java/util/regex/Matcher.java b/java/util/regex/Matcher.java
index 8d033d5e3..95a355359 100644
--- a/java/util/regex/Matcher.java
+++ b/java/util/regex/Matcher.java
@@ -103,6 +103,28 @@ public final class Matcher implements MatchResult
}
/**
+ * Changes the pattern used by the {@link Matcher} to
+ * the one specified. Existing match information is lost,
+ * but the input and the matcher's position within it is
+ * retained.
+ *
+ * @param newPattern the new pattern to use.
+ * @return this matcher.
+ * @throws IllegalArgumentException if {@code newPattern} is
+ * {@code null}.
+ * @since 1.5
+ */
+ public Matcher usePattern(Pattern newPattern)
+ {
+ if (newPattern == null)
+ throw new IllegalArgumentException("The new pattern was null.");
+ pattern = newPattern;
+ match = null;
+
+ return this;
+ }
+
+ /**
* @param sb The target string buffer
* @param replacement The replacement string
*
@@ -620,7 +642,7 @@ public final class Matcher implements MatchResult
*
* @param s the string to literalize.
* @return the literalized string.
- * @since 1.5
+ * @since 1.5
*/
public static String quoteReplacement(String s)
{