From 9bc0101c1a708d39d25e568ed9f72bf2d4656968 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Thu, 25 Apr 2024 17:34:15 -0700 Subject: [PATCH] Remove support for JDK 1.3 (#31) --- pom.xml | 6 -- .../sf/json/regexp/Perl5RegexpMatcher.java | 64 ------------------- .../java/net/sf/json/regexp/RegexpUtils.java | 29 +-------- .../java/net/sf/json/regexp/AllTests.java | 1 - .../json/regexp/TestPerl5RegexpMatcher.java | 35 ---------- 5 files changed, 2 insertions(+), 133 deletions(-) delete mode 100644 src/main/java/net/sf/json/regexp/Perl5RegexpMatcher.java delete mode 100644 src/test/java/net/sf/json/regexp/TestPerl5RegexpMatcher.java diff --git a/pom.xml b/pom.xml index 6b9d969..c434ee4 100644 --- a/pom.xml +++ b/pom.xml @@ -195,12 +195,6 @@ 2.4.21 true - - oro - oro - 2.0.8 - true - xom xom diff --git a/src/main/java/net/sf/json/regexp/Perl5RegexpMatcher.java b/src/main/java/net/sf/json/regexp/Perl5RegexpMatcher.java deleted file mode 100644 index b08927b..0000000 --- a/src/main/java/net/sf/json/regexp/Perl5RegexpMatcher.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2002-2009 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.json.regexp; - -import org.apache.oro.text.regex.MalformedPatternException; -import org.apache.oro.text.regex.Pattern; -import org.apache.oro.text.regex.PatternMatcher; -import org.apache.oro.text.regex.Perl5Compiler; -import org.apache.oro.text.regex.Perl5Matcher; - -/** - * Jakarta-oro RegexpMatcher Implementation.
- * Runs on older JVMs (1.3.1). You must have oro-2.0.8.jar configured in your classpath. - * - * @author Andres Almiray aalmiray@users.sourceforge.net - */ -public class Perl5RegexpMatcher implements RegexpMatcher { - private static final Perl5Compiler compiler = new Perl5Compiler(); - private Pattern pattern; - - public Perl5RegexpMatcher(String pattern) { - this(pattern, false); - } - - public Perl5RegexpMatcher(String pattern, boolean multiline) { - try { - if (multiline) { - this.pattern = compiler.compile(pattern, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.MULTILINE_MASK); - } else { - this.pattern = compiler.compile(pattern, Perl5Compiler.READ_ONLY_MASK); - } - } catch (MalformedPatternException mpe) { - throw new RuntimeException(mpe); - } - } - - @Override - public String getGroupIfMatches(String str, int group) { - PatternMatcher matcher = new Perl5Matcher(); - if (matcher.matches(str, pattern)) { - return matcher.getMatch().group(1); - } - return ""; - } - - @Override - public boolean matches(String str) { - return new Perl5Matcher().matches(str, pattern); - } -} diff --git a/src/main/java/net/sf/json/regexp/RegexpUtils.java b/src/main/java/net/sf/json/regexp/RegexpUtils.java index 31faa52..3c2f4f4 100644 --- a/src/main/java/net/sf/json/regexp/RegexpUtils.java +++ b/src/main/java/net/sf/json/regexp/RegexpUtils.java @@ -22,43 +22,18 @@ * @author Andres Almiray aalmiray@users.sourceforge.net */ public class RegexpUtils { - private static String javaVersion = "1.3.1"; - - static { - javaVersion = System.getProperty("java.version"); - } - /** * Returns a RegexpMatcher that works in a specific environment.
- * When in a JVM 1.3.1 it will return a Perl5RegexpMatcher, if the JVM is - * younger (1.4+) it will return a JdkRegexpMatcher. */ public static RegexpMatcher getMatcher(String pattern) { - if (isJDK13()) { - return new Perl5RegexpMatcher(pattern); - } else { - return new JdkRegexpMatcher(pattern); - } + return new JdkRegexpMatcher(pattern); } /** * Returns a RegexpMatcher that works in a specific environment.
- * When in a JVM 1.3.1 it will return a Perl5RegexpMatcher, if the JVM is - * younger (1.4+) it will return a JdkRegexpMatcher. */ public static RegexpMatcher getMatcher(String pattern, boolean multiline) { - if (isJDK13()) { - return new Perl5RegexpMatcher(pattern, true); - } else { - return new JdkRegexpMatcher(pattern, true); - } - } - - /** - * Queries the environment for the supported JDK version. - */ - public static boolean isJDK13() { - return javaVersion.indexOf("1.3") != -1; + return new JdkRegexpMatcher(pattern, multiline); } private RegexpUtils() {} diff --git a/src/test/java/net/sf/json/regexp/AllTests.java b/src/test/java/net/sf/json/regexp/AllTests.java index 57540a8..c80639e 100644 --- a/src/test/java/net/sf/json/regexp/AllTests.java +++ b/src/test/java/net/sf/json/regexp/AllTests.java @@ -27,7 +27,6 @@ public static TestSuite suite() throws Exception { suite.setName("regexp"); suite.addTest(new TestSuite(TestJdkRegexpMatcher.class)); - suite.addTest(new TestSuite(TestPerl5RegexpMatcher.class)); return suite; } diff --git a/src/test/java/net/sf/json/regexp/TestPerl5RegexpMatcher.java b/src/test/java/net/sf/json/regexp/TestPerl5RegexpMatcher.java deleted file mode 100644 index eeacb2a..0000000 --- a/src/test/java/net/sf/json/regexp/TestPerl5RegexpMatcher.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2002-2009 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.sf.json.regexp; - -/** - * @author Andres Almiray aalmiray@users.sourceforge.net - */ -public class TestPerl5RegexpMatcher extends AbstractRegexpMatcherTestCase { - public static void main(String[] args) { - junit.textui.TestRunner.run(TestPerl5RegexpMatcher.class); - } - - public TestPerl5RegexpMatcher(String name) { - super(name); - } - - @Override - protected RegexpMatcher getRegexpMatcher(String pattern) { - return new Perl5RegexpMatcher(pattern); - } -}