You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/07/01 12:41:17 UTC
[commons-text] branch master updated (dc640d1 -> c23a930)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git.
from dc640d1 More tests.
new 64731e5 Sort members.
new f6d449e Organise imports.
new 8ecb6f6 Organise imports.
new f347208 Sort members.
new c23a930 Sort members.
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/commons/text/AlphabetConverter.java | 5 +--
.../java/org/apache/commons/text/CaseUtils.java | 6 +--
.../org/apache/commons/text/FormattableUtils.java | 4 +-
.../apache/commons/text/RandomStringGenerator.java | 8 ++--
.../org/apache/commons/text/StringEscapeUtils.java | 12 +++---
.../org/apache/commons/text/TextStringBuilder.java | 22 +++++-----
.../java/org/apache/commons/text/WordUtils.java | 8 ++--
.../text/matcher/AbstractStringMatcher.java | 12 +++---
.../apache/commons/text/matcher/StringMatcher.java | 50 +++++++++++-----------
.../text/similarity/JaroWinklerSimilarity.java | 4 +-
.../text/lookup/BiFunctionStringLookupTest.java | 38 ++++++++--------
.../text/matcher/StringMatcherOnCharArrayTest.java | 22 +++++-----
12 files changed, 95 insertions(+), 96 deletions(-)
[commons-text] 02/05: Organise imports.
Posted by gg...@apache.org.
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
commit f6d449e70d8901a3dfa32bf9bc1e6e95ea559292
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jul 1 08:36:12 2020 -0400
Organise imports.
---
.../org/apache/commons/text/similarity/JaroWinklerSimilarity.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/commons/text/similarity/JaroWinklerSimilarity.java b/src/main/java/org/apache/commons/text/similarity/JaroWinklerSimilarity.java
index 058d369..fa7d754 100644
--- a/src/main/java/org/apache/commons/text/similarity/JaroWinklerSimilarity.java
+++ b/src/main/java/org/apache/commons/text/similarity/JaroWinklerSimilarity.java
@@ -16,10 +16,10 @@
*/
package org.apache.commons.text.similarity;
-import org.apache.commons.lang3.StringUtils;
-
import java.util.Arrays;
+import org.apache.commons.lang3.StringUtils;
+
/**
* A similarity algorithm indicating the percentage of matched characters between two character sequences.
*
[commons-text] 03/05: Organise imports.
Posted by gg...@apache.org.
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
commit 8ecb6f6c10b1b9559e95876ee18a880fa2c80cdb
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jul 1 08:37:32 2020 -0400
Organise imports.
---
src/main/java/org/apache/commons/text/AlphabetConverter.java | 5 ++---
src/main/java/org/apache/commons/text/CaseUtils.java | 6 +++---
src/main/java/org/apache/commons/text/FormattableUtils.java | 4 ++--
.../java/org/apache/commons/text/RandomStringGenerator.java | 8 ++++----
src/main/java/org/apache/commons/text/StringEscapeUtils.java | 12 ++++++------
src/main/java/org/apache/commons/text/WordUtils.java | 8 ++++----
6 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/src/main/java/org/apache/commons/text/AlphabetConverter.java b/src/main/java/org/apache/commons/text/AlphabetConverter.java
index 78e4f06..0cc5e21 100644
--- a/src/main/java/org/apache/commons/text/AlphabetConverter.java
+++ b/src/main/java/org/apache/commons/text/AlphabetConverter.java
@@ -26,12 +26,11 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Map.Entry;
-
-import org.apache.commons.lang3.ArrayUtils;
-
import java.util.Objects;
import java.util.Set;
+import org.apache.commons.lang3.ArrayUtils;
+
/**
* <p>
* Convert from one alphabet to another, with the possibility of leaving certain
diff --git a/src/main/java/org/apache/commons/text/CaseUtils.java b/src/main/java/org/apache/commons/text/CaseUtils.java
index ba360b3..641f64c 100644
--- a/src/main/java/org/apache/commons/text/CaseUtils.java
+++ b/src/main/java/org/apache/commons/text/CaseUtils.java
@@ -16,12 +16,12 @@
*/
package org.apache.commons.text;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-
import java.util.HashSet;
import java.util.Set;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+
/**
* <p>Case manipulation operations on Strings that contain words.</p>
*
diff --git a/src/main/java/org/apache/commons/text/FormattableUtils.java b/src/main/java/org/apache/commons/text/FormattableUtils.java
index 242a82a..aed0eb7 100644
--- a/src/main/java/org/apache/commons/text/FormattableUtils.java
+++ b/src/main/java/org/apache/commons/text/FormattableUtils.java
@@ -16,11 +16,11 @@
*/
package org.apache.commons.text;
+import static java.util.FormattableFlags.LEFT_JUSTIFY;
+
import java.util.Formattable;
import java.util.Formatter;
-import static java.util.FormattableFlags.LEFT_JUSTIFY;
-
/**
* <p>Provides utilities for working with the {@code Formattable} interface.</p>
*
diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
index f1a9b4f..a66f71b 100644
--- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
+++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
@@ -16,16 +16,16 @@
*/
package org.apache.commons.text;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.Validate;
-
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.Collections;
import java.util.concurrent.ThreadLocalRandom;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.Validate;
+
/**
* <p>
* Generates random Unicode strings containing the specified number of code points.
diff --git a/src/main/java/org/apache/commons/text/StringEscapeUtils.java b/src/main/java/org/apache/commons/text/StringEscapeUtils.java
index 93f76d2..2c0494a 100644
--- a/src/main/java/org/apache/commons/text/StringEscapeUtils.java
+++ b/src/main/java/org/apache/commons/text/StringEscapeUtils.java
@@ -16,6 +16,12 @@
*/
package org.apache.commons.text;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.translate.AggregateTranslator;
import org.apache.commons.text.translate.CharSequenceTranslator;
@@ -29,12 +35,6 @@ import org.apache.commons.text.translate.OctalUnescaper;
import org.apache.commons.text.translate.UnicodeUnescaper;
import org.apache.commons.text.translate.UnicodeUnpairedSurrogateRemover;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* <p>Escapes and unescapes {@code String}s for
* Java, Java Script, HTML and XML.</p>
diff --git a/src/main/java/org/apache/commons/text/WordUtils.java b/src/main/java/org/apache/commons/text/WordUtils.java
index 24f8f5b..6f6f1d2 100644
--- a/src/main/java/org/apache/commons/text/WordUtils.java
+++ b/src/main/java/org/apache/commons/text/WordUtils.java
@@ -16,15 +16,15 @@
*/
package org.apache.commons.text;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Validate;
-
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.Validate;
+
/**
* <p>
* Operations on Strings that contain words.
[commons-text] 01/05: Sort members.
Posted by gg...@apache.org.
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
commit 64731e5080b93909bcac2d0176ff1205e07494f0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jul 1 08:25:14 2020 -0400
Sort members.
---
.../org/apache/commons/text/TextStringBuilder.java | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/main/java/org/apache/commons/text/TextStringBuilder.java b/src/main/java/org/apache/commons/text/TextStringBuilder.java
index 3999b74..50674cb 100644
--- a/src/main/java/org/apache/commons/text/TextStringBuilder.java
+++ b/src/main/java/org/apache/commons/text/TextStringBuilder.java
@@ -295,17 +295,6 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
}
/**
- * Constructs an instance with the specified initial capacity.
- *
- * @param initialCapacity
- * the initial capacity, zero or less will be converted to 32
- */
- public TextStringBuilder(final int initialCapacity) {
- super();
- buffer = new char[initialCapacity <= 0 ? CAPACITY : initialCapacity];
- }
-
- /**
* Constructs an instance from a character sequence, allocating 32 extra characters for growth.
*
* @param seq the string to copy, null treated as blank string
@@ -319,6 +308,17 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
}
/**
+ * Constructs an instance with the specified initial capacity.
+ *
+ * @param initialCapacity
+ * the initial capacity, zero or less will be converted to 32
+ */
+ public TextStringBuilder(final int initialCapacity) {
+ super();
+ buffer = new char[initialCapacity <= 0 ? CAPACITY : initialCapacity];
+ }
+
+ /**
* Constructs an instance from a string, allocating 32 extra characters for growth.
*
* @param str
[commons-text] 05/05: Sort members.
Posted by gg...@apache.org.
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
commit c23a930f434471f74cd55455097c19f49e2006fb
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jul 1 08:40:11 2020 -0400
Sort members.
---
.../text/matcher/StringMatcherOnCharArrayTest.java | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/test/java/org/apache/commons/text/matcher/StringMatcherOnCharArrayTest.java b/src/test/java/org/apache/commons/text/matcher/StringMatcherOnCharArrayTest.java
index ad22693..71a6f37 100644
--- a/src/test/java/org/apache/commons/text/matcher/StringMatcherOnCharArrayTest.java
+++ b/src/test/java/org/apache/commons/text/matcher/StringMatcherOnCharArrayTest.java
@@ -253,17 +253,6 @@ public class StringMatcherOnCharArrayTest {
assertThat(matcher.isMatch(BUFFER1, 10)).isEqualTo(0);
}
- @Test
- public void testStringMatcher_String_fromChars() {
- testStringMatcher_String(StringMatcherFactory.INSTANCE.stringMatcher('b', 'c'));
- testStringMatcher_String(StringMatcherFactory.INSTANCE.stringMatcher(new char[] {'b', 'c'}));
- }
-
- @Test
- public void testStringMatcher_String_fromString() {
- testStringMatcher_String(StringMatcherFactory.INSTANCE.stringMatcher("bc"));
- }
-
private void testStringMatcher_String(final StringMatcher matcher) {
assertEquals(2, matcher.size());
//
@@ -287,6 +276,17 @@ public class StringMatcherOnCharArrayTest {
.isSameAs(StringMatcherFactory.INSTANCE.noneMatcher());
}
+ @Test
+ public void testStringMatcher_String_fromChars() {
+ testStringMatcher_String(StringMatcherFactory.INSTANCE.stringMatcher('b', 'c'));
+ testStringMatcher_String(StringMatcherFactory.INSTANCE.stringMatcher(new char[] {'b', 'c'}));
+ }
+
+ @Test
+ public void testStringMatcher_String_fromString() {
+ testStringMatcher_String(StringMatcherFactory.INSTANCE.stringMatcher("bc"));
+ }
+
// -----------------------------------------------------------------------
@Test
public void testTabMatcher() {
[commons-text] 04/05: Sort members.
Posted by gg...@apache.org.
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
commit f347208359dd9f0a9141e5e3e2f0f2cfea384104
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jul 1 08:39:15 2020 -0400
Sort members.
---
.../text/matcher/AbstractStringMatcher.java | 12 +++---
.../apache/commons/text/matcher/StringMatcher.java | 50 +++++++++++-----------
.../text/lookup/BiFunctionStringLookupTest.java | 38 ++++++++--------
3 files changed, 50 insertions(+), 50 deletions(-)
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 e7cf3c4..357ad29 100644
--- a/src/main/java/org/apache/commons/text/matcher/AbstractStringMatcher.java
+++ b/src/main/java/org/apache/commons/text/matcher/AbstractStringMatcher.java
@@ -212,10 +212,10 @@ abstract class AbstractStringMatcher implements StringMatcher {
*
* @param str the string to match, must not be null
*/
- StringMatcher(final String string) {
+ StringMatcher(final char... chars) {
super();
- this.string = string;
- this.chars = string.toCharArray();
+ this.string = String.valueOf(chars);
+ this.chars = chars.clone();
}
/**
@@ -223,10 +223,10 @@ abstract class AbstractStringMatcher implements StringMatcher {
*
* @param str the string to match, must not be null
*/
- StringMatcher(final char... chars) {
+ StringMatcher(final String string) {
super();
- this.string = String.valueOf(chars);
- this.chars = chars.clone();
+ this.string = string;
+ this.chars = string.toCharArray();
}
/**
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 8fa26f1..61b7055 100644
--- a/src/main/java/org/apache/commons/text/matcher/StringMatcher.java
+++ b/src/main/java/org/apache/commons/text/matcher/StringMatcher.java
@@ -50,31 +50,6 @@ public interface StringMatcher {
}
/**
- * Returns the number of matching characters, zero for no match.
- * <p>
- * This method is called to check for a match. The parameter {@code pos} represents the current position to be
- * checked in the string {@code buffer} (a character array which must not be changed). The API guarantees that
- * {@code pos} is a valid index for {@code buffer}.
- * </p>
- * <p>
- * The matching code may check one character or many. It may check characters preceding {@code pos} as well as those
- * after.
- * </p>
- * <p>
- * It must return zero for no match, or a positive number if a match was found. The number indicates the number of
- * characters that matched.
- * </p>
- *
- * @param buffer the text content to match against, do not change
- * @param pos the starting position for the match, valid for buffer
- * @return The number of matching characters, zero for no match
- * @since 1.9
- */
- default int isMatch(final CharSequence buffer, final int pos) {
- return isMatch(buffer, pos, 0, buffer.length());
- }
-
- /**
* Returns the number of matching characters, {@code 0} if there is no match.
* <p>
* This method is called to check for a match against a source {@code buffer}. The parameter {@code start}
@@ -103,6 +78,31 @@ public interface StringMatcher {
int isMatch(char[] buffer, int start, int bufferStart, int bufferEnd);
/**
+ * Returns the number of matching characters, zero for no match.
+ * <p>
+ * This method is called to check for a match. The parameter {@code pos} represents the current position to be
+ * checked in the string {@code buffer} (a character array which must not be changed). The API guarantees that
+ * {@code pos} is a valid index for {@code buffer}.
+ * </p>
+ * <p>
+ * The matching code may check one character or many. It may check characters preceding {@code pos} as well as those
+ * after.
+ * </p>
+ * <p>
+ * It must return zero for no match, or a positive number if a match was found. The number indicates the number of
+ * characters that matched.
+ * </p>
+ *
+ * @param buffer the text content to match against, do not change
+ * @param pos the starting position for the match, valid for buffer
+ * @return The number of matching characters, zero for no match
+ * @since 1.9
+ */
+ default int isMatch(final CharSequence buffer, final int pos) {
+ return isMatch(buffer, pos, 0, buffer.length());
+ }
+
+ /**
* Returns the number of matching characters, {@code 0} if there is no match.
* <p>
* This method is called to check for a match against a source {@code buffer}. The parameter {@code start}
diff --git a/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java
index b85735d..c8e2588 100644
--- a/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java
@@ -31,25 +31,6 @@ import org.junit.jupiter.api.Test;
*/
public class BiFunctionStringLookupTest {
- @Test
- public void testConcurrentHashMapNull() {
- Assertions.assertNull(BiFunctionStringLookup.on(new ConcurrentHashMap<>()).lookup(null));
- }
-
- @Test
- public void testHashMapNull() {
- Assertions.assertNull(BiFunctionStringLookup.on(new HashMap<>()).lookup(null));
- }
-
- @Test
- public void testOne() {
- final String key = "key";
- final String value = "value";
- final Map<String, String> map = new HashMap<>();
- map.put(key, value);
- Assertions.assertEquals(value, FunctionStringLookup.on(map).lookup(key));
- }
-
private static final String SEPARATOR = ".";
@SuppressWarnings("unchecked")
@@ -96,4 +77,23 @@ public class BiFunctionStringLookupTest {
stringLookup.lookup(rootKey + SEPARATOR + subKeyMap + SEPARATOR + subSubKey, rootMap));
}
+ @Test
+ public void testConcurrentHashMapNull() {
+ Assertions.assertNull(BiFunctionStringLookup.on(new ConcurrentHashMap<>()).lookup(null));
+ }
+
+ @Test
+ public void testHashMapNull() {
+ Assertions.assertNull(BiFunctionStringLookup.on(new HashMap<>()).lookup(null));
+ }
+
+ @Test
+ public void testOne() {
+ final String key = "key";
+ final String value = "value";
+ final Map<String, String> map = new HashMap<>();
+ map.put(key, value);
+ Assertions.assertEquals(value, FunctionStringLookup.on(map).lookup(key));
+ }
+
}