diff --git a/contrib/src/java/org/jdom/contrib/beans/DateUtils.java b/contrib/src/java/org/jdom/contrib/beans/DateUtils.java index 49f26c4..7d8e590 100644 --- a/contrib/src/java/org/jdom/contrib/beans/DateUtils.java +++ b/contrib/src/java/org/jdom/contrib/beans/DateUtils.java @@ -59,7 +59,7 @@ package org.jdom.contrib.beans; import java.util.*; -import org.apache.regexp.*; +import java.util.regex.*; import java.text.*; import java.io.PrintStream; @@ -165,20 +165,20 @@ public class DateUtils { // e.g. 1997-07-16T19:20:30.45+01:00 // additions: "T" can be a space, TZ can be a three-char code, TZ can be missing try { - RE re = new RE(reISO8601); - if (re.match(s)) { + Matcher re = Pattern.compile(reISO8601).matcher(s); + if (re.find()) { if (debug) showParens(re); ISO8601 iso = new ISO8601(); - iso.year = toInt(re.getParen(1)); - iso.month = toInt(re.getParen(3)); - iso.day = toInt(re.getParen(5)); - iso.hour = toInt(re.getParen(7)); - iso.min = toInt(re.getParen(8)); - iso.sec = toInt(re.getParen(11)); - iso.frac = toInt(re.getParen(13)); - iso.tz = re.getParen(14); + iso.year = toInt(re.group(1)); + iso.month = toInt(re.group(3)); + iso.day = toInt(re.group(5)); + iso.hour = toInt(re.group(7)); + iso.min = toInt(re.group(8)); + iso.sec = toInt(re.group(11)); + iso.frac = toInt(re.group(13)); + iso.tz = re.group(14); if (debug) { System.out.println("year='" + iso.year + "'"); @@ -194,7 +194,7 @@ public class DateUtils { return iso; } } // try - catch (RESyntaxException ree) { + catch (PatternSyntaxException ree) { ree.printStackTrace(); } return null; @@ -214,13 +214,13 @@ public class DateUtils { * Dump parenthesized subexpressions found by a regular expression matcher object * @param r Matcher object with results to show */ - static void showParens(RE r) + static void showParens(Matcher r) { // Loop through each paren - for (int i = 0; i < r.getParenCount(); i++) + for (int i = 0; i < r.groupCount(); i++) { // Show paren register - System.out.println("$" + i + " = " + r.getParen(i)); + System.out.println("$" + i + " = " + r.group(i)); } } diff --git a/contrib/src/java/org/jdom/contrib/input/scanner/JakartaRegExpXPathMatcher.java b/contrib/src/java/org/jdom/contrib/input/scanner/JakartaRegExpXPathMatcher.java index b7a4d5a..d0851d3 100644 --- a/contrib/src/java/org/jdom/contrib/input/scanner/JakartaRegExpXPathMatcher.java +++ b/contrib/src/java/org/jdom/contrib/input/scanner/JakartaRegExpXPathMatcher.java @@ -63,8 +63,7 @@ import org.jdom.xpath.XPath; import org.xml.sax.Attributes; -import org.apache.regexp.RE; -import org.apache.regexp.RESyntaxException; +import java.util.regex.*; /* package */ class JakartaRegExpXPathMatcher extends XPathMatcher { @@ -72,7 +71,7 @@ import org.apache.regexp.RESyntaxException; /** * The compiled regular expression this matcher matches. */ - private final RE re; + private final Pattern re; private final XPath test; @@ -94,7 +93,7 @@ import org.apache.regexp.RESyntaxException; try { String pathPattern = getPathPatternAsRE(expression); - this.re = new RE(pathPattern); + this.re = Pattern.compile(pathPattern); String testPattern = getTestPattern(expression); if (testPattern != null) { @@ -114,7 +113,7 @@ import org.apache.regexp.RESyntaxException; " -> XPath = " + testPattern); } } - catch (RESyntaxException ex1) { + catch (PatternSyntaxException ex1) { throw (new JDOMException( "Illegal XPath expression: " + expression, ex1)); } @@ -137,7 +136,7 @@ import org.apache.regexp.RESyntaxException; * expression, false otherwise. */ public boolean match(String path, Attributes attrs) { - return (this.re.match(path)); + return (this.re.matcher(path).find()); } /**