This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-text.git
The following commit(s) were added to refs/heads/master by this push: new c5145b7 Update Apache Commons Lang from 3.10 to 3.11. c5145b7 is described below commit c5145b71c443e1445a162e324168c082ee1bf045 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu Jul 16 11:29:18 2020 -0400 Update Apache Commons Lang from 3.10 to 3.11. Deprecate delegating APIs to StringUtils in favor of underlying APIs in org.apache.commons.text.lookup.AbstractStringLookup: - substringAfter(String, char) - substringAfter(String, String) - substringAfterLast(String, char) --- pom.xml | 2 +- src/changes/changes.xml | 4 ++-- .../commons/text/lookup/AbstractStringLookup.java | 19 +++++++--------- .../commons/text/lookup/FileStringLookup.java | 3 ++- .../text/lookup/PropertiesStringLookup.java | 4 +++- .../commons/text/lookup/UrlStringLookup.java | 4 +++- .../commons/text/lookup/XmlStringLookup.java | 3 ++- .../text/matcher/AbstractStringMatcher.java | 26 ---------------------- .../apache/commons/text/matcher/StringMatcher.java | 4 +++- 9 files changed, 24 insertions(+), 45 deletions(-) diff --git a/pom.xml b/pom.xml index 68e2bb9..28904c9 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> - <version>3.10</version> + <version>3.11</version> </dependency> <!-- testing --> <dependency> diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 17f3a74..b845d30 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -45,13 +45,13 @@ The <action> type attribute can be add,update,fix,remove. </properties> <body> - <release version="1.9" date="2019-MM-DD" description="Release 1.8.1"> + <release version="1.9" date="2020-MM-DD" description="Release 1.9"> <action issue="TEXT-166" type="fix" dev="kinow" due-to="Mikko Maunu">Removed non-existing parameter from Javadocs and spelled out parameters in throws.</action> <action issue="TEXT-149" type="fix" dev="kinow" due-to="Yuji Konishi">StringEscapeUtils.unescapeCsv doesn't remove quotes at begin and end of string.</action> <action issue="TEXT-174" type="fix" dev="ggregory" due-to="furkilic">ScriptStringLookup does not accept ":" #126.</action> <action issue="TEXT-178" type="fix" dev="ggregory" due-to="Gary Gregory">StringSubstitutor incorrectly removes some escape characters.</action> <action type="update" dev="ggregory" due-to="Johan Hammar">[javadoc] Fix compiler warnings in Java code example in Javadoc #124.</action> - <action issue="TEXT-177" type="update" dev="ggregory" due-to="Gary Gregory">Update from Apache Commons Lang 3.9 to 3.10.</action> + <action issue="TEXT-177" type="update" dev="ggregory" due-to="Gary Gregory">Update from Apache Commons Lang 3.9 to 3.11.</action> <action type="add" dev="ggregory" due-to="Gary Gregory">Add StringMatcher.size().</action> <action type="add" dev="ggregory" due-to="Gary Gregory">Refactor TextStringBuilder.readFrom(Readable), extracting readFrom(CharBuffer) and readFrom(Reader).</action> <action type="add" dev="ggregory" due-to="Gary Gregory">Add BiStringLookup and implementation BiFunctionStringLookup.</action> diff --git a/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java b/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java index 0e484b3..35a8107 100644 --- a/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/AbstractStringLookup.java @@ -27,11 +27,6 @@ import org.apache.commons.lang3.StringUtils; abstract class AbstractStringLookup implements StringLookup { /** - * The empty string. - */ - private static final String EMPTY = StringUtils.EMPTY; - - /** * The default split char. */ protected static final char SPLIT_CH = ':'; @@ -47,11 +42,11 @@ abstract class AbstractStringLookup implements StringLookup { * @param value The source string. * @param ch The character to search. * @return a new string. + * @deprecated Use {@link StringUtils#substringAfter(String, int)}. */ + @Deprecated protected String substringAfter(final String value, final char ch) { - // TODO Reuse Commons Lang 3.11 StringUtils.substringAfter(String, int) - final int indexOf = value.indexOf(ch); - return indexOf > -1 ? value.substring(indexOf + 1) : EMPTY; + return StringUtils.substringAfter(value, ch); } /** @@ -60,11 +55,11 @@ abstract class AbstractStringLookup implements StringLookup { * @param value The source string. * @param ch The character to search. * @return a new string. + * @deprecated Use {@link StringUtils#substringAfterLast(String, int)}. */ + @Deprecated protected String substringAfterLast(final String value, final char ch) { - // TODO Reuse Commons Lang 3.11 StringUtils.substringAfterLast(String, int) - final int indexOf = value.lastIndexOf(ch); - return indexOf > -1 ? value.substring(indexOf + 1) : EMPTY; + return StringUtils.substringAfterLast(value, ch); } /** @@ -73,7 +68,9 @@ abstract class AbstractStringLookup implements StringLookup { * @param value The source string. * @param str The string to search. * @return a new string. + * @deprecated Use {@link StringUtils#substringAfter(String, String)}. */ + @Deprecated protected String substringAfter(final String value, final String str) { return StringUtils.substringAfter(value, str); } diff --git a/src/main/java/org/apache/commons/text/lookup/FileStringLookup.java b/src/main/java/org/apache/commons/text/lookup/FileStringLookup.java index 3162832..a04b6d5 100644 --- a/src/main/java/org/apache/commons/text/lookup/FileStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/FileStringLookup.java @@ -20,6 +20,7 @@ package org.apache.commons.text.lookup; import java.nio.file.Files; import java.nio.file.Paths; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringSubstitutor; /** @@ -79,7 +80,7 @@ final class FileStringLookup extends AbstractStringLookup { .format("Bad file key format [%s], expected format is CharsetName:DocumentPath.", key); } final String charsetName = keys[0]; - final String fileName = substringAfter(key, SPLIT_CH); + final String fileName = StringUtils.substringAfter(key, SPLIT_CH); try { return new String(Files.readAllBytes(Paths.get(fileName)), charsetName); } catch (final Exception e) { diff --git a/src/main/java/org/apache/commons/text/lookup/PropertiesStringLookup.java b/src/main/java/org/apache/commons/text/lookup/PropertiesStringLookup.java index cb6f345..e5ed3a1 100644 --- a/src/main/java/org/apache/commons/text/lookup/PropertiesStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/PropertiesStringLookup.java @@ -22,6 +22,8 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.Properties; +import org.apache.commons.lang3.StringUtils; + /** * Looks up keys from an XML document. * <p> @@ -75,7 +77,7 @@ final class PropertiesStringLookup extends AbstractStringLookup { .format("Bad properties key format [%s]; expected format is DocumentPath::Key.", key); } final String documentPath = keys[0]; - final String propertyKey = substringAfter(key, "::"); + final String propertyKey = StringUtils.substringAfter(key, "::"); try { final Properties properties = new Properties(); try (InputStream inputStream = Files.newInputStream(Paths.get(documentPath))) { diff --git a/src/main/java/org/apache/commons/text/lookup/UrlStringLookup.java b/src/main/java/org/apache/commons/text/lookup/UrlStringLookup.java index 1d0fb4d..4daaa58 100644 --- a/src/main/java/org/apache/commons/text/lookup/UrlStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/UrlStringLookup.java @@ -22,6 +22,8 @@ import java.io.InputStreamReader; import java.io.StringWriter; import java.net.URL; +import org.apache.commons.lang3.StringUtils; + /** * Looks up keys from an XML document. * <p> @@ -69,7 +71,7 @@ final class UrlStringLookup extends AbstractStringLookup { key); } final String charsetName = keys[0]; - final String urlStr = substringAfter(key, SPLIT_CH); + final String urlStr = StringUtils.substringAfter(key, SPLIT_CH); try { final URL url = new URL(urlStr); final int size = 8192; diff --git a/src/main/java/org/apache/commons/text/lookup/XmlStringLookup.java b/src/main/java/org/apache/commons/text/lookup/XmlStringLookup.java index de9ae75..12aa5e5 100644 --- a/src/main/java/org/apache/commons/text/lookup/XmlStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/XmlStringLookup.java @@ -23,6 +23,7 @@ import java.nio.file.Paths; import javax.xml.xpath.XPathFactory; +import org.apache.commons.lang3.StringUtils; import org.xml.sax.InputSource; /** @@ -71,7 +72,7 @@ final class XmlStringLookup extends AbstractStringLookup { key); } final String documentPath = keys[0]; - final String xpath = substringAfter(key, SPLIT_CH); + final String xpath = StringUtils.substringAfter(key, SPLIT_CH); try (InputStream inputStream = Files.newInputStream(Paths.get(documentPath))) { return XPathFactory.newInstance().newXPath().evaluate(xpath, new InputSource(inputStream)); } catch (final Exception e) { diff --git a/src/main/java/org/apache/commons/text/matcher/AbstractStringMatcher.java b/src/main/java/org/apache/commons/text/matcher/AbstractStringMatcher.java index 6463df4..643531f 100644 --- a/src/main/java/org/apache/commons/text/matcher/AbstractStringMatcher.java +++ b/src/main/java/org/apache/commons/text/matcher/AbstractStringMatcher.java @@ -19,9 +19,6 @@ package org.apache.commons.text.matcher; import java.util.Arrays; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; - /** * A matcher that determines if a character array portion matches. * <p> @@ -442,29 +439,6 @@ abstract class AbstractStringMatcher implements StringMatcher { } /** - * Converts the given CharSequence to a char[]. - * - * TODO Reuse Apache Commons Lang 3.11 when released. - * - * @param source the {@code CharSequence} to be processed - * @return the resulting char array, never null. - */ - static char[] toCharArray(final CharSequence source) { - final int len = StringUtils.length(source); - if (len == 0) { - return ArrayUtils.EMPTY_CHAR_ARRAY; - } - if (source instanceof String) { - return ((String) source).toCharArray(); - } - final char[] array = new char[len]; - for (int i = 0; i < len; i++) { - array[i] = source.charAt(i); - } - return array; - } - - /** * Constructor. */ protected AbstractStringMatcher() { diff --git a/src/main/java/org/apache/commons/text/matcher/StringMatcher.java b/src/main/java/org/apache/commons/text/matcher/StringMatcher.java index d67fbc6..7b82d60 100644 --- a/src/main/java/org/apache/commons/text/matcher/StringMatcher.java +++ b/src/main/java/org/apache/commons/text/matcher/StringMatcher.java @@ -17,6 +17,8 @@ package org.apache.commons.text.matcher; +import org.apache.commons.lang3.CharSequenceUtils; + /** * Determines if a character array portion matches. * @@ -141,7 +143,7 @@ public interface StringMatcher { * @since 1.9 */ default int isMatch(final CharSequence buffer, final int start, final int bufferStart, final int bufferEnd) { - return isMatch(AbstractStringMatcher.toCharArray(buffer), start, bufferEnd, bufferEnd); + return isMatch(CharSequenceUtils.toCharArray(buffer), start, bufferEnd, bufferEnd); } /**