commons-dbutils git commit: .travis.yml: openjdk6
Repository: commons-dbutils Updated Branches: refs/heads/master d7181205f -> 469d4a85c .travis.yml: openjdk6 (side-effect: close #1) Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/469d4a85 Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/469d4a85 Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/469d4a85 Branch: refs/heads/master Commit: 469d4a85c0bde16b90240763a9319f797b0849be Parents: d718120 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Tue Jul 25 23:19:53 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Tue Jul 25 23:19:53 2017 +0200 -- .travis.yml | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/469d4a85/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index fc2a03a..ded5c5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ language: java sudo: false jdk: + - openjdk6 - openjdk7 - oraclejdk8
commons-dbutils git commit: Remove oraclejdk7 from travis configuration, because it is no longer available.
Repository: commons-dbutils Updated Branches: refs/heads/master 920642362 -> d7181205f Remove oraclejdk7 from travis configuration, because it is no longer available. see: https://github.com/travis-ci/travis-ci/issues/7964#issuecomment-316769421 for details Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/d7181205 Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/d7181205 Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/d7181205 Branch: refs/heads/master Commit: d7181205fdfbee77197c95225dad0f961d875656 Parents: 9206423 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Tue Jul 25 23:16:45 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Tue Jul 25 23:16:45 2017 +0200 -- .travis.yml | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/d7181205/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index cafe93d..fc2a03a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ sudo: false jdk: - openjdk7 - - oraclejdk7 - oraclejdk8 after_success:
commons-collections git commit: .travis.yml: also build pull requests
Repository: commons-collections Updated Branches: refs/heads/master 1909ca324 -> ee512ca28 .travis.yml: also build pull requests Project: http://git-wip-us.apache.org/repos/asf/commons-collections/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-collections/commit/ee512ca2 Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/tree/ee512ca2 Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/diff/ee512ca2 Branch: refs/heads/master Commit: ee512ca286da5937f5f168f882091edbdbdada57 Parents: 1909ca3 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Tue Jul 25 23:12:19 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Tue Jul 25 23:12:19 2017 +0200 -- .travis.yml | 5 - 1 file changed, 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-collections/blob/ee512ca2/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index 0a0f062..7a3645e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,5 @@ jdk: - openjdk7 - oraclejdk8 -# only build trunk -branches: - only: -- trunk - after_success: - mvn clean test jacoco:report coveralls:report
commons-collections git commit: Remove oraclejdk7 from travis configuration, because it is no longer available.
Repository: commons-collections Updated Branches: refs/heads/master b002903af -> 1909ca324 Remove oraclejdk7 from travis configuration, because it is no longer available. see: https://github.com/travis-ci/travis-ci/issues/7964#issuecomment-316769421 for details Project: http://git-wip-us.apache.org/repos/asf/commons-collections/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-collections/commit/1909ca32 Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/tree/1909ca32 Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/diff/1909ca32 Branch: refs/heads/master Commit: 1909ca32485ae8cb05b4f905ce2dde405c90baea Parents: b002903 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Tue Jul 25 23:11:08 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Tue Jul 25 23:11:08 2017 +0200 -- .travis.yml | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-collections/blob/1909ca32/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index 1731545..0a0f062 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ sudo: false jdk: - openjdk6 - openjdk7 - - oraclejdk7 - oraclejdk8 # only build trunk
commons-imaging git commit: .travis.yml: replace oraclejdk7 with open openjdk7, because oraclejdk7 is no longer available.
Repository: commons-imaging Updated Branches: refs/heads/master 6962d8b98 -> c184bc5a1 .travis.yml: replace oraclejdk7 with open openjdk7, because oraclejdk7 is no longer available. see: https://github.com/travis-ci/travis-ci/issues/7964#issuecomment-316769421 for details Project: http://git-wip-us.apache.org/repos/asf/commons-imaging/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-imaging/commit/c184bc5a Tree: http://git-wip-us.apache.org/repos/asf/commons-imaging/tree/c184bc5a Diff: http://git-wip-us.apache.org/repos/asf/commons-imaging/diff/c184bc5a Branch: refs/heads/master Commit: c184bc5a1ee44e582d718868f376de41b82a3cb4 Parents: 6962d8b Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Tue Jul 25 23:04:59 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Tue Jul 25 23:04:59 2017 +0200 -- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/c184bc5a/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index d1c6bb9..afcd5f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,6 @@ language: java sudo: false jdk: - - oraclejdk7 + - openjdk7 - oraclejdk8
commons-io git commit: Remove oraclejdk7 from travis configuration, because it is no longer available.
Repository: commons-io Updated Branches: refs/heads/master acceb6296 -> 9990c6669 Remove oraclejdk7 from travis configuration, because it is no longer available. see: https://github.com/travis-ci/travis-ci/issues/7964#issuecomment-316769421 for details Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/9990c666 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/9990c666 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/9990c666 Branch: refs/heads/master Commit: 9990c66690467cf6c08be921947532729b7ee91c Parents: acceb62 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Mon Jul 24 23:46:04 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Mon Jul 24 23:46:04 2017 +0200 -- .travis.yml | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/9990c666/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index fd1f6f5..2a591a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ sudo: false jdk: - openjdk7 - - oraclejdk7 - oraclejdk8 script:
[lang] Remove oraclejdk7 from travis configuration, because it is no longer available.
Repository: commons-lang Updated Branches: refs/heads/master 187a05b8a -> fdccdeaec Remove oraclejdk7 from travis configuration, because it is no longer available. see: https://github.com/travis-ci/travis-ci/issues/7964#issuecomment-316769421 for details Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/fdccdeae Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/fdccdeae Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/fdccdeae Branch: refs/heads/master Commit: fdccdeaec531bbb9dbb88f0329b6a351dac09690 Parents: 187a05b Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Mon Jul 24 23:42:38 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Mon Jul 24 23:42:38 2017 +0200 -- .travis.yml | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/fdccdeae/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index 1d9c9cd..be7c71f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ sudo: false jdk: - openjdk7 - - oraclejdk7 - oraclejdk8 script:
[text] Remove oraclejdk7 from travis configuration, because it is no longer available.
Repository: commons-text Updated Branches: refs/heads/master 79ef3cdf1 -> 6773be0a3 Remove oraclejdk7 from travis configuration, because it is no longer available. see: https://github.com/travis-ci/travis-ci/issues/7964#issuecomment-316769421 for details Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/6773be0a Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/6773be0a Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/6773be0a Branch: refs/heads/master Commit: 6773be0a357988126d22decb82e75f601d9814b9 Parents: 79ef3cd Author: Pascal SchumacherAuthored: Mon Jul 24 23:40:01 2017 +0200 Committer: Pascal Schumacher Committed: Mon Jul 24 23:40:01 2017 +0200 -- .travis.yml | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/6773be0a/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index 64905ed..d3097c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ sudo: false jdk: - openjdk7 - - oraclejdk7 - oraclejdk8 script:
[text] Add some unit tests to increase code coverage (closes #56).
Repository: commons-text Updated Branches: refs/heads/master 065a2f125 -> 79ef3cdf1 Add some unit tests to increase code coverage (closes #56). Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/79ef3cdf Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/79ef3cdf Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/79ef3cdf Branch: refs/heads/master Commit: 79ef3cdf1a931531774da378209772dfc743d84a Parents: 065a2f1 Author: Michael HauseggerAuthored: Tue Jul 18 01:26:06 2017 +0200 Committer: Pascal Schumacher Committed: Mon Jul 24 23:16:35 2017 +0200 -- .../commons/text/AlphabetConverterTest.java | 79 .../commons/text/ExtendedMessageFormatTest.java | 41 +- .../org/apache/commons/text/StrBuilderTest.java | 26 +++ .../apache/commons/text/StrSubstitutorTest.java | 67 - .../LevenshteinDetailedDistanceTest.java| 52 - .../similarity/LevenshteinDistanceTest.java | 17 - .../text/similarity/LevenshteinResultsTest.java | 70 + 7 files changed, 343 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/79ef3cdf/src/test/java/org/apache/commons/text/AlphabetConverterTest.java -- diff --git a/src/test/java/org/apache/commons/text/AlphabetConverterTest.java b/src/test/java/org/apache/commons/text/AlphabetConverterTest.java index d235c0e..4ffd20c 100644 --- a/src/test/java/org/apache/commons/text/AlphabetConverterTest.java +++ b/src/test/java/org/apache/commons/text/AlphabetConverterTest.java @@ -18,13 +18,18 @@ package org.apache.commons.text; import java.io.UnsupportedEncodingException; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + /** * Unit tests for {@link AlphabetConverter}. */ @@ -201,4 +206,78 @@ public class AlphabetConverterTest { Assert.assertEquals("Encoded '" + s + "' into '" + encoded + "', but decoded into '" + decoded + "'", s, decoded); } } + +@Test(expected=IllegalArgumentException.class) +public void testCreateConverterFromCharsWithNullAndNull() { +Character[] characterArray = new Character[2]; +characterArray[0] = Character.valueOf('$'); +characterArray[1] = characterArray[0]; + +AlphabetConverter.createConverterFromChars(characterArray, null, null); +} + +@Test +public void testCreateConverterFromCharsOne() { +Character[] characterArray = new Character[2]; +characterArray[0] = new Character('5'); +characterArray[1] = characterArray[0]; +AlphabetConverter alphabetConverter = AlphabetConverter.createConverterFromChars(characterArray, characterArray, characterArray); + +assertEquals(1, alphabetConverter.getEncodedCharLength()); +} + +@Test +public void testCreateConverterFromMapAndEquals() { +Map hashMap = new HashMap<>(); +AlphabetConverter alphabetConverter = AlphabetConverter.createConverterFromMap(hashMap); +hashMap.put(0, "CtDs"); +AlphabetConverter alphabetConverterTwo = AlphabetConverter.createConverterFromMap(hashMap); + +assertFalse(alphabetConverter.equals(alphabetConverterTwo)); +assertEquals(1, alphabetConverter.getEncodedCharLength()); +} + +@Test +public void testEquals() { +Character[] characterArray = new Character[2]; +Character character = new Character('R'); +characterArray[0] = character; +characterArray[1] = character; +AlphabetConverter alphabetConverter = AlphabetConverter.createConverterFromChars(characterArray, characterArray, characterArray); +Map map = new HashMap<>(); +AlphabetConverter alphabetConverterTwo = AlphabetConverter.createConverterFromMap(map); + +assertEquals(1, alphabetConverterTwo.getEncodedCharLength()); +assertFalse(alphabetConverter.equals(alphabetConverterTwo)); +} + +@Test +public void testEqualsWithNull() { +Character[] characterArray = new Character[0]; +AlphabetConverter alphabetConverter = AlphabetConverter.createConverterFromChars(characterArray, null, null); + +assertFalse(alphabetConverter.equals(null)); +} + +@Test +public void testCreateConverterFromCharsAndEquals() { +Character[] characterArray = new
[text] remove unused import statements and unused local variables
Repository: commons-text Updated Branches: refs/heads/master e8ded07ba -> aaf4aba36 remove unused import statements and unused local variables Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/aaf4aba3 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/aaf4aba3 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/aaf4aba3 Branch: refs/heads/master Commit: aaf4aba369ed0b97d17bc9343f763b0d099dbc2f Parents: e8ded07 Author: Pascal SchumacherAuthored: Sun Jul 9 10:32:29 2017 +0200 Committer: Pascal Schumacher Committed: Sun Jul 9 10:32:29 2017 +0200 -- .../java/org/apache/commons/text/RandomStringGeneratorTest.java | 3 --- src/test/java/org/apache/commons/text/StrBuilderTest.java | 2 -- 2 files changed, 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/aaf4aba3/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java -- diff --git a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java index bf00b5c..4d6e699 100644 --- a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java +++ b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java @@ -18,9 +18,6 @@ package org.apache.commons.text; import org.junit.Test; -import java.util.ArrayList; -import java.util.List; - import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.lessThanOrEqualTo; http://git-wip-us.apache.org/repos/asf/commons-text/blob/aaf4aba3/src/test/java/org/apache/commons/text/StrBuilderTest.java -- diff --git a/src/test/java/org/apache/commons/text/StrBuilderTest.java b/src/test/java/org/apache/commons/text/StrBuilderTest.java index 8f81434..04d754e 100644 --- a/src/test/java/org/apache/commons/text/StrBuilderTest.java +++ b/src/test/java/org/apache/commons/text/StrBuilderTest.java @@ -2027,13 +2027,11 @@ public class StrBuilderTest { @Test public void testAppendCharBufferNull() throws Exception { final StrBuilder sb = new StrBuilder("1234567890"); -final String text = "Test "; final CharBuffer buffer = null; sb.append(buffer); assertEquals("1234567890", sb.toString()); final StrBuilder sb1 = new StrBuilder("1234567890"); -final String text1 = "Test "; final CharBuffer buffer1 = null; sb.append(buffer1, 0, 0); assertEquals("1234567890", sb1.toString());
[text] TEXT-93: RandomStringGenerator accepts a list of valid characters
Repository: commons-text Updated Branches: refs/heads/master 9e48de8c8 -> e8ded07ba TEXT-93: RandomStringGenerator accepts a list of valid characters add since javadoc tag and other minimal clean-ups Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/e8ded07b Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/e8ded07b Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/e8ded07b Branch: refs/heads/master Commit: e8ded07ba5b747aee53ada88a8ca70773881ceb5 Parents: 9e48de8 Author: Pascal SchumacherAuthored: Sun Jul 9 10:20:59 2017 +0200 Committer: Pascal Schumacher Committed: Sun Jul 9 10:20:59 2017 +0200 -- .../java/org/apache/commons/text/RandomStringGenerator.java | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/e8ded07b/src/main/java/org/apache/commons/text/RandomStringGenerator.java -- diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java index 0dcf2a1..b3a763a 100644 --- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java +++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java @@ -78,7 +78,7 @@ public final class RandomStringGenerator { private final TextRandomProvider random; /** - * The source of provided charachters. + * The source of provided characters. */ private final List characterList; @@ -122,8 +122,6 @@ public final class RandomStringGenerator { return ThreadLocalRandom.current().nextInt(minInclusive, maxInclusive + 1); } - - /** * Generates a random number within a range, using a {@link ThreadLocalRandom} instance * or the user-supplied source of randomness. @@ -289,7 +287,7 @@ public final class RandomStringGenerator { private TextRandomProvider random; /** - * The source of provided charachters. + * The source of provided characters. */ private List characterList; @@ -410,6 +408,7 @@ public final class RandomStringGenerator { * @param chars set of preefined Characters for random string generation *the Character can be, may be {@code null} or empty * @return {@code this}, to allow method chaining + * @since 1.2 */ public Builder selectFrom(char ... chars) { characterList = new ArrayList();
[1/2] commons-io git commit: IO-542: FileUtils#readFileToByteArray: optimize reading of files with known size (closes #38)
Repository: commons-io Updated Branches: refs/heads/master d4f28d7ff -> acceb6296 IO-542: FileUtils#readFileToByteArray: optimize reading of files with known size (closes #38) Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/936b820a Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/936b820a Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/936b820a Branch: refs/heads/master Commit: 936b820a4e9b9f96661c961bab87e4ec05ca0574 Parents: d4f28d7 Author: Ilmars Poikans <ilm...@delibero.lv> Authored: Sun Jul 2 16:01:23 2017 +0300 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Jul 2 17:09:47 2017 +0200 -- src/main/java/org/apache/commons/io/FileUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/936b820a/src/main/java/org/apache/commons/io/FileUtils.java -- diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java index 10f39b9..f03d785 100644 --- a/src/main/java/org/apache/commons/io/FileUtils.java +++ b/src/main/java/org/apache/commons/io/FileUtils.java @@ -1849,7 +1849,9 @@ public class FileUtils { */ public static byte[] readFileToByteArray(final File file) throws IOException { try (InputStream in = openInputStream(file)) { -return IOUtils.toByteArray(in); // Do NOT use file.length() - see IO-453 +long fileLength = file.length(); +// file.length() may return 0 for system-dependent entities, treat 0 as unknown length - see IO-453 +return fileLength > 0 ? IOUtils.toByteArray(in, fileLength) : IOUtils.toByteArray(in); } }
[2/2] commons-io git commit: IO-542: FileUtils#readFileToByteArray: optimize reading of files with known size
IO-542: FileUtils#readFileToByteArray: optimize reading of files with known size add changes.xml entry Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/acceb629 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/acceb629 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/acceb629 Branch: refs/heads/master Commit: acceb62960971477744f6731bbbc06abbabfe4f3 Parents: 936b820 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Jul 2 17:12:11 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Jul 2 17:12:11 2017 +0200 -- src/changes/changes.xml | 3 +++ 1 file changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/acceb629/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index dd97dc6..6350730 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -47,6 +47,9 @@ The type attribute can be add,update,fix,remove. + +FileUtils#readFileToByteArray: optimize reading of files with known size + Add convenience methods for copyToDirectory
[lang] Fix ExceptionUtils#getStackFrame(String) javadoc (closes #274)
Repository: commons-lang Updated Branches: refs/heads/master 5f0d81275 -> a37d19eb4 Fix ExceptionUtils#getStackFrame(String) javadoc (closes #274) ExceptionUtils#getStackFrame(String)'s javadoc contains a broken reference to SystemUtils#LINE_SEPARATOR (as the class name is not fully qualified, and there's no import of org.apache.commons.lang3.SystemUtils). This patch fixes the broken reference by replacing it it with a reference to System#lineSeparator(), which the method actually uses. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/a37d19eb Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/a37d19eb Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/a37d19eb Branch: refs/heads/master Commit: a37d19eb45d76cd6ab4e2c8fa9fc156bf7be97db Parents: 5f0d812 Author: Allon Mureinik <amure...@redhat.com> Authored: Sat Jul 1 14:50:41 2017 +0300 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Jul 2 16:58:02 2017 +0200 -- .../java/org/apache/commons/lang3/exception/ExceptionUtils.java| 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a37d19eb/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java index 0318512..8fc750b 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java +++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java @@ -605,7 +605,7 @@ public class ExceptionUtils { /** * Returns an array where each element is a line from the argument. * - * The end of line is determined by the value of {@link SystemUtils#LINE_SEPARATOR}. + * The end of line is determined by the value of {@link System#lineSeparator()}. * * @param stackTrace a stack trace String * @return an array where each element is a line from the argument
[text] TEXT-90: Add CharacterPredicates for ASCII letters (uppercase/lowercase) and Arabic numerals (closes #50)
Repository: commons-text Updated Branches: refs/heads/master 25ec8d186 -> 569dbc094 TEXT-90: Add CharacterPredicates for ASCII letters (uppercase/lowercase) and Arabic numerals (closes #50) Add CharacterPredicates#ARABIC_NUMERALS, #ASCII_LOWERCASE_LETTERS, #ASCII_UPPERCASE_LETTERS, #ASCII_LETTERS and #ASCII_ALPHA_NUMERALS. Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/569dbc09 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/569dbc09 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/569dbc09 Branch: refs/heads/master Commit: 569dbc09402a6f28334936567a597e3d0db9185c Parents: 25ec8d1 Author: Pascal SchumacherAuthored: Wed Jun 14 22:04:55 2017 +0200 Committer: Pascal Schumacher Committed: Thu Jun 22 20:53:39 2017 +0200 -- src/changes/changes.xml | 1 + .../commons/text/CharacterPredicates.java | 61 ++ .../commons/text/CharacterPredicatesTest.java | 66 3 files changed, 128 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/569dbc09/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index f6c5b8f..412d1f4 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,7 @@ The type attribute can be add,update,fix,remove. + Add CharacterPredicates for ASCII letters (uppercase/lowercase) and arabic numerals Added CaseUtils class with camel case conversion support RandomStringGenerator should be able to generate a String with a random length Update commons-lang dependency to version 3.6 http://git-wip-us.apache.org/repos/asf/commons-text/blob/569dbc09/src/main/java/org/apache/commons/text/CharacterPredicates.java -- diff --git a/src/main/java/org/apache/commons/text/CharacterPredicates.java b/src/main/java/org/apache/commons/text/CharacterPredicates.java index a4544de..dc504c7 100644 --- a/src/main/java/org/apache/commons/text/CharacterPredicates.java +++ b/src/main/java/org/apache/commons/text/CharacterPredicates.java @@ -48,5 +48,66 @@ public enum CharacterPredicates implements CharacterPredicate { public boolean test(int codePoint) { return Character.isDigit(codePoint); } +}, + +/** + * Tests if the code points represents a number between 0 and 9. + * + * @since 1.2 + */ +ARABIC_NUMERALS { +@Override +public boolean test(int codePoint) { +return codePoint >= '0' && codePoint <= '9'; +} +}, + +/** + * Tests if the code points represents a letter between a and z. + * + * @since 1.2 + */ +ASCII_LOWERCASE_LETTERS { +@Override +public boolean test(int codePoint) { +return codePoint >= 'a' && codePoint <= 'z'; +} +}, + +/** + * Tests if the code points represents a letter between A and Z. + * + * @since 1.2 + */ +ASCII_UPPERCASE_LETTERS { +@Override +public boolean test(int codePoint) { +return codePoint >= 'A' && codePoint <= 'Z'; +} +}, + +/** + * Tests if the code points represents a letter between a and Z. + * + * @since 1.2 + */ +ASCII_LETTERS { +@Override +public boolean test(int codePoint) { +return ASCII_LOWERCASE_LETTERS.test(codePoint) || ASCII_UPPERCASE_LETTERS.test(codePoint); +} +}, + +/** + * Tests if the code points represents a letter between a and Z or a number between 0 and 9. + * + * @since 1.2 + */ +ASCII_ALPHA_NUMERALS { +@Override +public boolean test(int codePoint) { +return ASCII_LOWERCASE_LETTERS.test(codePoint) || ASCII_UPPERCASE_LETTERS.test(codePoint) +|| ARABIC_NUMERALS.test(codePoint); +} } } http://git-wip-us.apache.org/repos/asf/commons-text/blob/569dbc09/src/test/java/org/apache/commons/text/CharacterPredicatesTest.java -- diff --git a/src/test/java/org/apache/commons/text/CharacterPredicatesTest.java b/src/test/java/org/apache/commons/text/CharacterPredicatesTest.java index a22b466..1100868 100644 --- a/src/test/java/org/apache/commons/text/CharacterPredicatesTest.java +++ b/src/test/java/org/apache/commons/text/CharacterPredicatesTest.java @@ -44,4 +44,70 @@ public class CharacterPredicatesTest { assertFalse(CharacterPredicates.DIGITS.test('.'));
[3/3] [text] TEXT-85: Added CaseUtils class with camel case conversion
TEXT-85: Added CaseUtils class with camel case conversion correct since javadoc tag and other minimal clean-ups Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/25ec8d18 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/25ec8d18 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/25ec8d18 Branch: refs/heads/master Commit: 25ec8d186b37b8d0a85a9c42d10a107966ce955d Parents: 997a613 Author: Pascal SchumacherAuthored: Thu Jun 22 20:25:13 2017 +0200 Committer: Pascal Schumacher Committed: Thu Jun 22 20:25:13 2017 +0200 -- src/main/java/org/apache/commons/text/CaseUtils.java | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/25ec8d18/src/main/java/org/apache/commons/text/CaseUtils.java -- diff --git a/src/main/java/org/apache/commons/text/CaseUtils.java b/src/main/java/org/apache/commons/text/CaseUtils.java index 0e313a4..ae2067e 100644 --- a/src/main/java/org/apache/commons/text/CaseUtils.java +++ b/src/main/java/org/apache/commons/text/CaseUtils.java @@ -28,7 +28,7 @@ import java.util.Set; * An exception will not be thrown for a null input. * Each method documents its behaviour in more detail. * - * @since 1.0 + * @since 1.2 */ public class CaseUtils { @@ -44,8 +44,6 @@ public class CaseUtils { super(); } -// Camel Case -//--- /** * Converts all the delimiter separated words in a String into camelCase, * that is each word is made up of a titlecase character and then a series of @@ -112,19 +110,17 @@ public class CaseUtils { } else { return str; } - } /** * Converts an array of delimiters to a hash set of code points. Code point of space(32) is added - * as the default value. The generated hash set provides O(1) - * lookup time . + * as the default value. The generated hash set provides O(1) lookup time. * * @param delimiters set of characters to determine capitalization, null means whitespace * @return Set */ private static Set generateDelimiterSet(final char[] delimiters) { -Set delimiterHashSet = new HashSet(); +Set delimiterHashSet = new HashSet<>(); delimiterHashSet.add(Character.codePointAt(new char[]{' '}, 0)); if (delimiters == null || delimiters.length == 0) { return delimiterHashSet; @@ -134,7 +130,6 @@ public class CaseUtils { delimiterHashSet.add(Character.codePointAt(delimiters, index)); } return delimiterHashSet; - } }
[1/3] [text] StrBuilderTest#testAppendln: make test operating system independent
Repository: commons-text Updated Branches: refs/heads/master 2de4cf9b9 -> 25ec8d186 StrBuilderTest#testAppendln: make test operating system independent Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/3fcc4e85 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/3fcc4e85 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/3fcc4e85 Branch: refs/heads/master Commit: 3fcc4e8586807424fff21ee1f55fc2779ae78524 Parents: 2de4cf9 Author: Pascal SchumacherAuthored: Thu Jun 22 20:22:41 2017 +0200 Committer: Pascal Schumacher Committed: Thu Jun 22 20:22:41 2017 +0200 -- src/test/java/org/apache/commons/text/StrBuilderTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/3fcc4e85/src/test/java/org/apache/commons/text/StrBuilderTest.java -- diff --git a/src/test/java/org/apache/commons/text/StrBuilderTest.java b/src/test/java/org/apache/commons/text/StrBuilderTest.java index 6039a95..24bc6e1 100644 --- a/src/test/java/org/apache/commons/text/StrBuilderTest.java +++ b/src/test/java/org/apache/commons/text/StrBuilderTest.java @@ -2103,6 +2103,6 @@ public class StrBuilderTest { public void testAppendln() { final StrBuilder sb1 = new StrBuilder(); final char ch = 'c'; -assertEquals("c\n", sb1.appendln(ch).toString()); +assertEquals("c" + System.lineSeparator(), sb1.appendln(ch).toString()); } }
[2/3] [text] StrBuilderTest#testAppendStringBuilderNull: use second StringBuilder for second assertion
StrBuilderTest#testAppendStringBuilderNull: use second StringBuilder for second assertion Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/997a6134 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/997a6134 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/997a6134 Branch: refs/heads/master Commit: 997a613477a170926f5e82d693cc5cf2f4d1e473 Parents: 3fcc4e8 Author: Pascal SchumacherAuthored: Thu Jun 22 20:24:14 2017 +0200 Committer: Pascal Schumacher Committed: Thu Jun 22 20:24:14 2017 +0200 -- src/test/java/org/apache/commons/text/StrBuilderTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/997a6134/src/test/java/org/apache/commons/text/StrBuilderTest.java -- diff --git a/src/test/java/org/apache/commons/text/StrBuilderTest.java b/src/test/java/org/apache/commons/text/StrBuilderTest.java index 24bc6e1..8f81434 100644 --- a/src/test/java/org/apache/commons/text/StrBuilderTest.java +++ b/src/test/java/org/apache/commons/text/StrBuilderTest.java @@ -2096,7 +2096,7 @@ public class StrBuilderTest { assertEquals("", sb1.append(b).toString()); final StrBuilder sb2 = new StrBuilder(); -assertEquals("", sb1.append(b, 0, 0).toString()); +assertEquals("", sb2.append(b, 0, 0).toString()); } @Test
[text] TEXT-91: RandomStringGenerator should be able to generate a String with a random length (closes #51)
Repository: commons-text Updated Branches: refs/heads/master 6276d029b -> 2035ed14f TEXT-91: RandomStringGenerator should be able to generate a String with a random length (closes #51) Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/2035ed14 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/2035ed14 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/2035ed14 Branch: refs/heads/master Commit: 2035ed14fc77342909a35c1b61b28e8be66f49e0 Parents: 6276d02 Author: Pascal SchumacherAuthored: Wed Jun 14 22:34:09 2017 +0200 Committer: Pascal Schumacher Committed: Sun Jun 18 09:02:55 2017 +0200 -- src/changes/changes.xml | 1 + .../commons/text/RandomStringGenerator.java | 21 + .../commons/text/RandomStringGeneratorTest.java | 24 3 files changed, 46 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/2035ed14/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 86abf92..a97b474 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,7 @@ The type attribute can be add,update,fix,remove. +RandomStringGenerator should be able to generate a String with a random length Update commons-lang dependency to version 3.6 Document that commons-csv should be used in preference to CsvTranslators NumericEntityUnescaper.options - fix TODO http://git-wip-us.apache.org/repos/asf/commons-text/blob/2035ed14/src/main/java/org/apache/commons/text/RandomStringGenerator.java -- diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java index 6df21aa..37aec28 100644 --- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java +++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java @@ -177,6 +177,27 @@ public final class RandomStringGenerator { } /** + * Generates a random string, containing between the minimum (inclusive) and the maximum (inclusive) + * number of code points. + * + * @param minLengthInclusive + *the minimum (inclusive) number of code points to generate + * @param maxLengthInclusive + *the maximum (inclusive) number of code points to generate + * @return the generated string + * @throws IllegalArgumentException + * if {@code minLengthInclusive < 0}, or {@code maxLengthInclusive < minLengthInclusive} + * @see RandomStringGenerator#generate(int) + * @since 1.2 + */ +public String generate(final int minLengthInclusive, final int maxLengthInclusive) { +Validate.isTrue(minLengthInclusive >= 0, "Minimum length %d is smaller than zero.", minLengthInclusive); +Validate.isTrue(minLengthInclusive <= maxLengthInclusive, +"Maximum length %d is smaller than minimum length %d.", maxLengthInclusive, minLengthInclusive); +return generate(generateRandomNumber(minLengthInclusive, maxLengthInclusive)); +} + +/** * A builder for generating {@code RandomStringGenerator} instances. * The behaviour of a generator is controlled by properties set by this * builder. Each property has a default value, which can be overridden by http://git-wip-us.apache.org/repos/asf/commons-text/blob/2035ed14/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java -- diff --git a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java index 86537fa..ff50ac4 100644 --- a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java +++ b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java @@ -18,6 +18,9 @@ package org.apache.commons.text; import org.junit.Test; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.junit.Assert.*; /** @@ -45,6 +48,18 @@ public class RandomStringGeneratorTest { generator.generate(-1); } +@Test(expected = IllegalArgumentException.class) +public void testGenerateMinMaxLengthInvalidLength() { +RandomStringGenerator generator = new RandomStringGenerator.Builder().build(); +generator.generate(-1, 0); +} + +@Test(expected = IllegalArgumentException.class) +public
[text] revert "Added IBM Jdk8 build support to travis-ci configuration" (closes #53)
Repository: commons-text Updated Branches: refs/heads/master 0914cb2cb -> 6276d029b revert "Added IBM Jdk8 build support to travis-ci configuration" (closes #53) Although this is a desirable feature, it does not work as currently implemented: The build fails, but this failure is not reflected in the travis build status. Code-coverage is broken. Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/6276d029 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/6276d029 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/6276d029 Branch: refs/heads/master Commit: 6276d029bafeaf3002629e84c45fbb4ed09a6044 Parents: 0914cb2 Author: Pascal SchumacherAuthored: Sun Jun 18 08:48:41 2017 +0200 Committer: Pascal Schumacher Committed: Sun Jun 18 08:59:36 2017 +0200 -- .travis.yml | 7 --- 1 file changed, 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/6276d029/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index a80fc2e..64905ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,15 +21,8 @@ jdk: - oraclejdk7 - oraclejdk8 -services: - - docker - -before_install: - - docker pull ibmcom/ibmjava:8-sdk - script: - mvn - - docker run -v `pwd`:/work library/ibmjava:8-sdk /bin/bash -c "apt-get update && cd work && apt-get install -y maven && mvn" after_success: - mvn clean test jacoco:report coveralls:report
[text] TEXT-92: Update commons-lang dependency to version 3.6
Repository: commons-text Updated Branches: refs/heads/master 0029f139b -> 0914cb2cb TEXT-92: Update commons-lang dependency to version 3.6 Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/0914cb2c Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/0914cb2c Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/0914cb2c Branch: refs/heads/master Commit: 0914cb2cb80ee74f5ba46184309ad11b34b981e9 Parents: 0029f13 Author: Pascal SchumacherAuthored: Wed Jun 14 23:40:39 2017 +0200 Committer: Pascal Schumacher Committed: Wed Jun 14 23:40:39 2017 +0200 -- pom.xml | 2 +- src/changes/changes.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/0914cb2c/pom.xml -- diff --git a/pom.xml b/pom.xml index 809d105..0ce1864 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ org.apache.commons commons-lang3 - 3.5 + 3.6 http://git-wip-us.apache.org/repos/asf/commons-text/blob/0914cb2c/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 9d9971e..86abf92 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,7 @@ The type attribute can be add,update,fix,remove. +Update commons-lang dependency to version 3.6 Document that commons-csv should be used in preference to CsvTranslators NumericEntityUnescaper.options - fix TODO RandomStringGenerator claims to be immutable, but isn't
[text] TEXT-83: Document that commons-csv should be used in preference to CsvTranslators
Repository: commons-text Updated Branches: refs/heads/master 9ce255f89 -> 0029f139b TEXT-83: Document that commons-csv should be used in preference to CsvTranslators clarify statement Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/0029f139 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/0029f139 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/0029f139 Branch: refs/heads/master Commit: 0029f139bdb3f2653cdf1e9971238d00656926c6 Parents: 9ce255f Author: Pascal SchumacherAuthored: Mon Jun 12 20:41:34 2017 +0200 Committer: Pascal Schumacher Committed: Mon Jun 12 20:41:34 2017 +0200 -- src/changes/changes.xml | 4 ++-- .../org/apache/commons/text/translate/CsvTranslators.java | 9 ++--- 2 files changed, 4 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/0029f139/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 90c494d..9d9971e 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,8 +46,8 @@ The type attribute can be add,update,fix,remove. -Document CsvTranslators from from commons text in favor of Commons CSV -NumericEntityUnescaper.options - TODO +Document that commons-csv should be used in preference to CsvTranslators +NumericEntityUnescaper.options - fix TODO RandomStringGenerator claims to be immutable, but isn't http://git-wip-us.apache.org/repos/asf/commons-text/blob/0029f139/src/main/java/org/apache/commons/text/translate/CsvTranslators.java -- diff --git a/src/main/java/org/apache/commons/text/translate/CsvTranslators.java b/src/main/java/org/apache/commons/text/translate/CsvTranslators.java index 081aa82..2987ead 100644 --- a/src/main/java/org/apache/commons/text/translate/CsvTranslators.java +++ b/src/main/java/org/apache/commons/text/translate/CsvTranslators.java @@ -24,15 +24,10 @@ import org.apache.commons.lang3.StringUtils; /** * This class holds inner classes for escaping/unescaping Comma Separated Values. * - * In favor of Commons CSV which is responsible for all csv operations its always - * recommended to use API given in commons-csv. - * - * {@link CsvTranslators} have made by keeping in mind it will be useful to make high - * level and more complex API around CSV files. All low level API working on Text and - * with CSV are present in this class. + * In general the use a high level API like commons-csv should be preferred over these + * low level classes. * * @see http://commons.apache.org/proper/commons-csv/apidocs/index.html;>commons-csv - * */ public final class CsvTranslators {
[text] CsvTranslatorsTest: fix formatting
Repository: commons-text Updated Branches: refs/heads/master 8c94bb394 -> 1304d79eb CsvTranslatorsTest: fix formatting Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/1304d79e Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/1304d79e Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/1304d79e Branch: refs/heads/master Commit: 1304d79eb9abd8be5a9432255fe55b4f95d35d59 Parents: 8c94bb3 Author: Pascal SchumacherAuthored: Sun Jun 11 23:19:59 2017 +0200 Committer: Pascal Schumacher Committed: Sun Jun 11 23:19:59 2017 +0200 -- .../text/translate/CsvTranslatorsTest.java | 205 +-- 1 file changed, 99 insertions(+), 106 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/1304d79e/src/test/java/org/apache/commons/text/translate/CsvTranslatorsTest.java -- diff --git a/src/test/java/org/apache/commons/text/translate/CsvTranslatorsTest.java b/src/test/java/org/apache/commons/text/translate/CsvTranslatorsTest.java index 6d1e721..304eb77 100644 --- a/src/test/java/org/apache/commons/text/translate/CsvTranslatorsTest.java +++ b/src/test/java/org/apache/commons/text/translate/CsvTranslatorsTest.java @@ -27,111 +27,104 @@ import org.junit.Test; public class CsvTranslatorsTest { - @Test - public void csvEscaperPlaneTextTest() throws IOException{ - final CsvTranslators.CsvEscaper escaper = new CsvTranslators.CsvEscaper(); - final Writer writer = new StringWriter(); - final String input = "hi this is just a plane text nothing to do with csv!"; - escaper.translateWhole(input, writer); - String data = writer.toString(); - assertEquals(data, input); - } - - @Test - public void csvEscaperCommaTest() throws IOException{ - final CsvTranslators.CsvEscaper escaper = new CsvTranslators.CsvEscaper(); - final Writer writer = new StringWriter(); - final String input = "hi,this,is,a,test"; - escaper.translateWhole(input, writer); - String data = writer.toString(); - assertEquals(data, "\"hi,this,is,a,test\""); - - } - - @Test - public void csvEscaperQuoteTest() throws IOException{ - final CsvTranslators.CsvEscaper escaper = new CsvTranslators.CsvEscaper(); - final Writer writer = new StringWriter(); - final String input = "hi,this,is,a,\"quote,test"; - escaper.translateWhole(input, writer); - String data = writer.toString(); - assertEquals(data, "\"hi,this,is,a,\"\"quote,test\""); - - } - @Test - public void csvEscaperCRTest() throws IOException{ - final CsvTranslators.CsvEscaper escaper = new CsvTranslators.CsvEscaper(); - final Writer writer = new StringWriter(); - final String input = "hi,this,is,a,CR,test" + String.valueOf(CharUtils.CR); - escaper.translateWhole(input, writer); - String data = writer.toString(); - assertEquals(data, "\"hi,this,is,a,CR,test"+String.valueOf(CharUtils.CR)+"\""); - - } - @Test - public void csvEscaperLFTest() throws IOException{ - final CsvTranslators.CsvEscaper escaper = new CsvTranslators.CsvEscaper(); - final Writer writer = new StringWriter(); - final String input = "hi,this,is,a,LF,test" + String.valueOf(CharUtils.LF); - escaper.translateWhole(input, writer); - String data = writer.toString(); - assertEquals(data, "\"hi,this,is,a,LF,test" + String.valueOf(CharUtils.LF) +"\""); - - } - - @Test - public void csvUnEscaperPlaneTextTest() throws IOException{ - final CsvTranslators.CsvUnescaper escaper = new CsvTranslators.CsvUnescaper(); - final Writer writer = new StringWriter(); - final String input = "hi,this,is,unescape,test"; - escaper.translateWhole(input, writer); - String data = writer.toString(); - assertEquals(data, "hi,this,is,unescape,test"); - - } - - @Test - public void csvUnEscaperTest1() throws IOException{ - final CsvTranslators.CsvUnescaper escaper = new CsvTranslators.CsvUnescaper(); - final Writer writer = new StringWriter(); - final String input = "\"hi,this,is,unescape,test\""; - escaper.translateWhole(input, writer); - String data = writer.toString(); -
[lang] [LANG-1304] StringUtils method to check for mixed case in string (closes #223)
Repository: commons-lang Updated Branches: refs/heads/master ebe7bb58a -> ef3015cc9 [LANG-1304] StringUtils method to check for mixed case in string (closes #223) Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/ef3015cc Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/ef3015cc Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/ef3015cc Branch: refs/heads/master Commit: ef3015cc99f7bd51862c1d95014e8332d24c2341 Parents: ebe7bb5 Author: Andy Klimczak <andyklimc...@fastmail.com> Authored: Thu Dec 29 21:01:12 2016 -0500 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Thu May 25 16:14:46 2017 +0200 -- src/changes/changes.xml | 1 + .../org/apache/commons/lang3/StringUtils.java | 41 .../apache/commons/lang3/StringUtilsTest.java | 23 +++ 3 files changed, 65 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ef3015cc/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 1761d8e..cb2cbf3 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,7 @@ The type attribute can be add,update,fix,remove. +Add method in StringUtils to determine if string contains both mixed cased characters Deprecate CharEncoding in favour of java.nio.charset.StandardCharsets MultilineRecursiveToStringStyle StackOverflowError when object is an array Increase test coverage of ToStringBuilder class to 100% http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ef3015cc/src/main/java/org/apache/commons/lang3/StringUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 7134853..7f64322 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -7303,6 +7303,47 @@ public class StringUtils { return true; } +/** + * Checks if the CharSequence contains mixed casing of both uppercase and lowercase characters. + * + * {@code null} will return {@code false}. An empty CharSequence ({@code length()=0}) will return + * {@code false}. + * + * + * StringUtils.isMixedCase(null)= false + * StringUtils.isMixedCase("") = false + * StringUtils.isMixedCase("ABC") = false + * StringUtils.isMixedCase("abc") = false + * StringUtils.isMixedCase("aBc") = true + * StringUtils.isMixedCase("A c") = true + * StringUtils.isMixedCase("A1c") = true + * StringUtils.isMixedCase("a/C") = true + * StringUtils.isMixedCase("aC\t") = true + * + * + * @param cs the CharSequence to check, may be null + * @return {@code true} if the CharSequence contains both uppercase and lowercase characters + * @since 3.5 + */ +public static boolean isMixedCase(final CharSequence cs) { +if (isEmpty(cs) || cs.length() == 1) { +return false; +} +boolean containsUppercase = false; +boolean containsLowercase = false; +final int sz = cs.length(); +for (int i = 0; i < sz; i++) { +if (containsUppercase && containsLowercase) { +return true; +} else if (Character.isUpperCase(cs.charAt(i))) { +containsUppercase = true; +} else if (Character.isLowerCase(cs.charAt(i))) { +containsLowercase = true; +} +} +return containsUppercase && containsLowercase; +} + // Defaults //--- /** http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ef3015cc/src/test/java/org/apache/commons/lang3/StringUtilsTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java index 3051b47..2b49669 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java @@ -2581,6 +2581,29 @@ public class StringUtilsTest { assertFalse(StringUtils.isAllUpperCase("A/C")); } +/** + * Test for {@link StringUtils#isMixedCase(CharSequence)}. + */ +@Test +public void testIsMixedCase() { +assertFalse(StringUtils.isMixe
[2/2] [lang] LANG-1316: Deprecate classes/methods moved to commons-text
LANG-1316: Deprecate classes/methods moved to commons-text Deprecated WordUtils and RandomStringUtils now that commons-text 1.1 was released. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/ebe7bb58 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/ebe7bb58 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/ebe7bb58 Branch: refs/heads/master Commit: ebe7bb58a541bf397333f466d412e617266ee5aa Parents: 8019416 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Thu May 25 14:49:46 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Thu May 25 14:49:46 2017 +0200 -- src/main/java/org/apache/commons/lang3/RandomStringUtils.java| 4 src/main/java/org/apache/commons/lang3/text/WordUtils.java | 4 .../java/org/apache/commons/lang3/RandomStringUtilsTest.java | 1 + src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java | 1 + 4 files changed, 10 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ebe7bb58/src/main/java/org/apache/commons/lang3/RandomStringUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java index ba42d36..c5e256b 100644 --- a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java +++ b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java @@ -31,7 +31,11 @@ import java.util.Random; * * #ThreadSafe# * @since 1.0 + * @deprecated as of 3.6, use commons-text + * https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/RandomStringGenerator.html;> + * RandomStringGenerator instead */ +@Deprecated public class RandomStringUtils { /** http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ebe7bb58/src/main/java/org/apache/commons/lang3/text/WordUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/text/WordUtils.java b/src/main/java/org/apache/commons/lang3/text/WordUtils.java index 0f6f363..16ae683 100644 --- a/src/main/java/org/apache/commons/lang3/text/WordUtils.java +++ b/src/main/java/org/apache/commons/lang3/text/WordUtils.java @@ -30,7 +30,11 @@ import org.apache.commons.lang3.StringUtils; * Each method documents its behaviour in more detail. * * @since 2.0 + * @deprecated as of 3.6, use commons-text + * https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/WordUtils.html;> + * WordUtils instead */ +@Deprecated public class WordUtils { /** http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ebe7bb58/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java index 961eb2d..68d10d2 100644 --- a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java @@ -37,6 +37,7 @@ import org.junit.Test; /** * Unit tests {@link org.apache.commons.lang3.RandomStringUtils}. */ +@Deprecated public class RandomStringUtilsTest { //--- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ebe7bb58/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java index a709a77..370e754 100644 --- a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java @@ -29,6 +29,7 @@ import org.junit.Test; /** * Unit tests for WordUtils class. */ +@Deprecated public class WordUtilsTest { //---
[1/2] [lang] ObjectUtils#identityToString(StrBuilder, Object): improve deprecating javadoc comment
Repository: commons-lang Updated Branches: refs/heads/master 670bb2e0a -> ebe7bb58a ObjectUtils#identityToString(StrBuilder, Object): improve deprecating javadoc comment Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/8019416d Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/8019416d Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/8019416d Branch: refs/heads/master Commit: 8019416d8197df8881788f889edfcf2ad45c4bf8 Parents: 670bb2e Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Thu May 25 14:46:50 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Thu May 25 14:46:50 2017 +0200 -- src/main/java/org/apache/commons/lang3/ObjectUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/8019416d/src/main/java/org/apache/commons/lang3/ObjectUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java b/src/main/java/org/apache/commons/lang3/ObjectUtils.java index 13d1256..b5a00db 100644 --- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java +++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java @@ -373,7 +373,8 @@ public class ObjectUtils { * @param builder the builder to append to * @param object the object to create a toString for * @since 3.2 - * @deprecated as of 3.6, use one of the other {@code identityToString} methods instead + * @deprecated as of 3.6, because StrBuilder was moved to commons-text, + * use one of the other {@code identityToString} methods instead */ @Deprecated public static void identityToString(final StrBuilder builder, final Object object) {
[lang] include checkstyle-suppressions.xml file in source distribution
Repository: commons-lang Updated Branches: refs/heads/master 9f2fe9bb8 -> 670bb2e0a include checkstyle-suppressions.xml file in source distribution Now checkstyle can be successfully executed from the source distribution (e.g. as part of the site life-cylce). Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/670bb2e0 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/670bb2e0 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/670bb2e0 Branch: refs/heads/master Commit: 670bb2e0a1e67894ac29bb1bc4287c40943f0205 Parents: 9f2fe9b Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Thu May 25 14:00:38 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Thu May 25 14:00:38 2017 +0200 -- src/assembly/src.xml | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/670bb2e0/src/assembly/src.xml -- diff --git a/src/assembly/src.xml b/src/assembly/src.xml index e2d2af6..dc91e0e 100644 --- a/src/assembly/src.xml +++ b/src/assembly/src.xml @@ -26,6 +26,7 @@ .travis.yml checkstyle.xml +checkstyle-suppressions.xml findbugs-exclude-filter.xml LICENSE.txt NOTICE.txt
[lang] LANG-1320: correct id in changes.xml
Repository: commons-lang Updated Branches: refs/heads/master 7c19a1ff4 -> 9f2fe9bb8 LANG-1320: correct id in changes.xml Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/9f2fe9bb Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/9f2fe9bb Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/9f2fe9bb Branch: refs/heads/master Commit: 9f2fe9bb80065fc249c61c897a0434e9ff48bbf6 Parents: 7c19a1f Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Tue May 23 00:34:59 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Tue May 23 00:34:59 2017 +0200 -- src/changes/changes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9f2fe9bb/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 69b95d7..1761d8e 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -53,7 +53,7 @@ The type attribute can be add,update,fix,remove. Implement HashSetvBitSetTest using JMH Add JMH maven dependencies Add null filter to ReflectionToStringBuilder -LocaleUtils#toLocale does not support language followed by UN M.49 numeric-3 area code followed by variant +LocaleUtils#toLocale does not support language followed by UN M.49 numeric-3 area code followed by variant Clarify or improve behaviour of int-based indexOf methods in StringUtils Add method for converting string to an array of code points RandomStringUtils random method can overflow and return characters outside of specified range
[text] use Validate to check arguments
Repository: commons-text Updated Branches: refs/heads/master f651b78a6 -> 732450209 use Validate to check arguments Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/73245020 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/73245020 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/73245020 Branch: refs/heads/master Commit: 7324502096a1e7f02c510285aba087557dec0059 Parents: f651b78 Author: Pascal SchumacherAuthored: Fri May 5 14:10:06 2017 +0200 Committer: Pascal Schumacher Committed: Fri May 5 14:43:01 2017 +0200 -- .../commons/text/RandomStringGenerator.java | 24 +++- .../org/apache/commons/text/StrSubstitutor.java | 18 +-- .../java/org/apache/commons/text/WordUtils.java | 16 +++-- .../text/similarity/EditDistanceFrom.java | 6 ++--- .../commons/text/similarity/RegexTokenizer.java | 7 +++--- .../text/similarity/SimilarityScoreFrom.java| 6 ++--- .../text/translate/CharSequenceTranslator.java | 6 ++--- 7 files changed, 30 insertions(+), 53 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/73245020/src/main/java/org/apache/commons/text/RandomStringGenerator.java -- diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java index ab7fd9d..8596a9b 100644 --- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java +++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java @@ -20,6 +20,8 @@ import java.util.HashSet; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; +import org.apache.commons.lang3.Validate; + /** * * Generates random Unicode strings containing the specified number of code points. @@ -119,9 +121,7 @@ public final class RandomStringGenerator { if (length == 0) { return ""; } -if (length < 0) { -throw new IllegalArgumentException(String.format("Length %d is smaller than zero.", length)); -} +Validate.isTrue(length > 0, "Length %d is smaller than zero.", length); final StringBuilder builder = new StringBuilder(length); long remaining = length; @@ -223,19 +223,11 @@ public final class RandomStringGenerator { * if {@code minimumCodePoint > maximumCodePoint} */ public Builder withinRange(final int minimumCodePoint, final int maximumCodePoint) { -if (minimumCodePoint > maximumCodePoint) { -throw new IllegalArgumentException(String.format( -"Minimum code point %d is larger than maximum code point %d", -minimumCodePoint, maximumCodePoint)); -} -if (minimumCodePoint < 0) { -throw new IllegalArgumentException( -String.format("Minimum code point %d is negative", minimumCodePoint)); -} -if (maximumCodePoint > Character.MAX_CODE_POINT) { -throw new IllegalArgumentException( -String.format("Value %d is larger than Character.MAX_CODE_POINT.", maximumCodePoint)); -} +Validate.isTrue(minimumCodePoint <= maximumCodePoint, +"Minimum code point %d is larger than maximum code point %d", minimumCodePoint, maximumCodePoint); +Validate.isTrue(minimumCodePoint >= 0, "Minimum code point %d is negative", minimumCodePoint); +Validate.isTrue(maximumCodePoint <= Character.MAX_CODE_POINT, +"Value %d is larger than Character.MAX_CODE_POINT.", maximumCodePoint); this.minimumCodePoint = minimumCodePoint; this.maximumCodePoint = maximumCodePoint; http://git-wip-us.apache.org/repos/asf/commons-text/blob/73245020/src/main/java/org/apache/commons/text/StrSubstitutor.java -- diff --git a/src/main/java/org/apache/commons/text/StrSubstitutor.java b/src/main/java/org/apache/commons/text/StrSubstitutor.java index 3cb4b9b..27b2af4 100644 --- a/src/main/java/org/apache/commons/text/StrSubstitutor.java +++ b/src/main/java/org/apache/commons/text/StrSubstitutor.java @@ -23,6 +23,8 @@ import java.util.List; import java.util.Map; import java.util.Properties; +import org.apache.commons.lang3.Validate; + /** * Substitutes variables within a string by values. * @@ -982,9 +984,7 @@ public class StrSubstitutor { * @throws IllegalArgumentException if the prefix matcher is null */ public StrSubstitutor
[text] pom.xml: add goals executed on travis as defaultGoal to make it easy to run the same checks locally
Repository: commons-text Updated Branches: refs/heads/master d4890a893 -> e0b744e52 pom.xml: add goals executed on travis as defaultGoal to make it easy to run the same checks locally Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/e0b744e5 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/e0b744e5 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/e0b744e5 Branch: refs/heads/master Commit: e0b744e524d70b3d31ea26fde5f72195ed101986 Parents: d4890a8 Author: Pascal SchumacherAuthored: Thu May 4 21:31:18 2017 +0200 Committer: Pascal Schumacher Committed: Thu May 4 21:31:18 2017 +0200 -- pom.xml | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/e0b744e5/pom.xml -- diff --git a/pom.xml b/pom.xml index 750da98..87534ba 100644 --- a/pom.xml +++ b/pom.xml @@ -150,6 +150,7 @@ +clean test apache-rat:check clirr:check checkstyle:check findbugs:check javadoc:javadoc
[lang] pom.xml: add goals executed on travis as defaultGoal to make it easy to run the same checks locally
Repository: commons-lang Updated Branches: refs/heads/master 1375e931d -> 340f5f70e pom.xml: add goals executed on travis as defaultGoal to make it easy to run the same checks locally Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/340f5f70 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/340f5f70 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/340f5f70 Branch: refs/heads/master Commit: 340f5f70e970a85c760416569ad877bf7209b6b6 Parents: 1375e93 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Thu May 4 21:27:40 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Thu May 4 21:27:40 2017 +0200 -- pom.xml | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/340f5f70/pom.xml -- diff --git a/pom.xml b/pom.xml index 481840f..6346074 100644 --- a/pom.xml +++ b/pom.xml @@ -603,6 +603,7 @@ + clean test apache-rat:check clirr:check checkstyle:check findbugs:check javadoc:javadoc
[lang] StrBuilder: remove commented-out code
Repository: commons-lang Updated Branches: refs/heads/master 7ddfc8ae1 -> 1375e931d StrBuilder: remove commented-out code Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/1375e931 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/1375e931 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/1375e931 Branch: refs/heads/master Commit: 1375e931d7c7e6de8b297378fc296029d476d7e8 Parents: 7ddfc8a Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Thu May 4 13:01:38 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Thu May 4 13:01:38 2017 +0200 -- .../apache/commons/lang3/text/StrBuilder.java | 31 1 file changed, 31 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1375e931/src/main/java/org/apache/commons/lang3/text/StrBuilder.java -- diff --git a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java index e7401f3..cb0bf9d 100644 --- a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java +++ b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java @@ -2757,37 +2757,6 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build } } -//--- -///** -// * Gets a String version of the string builder by calling the internal -// * constructor of String by reflection. -// * -// * WARNING: You must not use the StrBuilder after calling this method -// * as the buffer is now shared with the String object. To ensure this, -// * the internal character array is set to null, so you will get -// * NullPointerExceptions on all method calls. -// * -// * @return the builder as a String -// */ -//public String toSharedString() { -//try { -//Constructor con = String.class.getDeclaredConstructor( -//new Class[] {int.class, int.class, char[].class}); -//con.setAccessible(true); -//char[] buffer = buf; -//buf = null; -//size = -1; -//nullText = null; -//return (String) con.newInstance( -//new Object[] {Integer.valueOf(0), Integer.valueOf(size), buffer}); -// -//} catch (Exception ex) { -//ex.printStackTrace(); -//throw new UnsupportedOperationException("StrBuilder.toSharedString is unsupported: " + ex.getMessage()); -//} -//} - -//--- /** * Checks the contents of this builder against another to see if they * contain the same character content ignoring case.
[2/3] [text] fix some javadoc typos
fix some javadoc typos Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/aa2a77ef Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/aa2a77ef Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/aa2a77ef Branch: refs/heads/master Commit: aa2a77effd4ddd21c382f98744ab899fb569f932 Parents: 1dd427b Author: Pascal SchumacherAuthored: Thu May 4 12:46:46 2017 +0200 Committer: Pascal Schumacher Committed: Thu May 4 12:49:00 2017 +0200 -- .../org/apache/commons/text/StrBuilder.java | 2 +- .../org/apache/commons/text/StrSubstitutor.java | 22 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/aa2a77ef/src/main/java/org/apache/commons/text/StrBuilder.java -- diff --git a/src/main/java/org/apache/commons/text/StrBuilder.java b/src/main/java/org/apache/commons/text/StrBuilder.java index bb6e55e..676a929 100644 --- a/src/main/java/org/apache/commons/text/StrBuilder.java +++ b/src/main/java/org/apache/commons/text/StrBuilder.java @@ -2615,7 +2615,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * changed on the tokenizer class, before retrieving the tokens. * * The returned tokenizer is linked to this builder. You may intermix - * calls to the buider and tokenizer within certain limits, however + * calls to the builder and tokenizer within certain limits, however * there is no synchronization. Once the tokenizer has been used once, * it must be {@link StrTokenizer#reset() reset} to pickup the latest * changes in the builder. For example: http://git-wip-us.apache.org/repos/asf/commons-text/blob/aa2a77ef/src/main/java/org/apache/commons/text/StrSubstitutor.java -- diff --git a/src/main/java/org/apache/commons/text/StrSubstitutor.java b/src/main/java/org/apache/commons/text/StrSubstitutor.java index 82a4e22..3cb4b9b 100644 --- a/src/main/java/org/apache/commons/text/StrSubstitutor.java +++ b/src/main/java/org/apache/commons/text/StrSubstitutor.java @@ -184,7 +184,7 @@ public class StrSubstitutor { /** * Replaces all the occurrences of variables in the given source object with - * their matching values from the map. This method allows to specifiy a + * their matching values from the map. This method allows to specify a * custom variable prefix and suffix * * @param the type of the values in the map @@ -960,7 +960,7 @@ public class StrSubstitutor { /** * Gets the variable prefix matcher currently in use. * - * The variable prefix is the characer or characters that identify the + * The variable prefix is the character or characters that identify the * start of a variable. This prefix is expressed in terms of a matcher * allowing advanced prefix matches. * @@ -973,7 +973,7 @@ public class StrSubstitutor { /** * Sets the variable prefix matcher currently in use. * - * The variable prefix is the characer or characters that identify the + * The variable prefix is the character or characters that identify the * start of a variable. This prefix is expressed in terms of a matcher * allowing advanced prefix matches. * @@ -1006,7 +1006,7 @@ public class StrSubstitutor { /** * Sets the variable prefix to use. * - * The variable prefix is the characer or characters that identify the + * The variable prefix is the character or characters that identify the * start of a variable. This method allows a string prefix to be easily set. * * @param prefix the prefix for variables, not null @@ -1025,7 +1025,7 @@ public class StrSubstitutor { /** * Gets the variable suffix matcher currently in use. * - * The variable suffix is the characer or characters that identify the + * The variable suffix is the character or characters that identify the * end of a variable. This suffix is expressed in terms of a matcher * allowing advanced suffix matches. * @@ -1038,7 +1038,7 @@ public class StrSubstitutor { /** * Sets the variable suffix matcher currently in use. * - * The variable suffix is the characer or characters that identify the + * The variable suffix is the character or characters that identify the * end of a variable. This suffix is expressed in terms of a matcher * allowing advanced suffix matches. * @@ -1057,7 +1057,7 @@ public class StrSubstitutor { /** * Sets the variable
[3/3] [text] StrBuilder: remove commented-out code
StrBuilder: remove commented-out code Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/d4890a89 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/d4890a89 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/d4890a89 Branch: refs/heads/master Commit: d4890a893e53c9bae1a20c19462ffbfeb78b79b9 Parents: aa2a77e Author: Pascal SchumacherAuthored: Thu May 4 13:01:00 2017 +0200 Committer: Pascal Schumacher Committed: Thu May 4 13:01:00 2017 +0200 -- .../org/apache/commons/text/StrBuilder.java | 31 1 file changed, 31 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/d4890a89/src/main/java/org/apache/commons/text/StrBuilder.java -- diff --git a/src/main/java/org/apache/commons/text/StrBuilder.java b/src/main/java/org/apache/commons/text/StrBuilder.java index 676a929..1eafba6 100644 --- a/src/main/java/org/apache/commons/text/StrBuilder.java +++ b/src/main/java/org/apache/commons/text/StrBuilder.java @@ -2716,37 +2716,6 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build } } -//--- -///** -// * Gets a String version of the string builder by calling the internal -// * constructor of String by reflection. -// * -// * WARNING: You must not use the StrBuilder after calling this method -// * as the buffer is now shared with the String object. To ensure this, -// * the internal character array is set to null, so you will get -// * NullPointerExceptions on all method calls. -// * -// * @return the builder as a String -// */ -//public String toSharedString() { -//try { -//Constructor con = String.class.getDeclaredConstructor( -//new Class[] {int.class, int.class, char[].class}); -//con.setAccessible(true); -//char[] buffer = buf; -//buf = null; -//size = -1; -//nullText = null; -//return (String) con.newInstance( -//new Object[] {Integer.valueOf(0), Integer.valueOf(size), buffer}); -// -//} catch (Exception ex) { -//ex.printStackTrace(); -//throw new UnsupportedOperationException("StrBuilder.toSharedString is unsupported: " + ex.getMessage()); -//} -//} - -//--- /** * Checks the contents of this builder against another to see if they * contain the same character content ignoring case.
[1/3] [text] use System.lineSeparator() instead of System.getProperty("line.separator")
Repository: commons-text Updated Branches: refs/heads/master 4d84a33e4 -> d4890a893 use System.lineSeparator() instead of System.getProperty("line.separator") Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/1dd427b4 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/1dd427b4 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/1dd427b4 Branch: refs/heads/master Commit: 1dd427b46a6f13fdf92eab328aa79b77a0dbc0cb Parents: 4d84a33 Author: Pascal SchumacherAuthored: Thu May 4 12:43:02 2017 +0200 Committer: Pascal Schumacher Committed: Thu May 4 12:43:02 2017 +0200 -- src/main/java/org/apache/commons/text/AlphabetConverter.java | 7 +-- src/main/java/org/apache/commons/text/StrBuilder.java| 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/1dd427b4/src/main/java/org/apache/commons/text/AlphabetConverter.java -- diff --git a/src/main/java/org/apache/commons/text/AlphabetConverter.java b/src/main/java/org/apache/commons/text/AlphabetConverter.java index a216305..dcc2eee 100644 --- a/src/main/java/org/apache/commons/text/AlphabetConverter.java +++ b/src/main/java/org/apache/commons/text/AlphabetConverter.java @@ -88,11 +88,6 @@ public final class AlphabetConverter { * Arrow constant, used for converting the object into a string. */ private static final String ARROW = " -> "; -/** - * Line separator, used for converting the object into a string. - */ -private static final String LINE_SEPARATOR = -System.getProperty("line.separator"); /** * Hidden constructor for alphabet converter. Used by static helper methods. @@ -284,7 +279,7 @@ public final class AlphabetConverter { : originalToEncoded.entrySet()) { sb.append(codePointToString(entry.getKey())) .append(ARROW) -.append(entry.getValue()).append(LINE_SEPARATOR); +.append(entry.getValue()).append(System.lineSeparator()); } return sb.toString(); http://git-wip-us.apache.org/repos/asf/commons-text/blob/1dd427b4/src/main/java/org/apache/commons/text/StrBuilder.java -- diff --git a/src/main/java/org/apache/commons/text/StrBuilder.java b/src/main/java/org/apache/commons/text/StrBuilder.java index a3bc429..bb6e55e 100644 --- a/src/main/java/org/apache/commons/text/StrBuilder.java +++ b/src/main/java/org/apache/commons/text/StrBuilder.java @@ -472,7 +472,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build */ public StrBuilder appendNewLine() { if (newLine == null) { -append(System.getProperty("line.separator")); +append(System.lineSeparator()); return this; } return append(newLine);
[3/3] [text] WordUtils: correct since javadoc tags
WordUtils: correct since javadoc tags Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/4d84a33e Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/4d84a33e Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/4d84a33e Branch: refs/heads/master Commit: 4d84a33e4aa0e72bce0047a059673d52a4e9a608 Parents: 8140c6a Author: Pascal SchumacherAuthored: Thu May 4 12:32:42 2017 +0200 Committer: Pascal Schumacher Committed: Thu May 4 12:32:42 2017 +0200 -- src/main/java/org/apache/commons/text/WordUtils.java | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/4d84a33e/src/main/java/org/apache/commons/text/WordUtils.java -- diff --git a/src/main/java/org/apache/commons/text/WordUtils.java b/src/main/java/org/apache/commons/text/WordUtils.java index f4a4c8e..7988822 100644 --- a/src/main/java/org/apache/commons/text/WordUtils.java +++ b/src/main/java/org/apache/commons/text/WordUtils.java @@ -29,7 +29,7 @@ import org.apache.commons.lang3.StringUtils; * An exception will not be thrown for a null input. * Each method documents its behaviour in more detail. * - * @since 1.0 + * @since 1.1 */ public class WordUtils { @@ -624,7 +624,6 @@ public class WordUtils { * @param str the String to get initials from, may be null * @return String of initial letters, null if null String input * @see #initials(String,char[]) - * @since 2.2 */ public static String initials(final String str) { return initials(str, null); @@ -654,7 +653,6 @@ public class WordUtils { * @param delimiters set of characters to determine words, null means whitespace * @return String of initial characters, null if null String input * @see #initials(String) - * @since 2.2 */ public static String initials(final String str, final char... delimiters) { if (StringUtils.isEmpty(str)) { @@ -704,7 +702,6 @@ public class WordUtils { * @param word The CharSequence to check, may be null * @param words The array of String words to search for, may be null * @return {@code true} if all search words are found, {@code false} otherwise - * @since 3.5 */ public static boolean containsAllWords(final CharSequence word, final CharSequence... words) { if (StringUtils.isEmpty(word) || ArrayUtils.isEmpty(words)) {
[1/3] [text] port changes from commons-lang WordUtils to commons-text WordUtils
Repository: commons-text Updated Branches: refs/heads/master 0b6a285bb -> 4d84a33e4 port changes from commons-lang WordUtils to commons-text WordUtils Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/c0f7877b Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/c0f7877b Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/c0f7877b Branch: refs/heads/master Commit: c0f7877b0e72b0b27fbd14c02da315e3247a2e95 Parents: 0b6a285 Author: Pascal SchumacherAuthored: Thu May 4 12:30:02 2017 +0200 Committer: Pascal Schumacher Committed: Thu May 4 12:30:02 2017 +0200 -- .../java/org/apache/commons/text/WordUtils.java | 36 +++- .../org/apache/commons/text/WordUtilsTest.java | 8 + 2 files changed, 28 insertions(+), 16 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/c0f7877b/src/main/java/org/apache/commons/text/WordUtils.java -- diff --git a/src/main/java/org/apache/commons/text/WordUtils.java b/src/main/java/org/apache/commons/text/WordUtils.java index 0cee2f6..f4a4c8e 100644 --- a/src/main/java/org/apache/commons/text/WordUtils.java +++ b/src/main/java/org/apache/commons/text/WordUtils.java @@ -16,10 +16,12 @@ */ package org.apache.commons.text; -import java.lang.reflect.Array; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + /** * Operations on Strings that contain words. * @@ -31,8 +33,6 @@ import java.util.regex.Pattern; */ public class WordUtils { -private static final int THIRTY_TWO = 32; - /** * WordUtils instances should NOT be constructed in * standard programming. Instead, the class should be used as @@ -108,7 +108,7 @@ public class WordUtils { * * * input - * wrapLenght + * wrapLength * newLineString * wrapLongWords * result @@ -189,7 +189,7 @@ public class WordUtils { * * * input - * wrapLenght + * wrapLength * newLineString * wrapLongWords * wrapOn @@ -280,18 +280,18 @@ public class WordUtils { return null; } if (newLineStr == null) { -newLineStr = System.getProperty("line.separator"); +newLineStr = System.lineSeparator(); } if (wrapLength < 1) { wrapLength = 1; } -if (wrapOn == null || wrapOn.length() == 0 || wrapOn.trim().length() == 0) { +if (StringUtils.isBlank(wrapOn)) { wrapOn = " "; } final Pattern patternToWrapOn = Pattern.compile(wrapOn); final int inputLineLength = str.length(); int offset = 0; -final StringBuilder wrappedLine = new StringBuilder(inputLineLength + THIRTY_TWO); +final StringBuilder wrappedLine = new StringBuilder(inputLineLength + 32); while (offset < inputLineLength) { int spaceToWrapAt = -1; @@ -301,8 +301,9 @@ public class WordUtils { if (matcher.start() == 0) { offset += matcher.end(); continue; +} else { +spaceToWrapAt = matcher.start() + offset; } -spaceToWrapAt = matcher.start(); } // only last line without leading spaces is left @@ -410,7 +411,7 @@ public class WordUtils { */ public static String capitalize(final String str, final char... delimiters) { final int delimLen = delimiters == null ? -1 : delimiters.length; -if (str == null || str.length() == 0 || delimLen == 0) { +if (StringUtils.isEmpty(str) || delimLen == 0) { return str; } final char[] buffer = str.toCharArray(); @@ -478,7 +479,7 @@ public class WordUtils { */ public static String capitalizeFully(String str, final char... delimiters) { final int delimLen = delimiters == null ? -1 : delimiters.length; -if (str == null || str.length() == 0 || delimLen == 0) { +if (StringUtils.isEmpty(str) || delimLen == 0) { return str; } str = str.toLowerCase(); @@ -533,7 +534,7 @@ public class WordUtils { */ public static String uncapitalize(final String str, final char... delimiters) { final int delimLen = delimiters == null ? -1 : delimiters.length; -if (str == null || str.length() == 0 || delimLen == 0) { +if (StringUtils.isEmpty(str) || delimLen == 0) { return str; } final char[] buffer =
[2/3] [text] checkstyle-suppressions.xml: also suppress MagicNumber warning for WordUitls
checkstyle-suppressions.xml: also suppress MagicNumber warning for WordUitls Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/8140c6a7 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/8140c6a7 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/8140c6a7 Branch: refs/heads/master Commit: 8140c6a7be164d03920734002febf5f763ad5bce Parents: c0f7877 Author: Pascal SchumacherAuthored: Thu May 4 12:31:15 2017 +0200 Committer: Pascal Schumacher Committed: Thu May 4 12:31:15 2017 +0200 -- checkstyle-suppressions.xml | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/8140c6a7/checkstyle-suppressions.xml -- diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml index bdf6ecf..687034d 100644 --- a/checkstyle-suppressions.xml +++ b/checkstyle-suppressions.xml @@ -52,4 +52,6 @@ + +
commons-io git commit: IO-367: Add convenience methods for copyToDirectory (closes #34, closes #18)
Repository: commons-io Updated Branches: refs/heads/master ffcbfdc80 -> bfd83b00e IO-367: Add convenience methods for copyToDirectory (closes #34, closes #18) based on patch supplied by James Sawle Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/bfd83b00 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/bfd83b00 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/bfd83b00 Branch: refs/heads/master Commit: bfd83b00eb5743ad4ad0d24957f84b61ef9f5f79 Parents: ffcbfdc Author: Pascal Schumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 21:02:29 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Mon May 1 17:03:54 2017 +0200 -- src/changes/changes.xml | 3 + .../java/org/apache/commons/io/FileUtils.java | 69 +++ .../apache/commons/io/FileUtilsTestCase.java| 89 3 files changed, 161 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/bfd83b00/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index bb4e37e..a395005 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -47,6 +47,9 @@ The type attribute can be add,update,fix,remove. + +Add convenience methods for copyToDirectory + Javadoc contradictory for FileFilterUtils.ageFileFilter(cutoff) and the filter it constructs: AgeFileFilter(cutoff) http://git-wip-us.apache.org/repos/asf/commons-io/blob/bfd83b00/src/main/java/org/apache/commons/io/FileUtils.java -- diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java index 51f82d7..10f39b9 100644 --- a/src/main/java/org/apache/commons/io/FileUtils.java +++ b/src/main/java/org/apache/commons/io/FileUtils.java @@ -1531,6 +1531,75 @@ public class FileUtils { } } +/** + * Copies a file or directory to within another directory preserving the file dates. + * + * This method copies the source file or directory, along all its contents, to a + * directory of the same name in the specified destination directory. + * + * The destination directory is created if it does not exist. + * If the destination directory did exist, then this method merges + * the source with the destination, with the source taking precedence. + * + * Note: This method tries to preserve the files' last + * modified date/times using {@link File#setLastModified(long)}, however + * it is not guaranteed that those operations will succeed. + * If the modification operation fails, no indication is provided. + * + * @param src an existing file or directory to copy, must not be {@code null} + * @param destDir the directory to place the copy in, must not be {@code null} + * + * @throws NullPointerException if source or destination is {@code null} + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @see #copyDirectoryToDirectory(File, File) + * @see #copyFileToDirectory(File, File) + * @since 2.6 + */ +public static void copyToDirectory(final File src, final File destDir) throws IOException { +if (src == null) { +throw new NullPointerException("Source must not be null"); +} +if (src.isFile()) { +copyFileToDirectory(src, destDir); +} else if (src.isDirectory()) { +copyDirectoryToDirectory(src, destDir); +} else { +throw new IOException("The source " + src + " does not exist"); +} +} + +/** + * Copies a files to a directory preserving each file's date. + * + * This method copies the contents of the specified source files + * to a file of the same name in the specified destination directory. + * The destination directory is created if it does not exist. + * If the destination file exists, then this method will overwrite it. + * + * Note: This method tries to preserve the file's last + * modified date/times using {@link File#setLastModified(long)}, however + * it is not guaranteed that the operation will succeed. + * If the modification operation fails, no indication is provided. + * + * @param srcs a existing files to copy, must not be {@code null} + * @param destDir the directory to place the copy in, must not be {@code null} + * + * @throws NullPointerException if source or de
[1/2] [lang] LANG-1307: Added getDigits method to StringUtils (closes #225)
Repository: commons-lang Updated Branches: refs/heads/master c8e648b92 -> 610caab59 LANG-1307: Added getDigits method to StringUtils (closes #225) Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/9b3257e4 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/9b3257e4 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/9b3257e4 Branch: refs/heads/master Commit: 9b3257e4d1a63e0a4d971a331eaf7b9a08d98040 Parents: c8e648b Author: Arshad Basha <arba...@paypal.com> Authored: Tue Jan 3 00:14:33 2017 +0530 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Mon May 1 11:05:45 2017 +0200 -- .../org/apache/commons/lang3/StringUtils.java | 36 .../apache/commons/lang3/StringUtilsTest.java | 11 ++ 2 files changed, 47 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9b3257e4/src/main/java/org/apache/commons/lang3/StringUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index bd660bc..6ab1118 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -7157,6 +7157,42 @@ public class StringUtils { } /** + * Checks if a String {@code str} contains Unicode digits, + * if yes then concatenate all the digits in {@code str} and return it as a String. + * + * An empty ("") String will be returned if no digits found in {@code str}. + * + * + * StringUtils.getDigits(null) = null + * StringUtils.getDigits("")= "" + * StringUtils.getDigits("abc") = "" + * StringUtils.getDigits("1000$") = "1000" + * StringUtils.getDigits("1123~45") = "12345" + * StringUtils.getDigits("(541) 754-3010") = "5417543010" + * StringUtils.getDigits("\u0967\u0968\u0969") = "\u0967\u0968\u0969" + * + * + * @param str the String to extract digits from, may be null + * @return String with only digits, + * or an empty ("") String if no digits found, + * or {@code null} String if {@code str} is null + */ +public static String getDigits(final String str) { +if (isEmpty(str)) { +return str; +} +final int sz = str.length(); +final StringBuilder strDigits = new StringBuilder(sz); +for (int i = 0; i < sz; i++) { +final char tempChar = str.charAt(i); +if (Character.isDigit(tempChar)) { +strDigits.append(tempChar); +} +} +return strDigits.toString(); +} + +/** * Checks if the CharSequence contains only whitespace. * * Whitespace is defined by {@link Character#isWhitespace(char)}. http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9b3257e4/src/test/java/org/apache/commons/lang3/StringUtilsTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java index b776b3b..3051b47 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java @@ -3206,4 +3206,15 @@ public class StringUtilsTest { assertNull(StringUtils.toCodePoints(null)); assertArrayEquals(ArrayUtils.EMPTY_INT_ARRAY, StringUtils.toCodePoints("")); } + +@Test +public void testGetDigits() { +assertEquals(null, StringUtils.getDigits(null)); +assertEquals("", StringUtils.getDigits("")); +assertEquals("", StringUtils.getDigits("abc")); +assertEquals("1000", StringUtils.getDigits("1000$")); +assertEquals("12345", StringUtils.getDigits("123password45")); +assertEquals("5417543010", StringUtils.getDigits("(541) 754-3010")); +assertEquals("\u0967\u0968\u0969", StringUtils.getDigits("\u0967\u0968\u0969")); +} }
[2/2] [lang] LANG-1307: Add getDigits method to StringUtils
LANG-1307: Add getDigits method to StringUtils add since javadoc tag and changes.xml entry Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/610caab5 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/610caab5 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/610caab5 Branch: refs/heads/master Commit: 610caab590fe224c02c8f509431f6428fe8e1063 Parents: 9b3257e Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Mon May 1 11:08:10 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Mon May 1 11:08:10 2017 +0200 -- src/changes/changes.xml | 1 + src/main/java/org/apache/commons/lang3/StringUtils.java | 1 + 2 files changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/610caab5/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index a679df8..6c3957a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,7 @@ The type attribute can be add,update,fix,remove. +Add a method in StringUtils to extract only digits out of input string Implement HashSetvBitSetTest using JMH Add JMH maven dependencies Add null filter to ReflectionToStringBuilder http://git-wip-us.apache.org/repos/asf/commons-lang/blob/610caab5/src/main/java/org/apache/commons/lang3/StringUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 6ab1118..cf398d1 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -7176,6 +7176,7 @@ public class StringUtils { * @return String with only digits, * or an empty ("") String if no digits found, * or {@code null} String if {@code str} is null + * @since 3.6 */ public static String getDigits(final String str) { if (isEmpty(str)) {
[lang] HashSetvBitSetTest: use diamond operator (closes #264)
Repository: commons-lang Updated Branches: refs/heads/master d61090ab6 -> c8e648b92 HashSetvBitSetTest: use diamond operator (closes #264) Use Java 7's diamond operator to make the code a tad more elegant, as done in the rest of the codebase. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/c8e648b9 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/c8e648b9 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/c8e648b9 Branch: refs/heads/master Commit: c8e648b92cc133a604b5e1f4da1ced943788e64b Parents: d61090a Author: Allon Mureinik <amure...@redhat.com> Authored: Sat Apr 29 10:37:40 2017 +0300 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sat Apr 29 10:48:41 2017 +0200 -- src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c8e648b9/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java index cafb298..97fe714 100644 --- a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java +++ b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java @@ -39,7 +39,7 @@ public class HashSetvBitSetTest { @Benchmark public int[] testHashSet() { -final HashSet toRemove = new HashSet(); +final HashSet toRemove = new HashSet<>(); int found = 0; for (int i = 0; i < numberOfElementsToCompute; i++) { toRemove.add(found++);
[lang] LANG-1256: Add JMH maven dependencies.
Repository: commons-lang Updated Branches: refs/heads/master 331d2f21f -> b7cc7a1c7 LANG-1256: Add JMH maven dependencies. fix checkstyle exclusion on older maven versions Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/b7cc7a1c Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/b7cc7a1c Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/b7cc7a1c Branch: refs/heads/master Commit: b7cc7a1c7ba803e37218e53825c8aa1534071796 Parents: 331d2f2 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Fri Apr 28 19:09:14 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Fri Apr 28 19:09:14 2017 +0200 -- pom.xml | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/b7cc7a1c/pom.xml -- diff --git a/pom.xml b/pom.xml index 0f842fc..35cf5b3 100644 --- a/pom.xml +++ b/pom.xml @@ -675,10 +675,14 @@ ${basedir}/checkstyle.xml ${basedir}/checkstyle-suppressions.xml - + + +src/main/java + src/test/java + true false @@ -704,10 +708,14 @@ ${basedir}/checkstyle.xml ${basedir}/checkstyle-suppressions.xml - + + +src/main/java + src/test/java + true false
[lang] LANG-1256: Add JMH maven dependencies.
Repository: commons-lang Updated Branches: refs/heads/master e685d847b -> 331d2f21f LANG-1256: Add JMH maven dependencies. do not run checksytle on classes generated by JMH remove unnecessary maven-compiler-plugin configuration from benchmark profile Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/331d2f21 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/331d2f21 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/331d2f21 Branch: refs/heads/master Commit: 331d2f21f96ea6d1197fd8fb0774109a8e9732b5 Parents: e685d84 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Fri Apr 28 18:34:29 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Fri Apr 28 18:34:29 2017 +0200 -- pom.xml | 24 +++- 1 file changed, 11 insertions(+), 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/331d2f21/pom.xml -- diff --git a/pom.xml b/pom.xml index 9b22eb3..0f842fc 100644 --- a/pom.xml +++ b/pom.xml @@ -675,6 +675,10 @@ ${basedir}/checkstyle.xml ${basedir}/checkstyle-suppressions.xml + + +src/test/java + true false @@ -700,6 +704,10 @@ ${basedir}/checkstyle.xml ${basedir}/checkstyle-suppressions.xml + + +src/test/java + true false @@ -872,22 +880,12 @@ true org.apache - -org.apache.maven.plugins -maven-compiler-plugin -3.1 - - ${maven.compiler.target} - ${maven.compiler.target} - ${maven.compiler.target} - - - org.codehaus.mojo exec-maven-plugin +1.6.0 benchmark @@ -914,6 +912,6 @@ - - + +
[2/2] [lang] LANG-1110: Implement HashSetvBitSetTest using JMH
LANG-1110: Implement HashSetvBitSetTest using JMH (side effect: closes #253, closes #191) Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/e685d847 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/e685d847 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/e685d847 Branch: refs/heads/master Commit: e685d847b4c70e354e47ea3990cefda3265aa5c6 Parents: 111fd3f Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Fri Apr 28 17:36:58 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Fri Apr 28 17:36:58 2017 +0200 -- src/changes/changes.xml | 2 + .../commons/lang3/HashSetvBitSetTest.java | 156 +-- 2 files changed, 41 insertions(+), 117 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e685d847/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index f4df009..a679df8 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,8 @@ The type attribute can be add,update,fix,remove. +Implement HashSetvBitSetTest using JMH +Add JMH maven dependencies Add null filter to ReflectionToStringBuilder LocaleUtils#toLocale does not support language followed by UN M.49 numeric-3 area code followed by variant Clarify or improve behaviour of int-based indexOf methods in StringUtils http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e685d847/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java index 994631f..cafb298 100644 --- a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java +++ b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java @@ -18,86 +18,63 @@ package org.apache.commons.lang3; import java.util.BitSet; import java.util.HashSet; +import java.util.concurrent.TimeUnit; -import org.junit.Assert; -import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; /** * Test to show whether using BitSet for removeAll() methods is faster than using HashSet. */ +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) public class HashSetvBitSetTest { -private static final int LOOPS = 2000; // number of times to invoke methods -private static final int LOOPS2 = 1; +private static final int numberOfElementsToCompute = 10; -@Test -public void testTimes() { -timeHashSet(10); // warmup -timeBitSet(10); // warmup -long timeDiff = printTimes(0); -timeDiff += printTimes(5); -timeDiff += printTimes(10); -timeDiff += printTimes(200); -timeDiff += printTimes(50); -timeDiff += printTimes(100); -timeDiff += printTimes(1000); -timeDiff += printTimes(2000); -Assert.assertTrue(timeDiff <= 0); -} - -/** - * @return bitSet - HashSet - */ -private long printTimes(final int count) { -final long hashSet = timeHashSet(count); -final long bitSet = timeBitSet(count); -// If percent is less than 100, then bitset is faster -System.out.println("Ratio="+(bitSet*100/hashSet)+"% count="+count+" hash="+hashSet+" bits="+bitSet); -return bitSet - hashSet; -} - -private static long timeHashSet(final int count) { -int [] result = new int[0]; -final long start = System.nanoTime(); -for (int i = 0; i < LOOPS; i++) { -result = testHashSet(count); -} -final long elapsed = System.nanoTime() - start; -Assert.assertEquals(count, result.length); -return elapsed; -} - -private static long timeBitSet(final int count) { -int [] result = new int[0]; -final long start = System.nanoTime(); -for (int i = 0; i < LOOPS; i++) { -result = testBitSet(count); +@Benchmark +public int[] testHashSet() { +final HashSet toRemove = new HashSet(); +int found = 0; +for (int i = 0; i < numberOfElementsToCompute; i++) { +toRemove.add(found++); } -final long elapsed = System.nanoTime() - start; -Assert.assertEquals
[1/2] [lang] LANG-1256: Add JMH maven dependencies. (closes #182)
Repository: commons-lang Updated Branches: refs/heads/master a060733e6 -> e685d847b LANG-1256: Add JMH maven dependencies. (closes #182) In order to provide patch for LANG-1110, required dependency on JMH lib. Current commit add benchmark profile and ability to run JMH based benchmark by executing "mvn test -P benchmark" command, moreover it's also possible to specify exact benchmark name by running "mvn test -P benchmark -Dbenchmark=benchmark.full.class.name". Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/111fd3f6 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/111fd3f6 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/111fd3f6 Branch: refs/heads/master Commit: 111fd3f6eef8e7d1641a42ce0cc56b92f2d75f4a Parents: a060733 Author: Artem Barger <ar...@bargr.net> Authored: Sat Aug 13 03:33:08 2016 +0300 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Fri Apr 28 17:30:46 2017 +0200 -- pom.xml | 70 +++- 1 file changed, 69 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/111fd3f6/pom.xml -- diff --git a/pom.xml b/pom.xml index bca6df4..9b22eb3 100644 --- a/pom.xml +++ b/pom.xml @@ -535,6 +535,21 @@ 3.4 test + + + org.openjdk.jmh + jmh-core + ${jmh.version} + test + + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + test + + @@ -580,6 +595,10 @@ 2.8 2.17 + + +1.17.4 +benchmarks @@ -846,6 +865,55 @@ -Xmx512m --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED - + + + benchmark + +true +org.apache + + + + + +org.apache.maven.plugins +maven-compiler-plugin +3.1 + + ${maven.compiler.target} + ${maven.compiler.target} + ${maven.compiler.target} + + + +org.codehaus.mojo +exec-maven-plugin + + +benchmark +test + + exec + + + test + java + +-classpath + +org.openjdk.jmh.Main +-rf +json +-rff +target/jmh-result.${benchmark}.json +${benchmark} + + + + + + + +
commons-io git commit: README.md: remove license badge, because github now displays the license at the top
Repository: commons-io Updated Branches: refs/heads/master a64b4cc53 -> ffcbfdc80 README.md: remove license badge, because github now displays the license at the top Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/ffcbfdc8 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/ffcbfdc8 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/ffcbfdc8 Branch: refs/heads/master Commit: ffcbfdc80ed7ca7ffce883f615f710beabd9e06c Parents: a64b4cc Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Fri Apr 28 16:43:27 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Fri Apr 28 16:43:27 2017 +0200 -- README.md | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/ffcbfdc8/README.md -- diff --git a/README.md b/README.md index c5da757..fc28d5f 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,6 @@ Apache Commons IO [![Build Status](https://travis-ci.org/apache/commons-io.svg?branch=master)](https://travis-ci.org/apache/commons-io) [![Coverage Status](https://coveralls.io/repos/github/apache/commons-io/badge.svg?branch=master)](https://coveralls.io/github/apache/commons-io?branch=master) -[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) The Apache Commons IO library contains utility classes, stream implementations, file filters, file comparators, endian transformation classes, and much more.
[text] README.md: remove license badge, because github now displays the license at the top
Repository: commons-text Updated Branches: refs/heads/master 1f5171efc -> f945dd26d README.md: remove license badge, because github now displays the license at the top Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/f945dd26 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/f945dd26 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/f945dd26 Branch: refs/heads/master Commit: f945dd26de832ee6bf925be13bda929932e301f1 Parents: 1f5171e Author: Pascal SchumacherAuthored: Fri Apr 28 16:40:30 2017 +0200 Committer: Pascal Schumacher Committed: Fri Apr 28 16:40:30 2017 +0200 -- README.md | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/f945dd26/README.md -- diff --git a/README.md b/README.md index ef228e8..15e0973 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,6 @@ Apache Commons Text [![Build Status](https://travis-ci.org/apache/commons-text.svg?branch=master)](https://travis-ci.org/apache/commons-text) [![Coverage Status](https://coveralls.io/repos/apache/commons-text/badge.svg?branch=master)](https://coveralls.io/r/apache/commons-text) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-text/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-text/) -[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) Apache Commons Text is a library focused on algorithms working on strings.
[3/4] [text] TEXT-81: Add RandomStringGenerator (closes #36)
TEXT-81: Add RandomStringGenerator (closes #36) add changes.xml entries for TEXT-81 and TEXT-36 fix checkstyle violations other minimal clean-up fix checkstyle Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/c72a24bc Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/c72a24bc Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/c72a24bc Branch: refs/heads/master Commit: c72a24bc24f2650a71bee0418b2ee3609f297cdc Parents: 8d14206 Author: Pascal SchumacherAuthored: Mon Apr 24 22:28:09 2017 +0200 Committer: Pascal Schumacher Committed: Fri Apr 28 16:26:36 2017 +0200 -- src/changes/changes.xml | 2 + .../commons/text/RandomStringGenerator.java | 106 --- .../apache/commons/text/TextRandomProvider.java | 4 +- .../commons/text/RandomStringGeneratorTest.java | 66 ++-- 4 files changed, 82 insertions(+), 96 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/c72a24bc/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index cd59174..91067bb 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,8 @@ The type attribute can be add,update,fix,remove. +Add RandomStringGenerator +RandomStringGenerator: allow users to provide source of randomness Correct round issue in Jaro Winkler implementation Similar to LANG-1025, clirr fails site build. http://git-wip-us.apache.org/repos/asf/commons-text/blob/c72a24bc/src/main/java/org/apache/commons/text/RandomStringGenerator.java -- diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java index 7eb45d9..ab7fd9d 100644 --- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java +++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java @@ -27,7 +27,12 @@ import java.util.concurrent.ThreadLocalRandom; * callers to define the properties of the generator. See the documentation for the * {@link Builder} class to see available properties. * - * + * + * // Generates a 20 code point string, using only the letters a-z + * RandomStringGenerator generator = new RandomStringGenerator.Builder() + * .withinRange('a', 'z').build(); + * String randomLetters = generator.generate(20); + * * * // Using Apache Commons RNG for randomness * UniformRandomProvider rng = RandomSource.create(...); @@ -36,14 +41,12 @@ import java.util.concurrent.ThreadLocalRandom; * .withinRange('a', 'z') * .usingRandom(rng::nextInt) // uses Java 8 syntax * .build(); - * String random = generator.generate(20); + * String randomLetters = generator.generate(20); * - * * * {@code RandomStringBuilder} instances are immutable and thread-safe. * - * - * @since 1.0 + * @since 1.1 */ public final class RandomStringGenerator { @@ -52,10 +55,9 @@ public final class RandomStringGenerator { private final Set inclusivePredicates; private final TextRandomProvider random; - /** * Constructs the generator. - * + * * @param minimumCodePoint *smallest allowed code point (inclusive) * @param maximumCodePoint @@ -72,12 +74,11 @@ public final class RandomStringGenerator { this.inclusivePredicates = inclusivePredicates; this.random = random; } - + /** - * Generates a random number within a range, using a - * {@link ThreadLocalRandom} instance or the user-supplied source of - * randomness. - * + * Generates a random number within a range, using a {@link ThreadLocalRandom} instance + * or the user-supplied source of randomness. + * * @param minInclusive *the minimum value allowed * @param maxInclusive @@ -88,11 +89,9 @@ public final class RandomStringGenerator { if (random != null) { return random.nextInt(maxInclusive - minInclusive + 1) + minInclusive; } - return ThreadLocalRandom.current().nextInt(minInclusive, maxInclusive + 1); } - /** * * Generates a random string, containing the specified number of code points. @@ -109,19 +108,17 @@ public final class RandomStringGenerator { * {@link Character} documentation to understand how Java stores Unicode * values. * - * + * * @param length *the number of code points to generate * @return the generated string * @throws
[2/4] [text] TEXT-81: Add RandomStringGenerator
TEXT-81: Add RandomStringGenerator Revert "TEXT-51: remove RandomStringGenerator for 1.0 release add again in 1.1" This reverts commit ba4e4932f0d864a15c94d32fb8c341e230d928df and restores RandomStringGenerator. Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/edb0676a Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/edb0676a Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/edb0676a Branch: refs/heads/master Commit: edb0676a3e40ff414c9c0047e3829b28a219d08f Parents: 66cf587 Author: Pascal SchumacherAuthored: Mon Apr 24 22:09:35 2017 +0200 Committer: Pascal Schumacher Committed: Fri Apr 28 16:25:34 2017 +0200 -- .../commons/text/RandomStringGenerator.java | 316 +++ .../commons/text/RandomStringGeneratorTest.java | 212 + 2 files changed, 528 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/edb0676a/src/main/java/org/apache/commons/text/RandomStringGenerator.java -- diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java new file mode 100644 index 000..c4411a2 --- /dev/null +++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java @@ -0,0 +1,316 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.commons.text; + +import java.util.HashSet; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.ThreadLocalRandom; + +/** + * + * Generates random Unicode strings containing the specified number of code points. + * Instances are created using a builder class, which allows the + * callers to define the properties of the generator. See the documentation for the + * {@link Builder} class to see available properties. + * + * + * + * // Generates a 20 code point string, using only the letters a-z + * RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange('a', 'z').build(); + * String random = generator.generate(20); + * + * + * + * {@code RandomStringBuilder} instances are immutable and thread-safe. + * + * + * @since 1.0 + */ +public final class RandomStringGenerator { + +private final int minimumCodePoint; +private final int maximumCodePoint; +private final Set inclusivePredicates; +private final Random random; + + +/** + * Constructs the generator. + * + * @param minimumCodePoint + *smallest allowed code point (inclusive) + * @param maximumCodePoint + *largest allowed code point (inclusive) + * @param inclusivePredicates + *filters for code points + * @param random + *source of randomness + */ +private RandomStringGenerator(int minimumCodePoint, int maximumCodePoint, +Set inclusivePredicates, Random random) { +this.minimumCodePoint = minimumCodePoint; +this.maximumCodePoint = maximumCodePoint; +this.inclusivePredicates = inclusivePredicates; +this.random = random; +} + +/** + * Generates a random number within a range, using a + * {@link ThreadLocalRandom} instance or the user-supplied source of + * randomness. + * + * @param minInclusive + *the minimum value allowed + * @param maxInclusive + *the maximum value allowed + * @return the random number. + */ +private int generateRandomNumber(final int minInclusive, final int maxInclusive) { +if (random != null) { +return random.nextInt(maxInclusive - minInclusive + 1) + minInclusive; +} + +return ThreadLocalRandom.current().nextInt(minInclusive, maxInclusive + 1); +} + + +/** + * + * Generates a random string, containing the specified number of code points. + * + * Code points are randomly
[4/4] [text] checkstyle.xml: do not require javadoc for private variables
checkstyle.xml: do not require javadoc for private variables Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/1f5171ef Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/1f5171ef Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/1f5171ef Branch: refs/heads/master Commit: 1f5171efc40e7a0ce28865ea705f77ebc9d7fd66 Parents: c72a24b Author: Pascal SchumacherAuthored: Mon Apr 24 23:16:44 2017 +0200 Committer: Pascal Schumacher Committed: Fri Apr 28 16:26:59 2017 +0200 -- checkstyle.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/1f5171ef/checkstyle.xml -- diff --git a/checkstyle.xml b/checkstyle.xml index 6afc1dd..e6cb6b2 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -94,7 +94,9 @@ - + + +
[1/4] [text] TEXT-36: RandomStringGenerator: allow users to provide source of randomness (closes #25)
Repository: commons-text Updated Branches: refs/heads/master 66cf58776 -> 1f5171efc TEXT-36: RandomStringGenerator: allow users to provide source of randomness (closes #25) Create functional interface to provide randomness for RandomStringGenerator Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/8d14206b Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/8d14206b Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/8d14206b Branch: refs/heads/master Commit: 8d14206b94631e5c78a51e1a319c7e7ad06e890a Parents: edb0676 Author: Ray DeCampoAuthored: Fri Jan 6 06:52:15 2017 -0500 Committer: Pascal Schumacher Committed: Fri Apr 28 16:25:34 2017 +0200 -- .../commons/text/RandomStringGenerator.java | 37 +++--- .../apache/commons/text/TextRandomProvider.java | 51 .../commons/text/RandomStringGeneratorTest.java | 8 ++- 3 files changed, 83 insertions(+), 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/8d14206b/src/main/java/org/apache/commons/text/RandomStringGenerator.java -- diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java index c4411a2..7eb45d9 100644 --- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java +++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java @@ -17,7 +17,6 @@ package org.apache.commons.text; import java.util.HashSet; -import java.util.Random; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; @@ -30,8 +29,13 @@ import java.util.concurrent.ThreadLocalRandom; * * * + * // Using Apache Commons RNG for randomness + * UniformRandomProvider rng = RandomSource.create(...); * // Generates a 20 code point string, using only the letters a-z - * RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange('a', 'z').build(); + * RandomStringGenerator generator = new RandomStringGenerator.Builder() + * .withinRange('a', 'z') + * .usingRandom(rng::nextInt) // uses Java 8 syntax + * .build(); * String random = generator.generate(20); * * @@ -46,7 +50,7 @@ public final class RandomStringGenerator { private final int minimumCodePoint; private final int maximumCodePoint; private final Set inclusivePredicates; -private final Random random; +private final TextRandomProvider random; /** @@ -62,7 +66,7 @@ public final class RandomStringGenerator { *source of randomness */ private RandomStringGenerator(int minimumCodePoint, int maximumCodePoint, -Set inclusivePredicates, Random random) { +Set inclusivePredicates, TextRandomProvider random) { this.minimumCodePoint = minimumCodePoint; this.maximumCodePoint = maximumCodePoint; this.inclusivePredicates = inclusivePredicates; @@ -168,7 +172,7 @@ public final class RandomStringGenerator { * The minimum and maximum code point values are defined using {@link #withinRange(int, int)}. The * default values are {@code 0} and {@link Character#MAX_CODE_POINT} respectively. * - * The source of randomness can be set using {@link #usingRandom(Random)}, otherwise {@link ThreadLocalRandom} + * The source of randomness can be set using {@link #usingRandom(TextRandomProvider) }, otherwise {@link ThreadLocalRandom} * is used. * * The type of code points returned can be filtered using {@link #filteredBy(CharacterPredicate...)}, @@ -207,7 +211,7 @@ public final class RandomStringGenerator { private int minimumCodePoint = DEFAULT_MINIMUM_CODE_POINT; private int maximumCodePoint = DEFAULT_MAXIMUM_CODE_POINT; private Set inclusivePredicates; -private Random random; +private TextRandomProvider random; /** @@ -286,8 +290,25 @@ public final class RandomStringGenerator { /** * - * Overrides the default source of randomness. + * Overrides the default source of randomness. It is highly + * recommended that a random number generator library like + * http://commons.apache.org/proper/commons-rng/;>Apache Commons RNG + * be used to provide the random number generation. * + * + * + * When using Java 8 or later, {@link TextRandomProvider} is a + * functional interface and need not be explicitly implemented: + * + * + * {@code + * UniformRandomProvider rng = RandomSource.create(...); + *
commons-io git commit: IOUtilsTestCase#testToByteArray_InputStream_NegativeSize: fix typo
Repository: commons-io Updated Branches: refs/heads/master 41a3e9c52 -> a64b4cc53 IOUtilsTestCase#testToByteArray_InputStream_NegativeSize: fix typo Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/a64b4cc5 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/a64b4cc5 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/a64b4cc5 Branch: refs/heads/master Commit: a64b4cc5329f2275a5513b12622863e99a803a24 Parents: 41a3e9c Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Tue Apr 25 21:06:46 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Tue Apr 25 21:06:46 2017 +0200 -- src/test/java/org/apache/commons/io/IOUtilsTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/a64b4cc5/src/test/java/org/apache/commons/io/IOUtilsTestCase.java -- diff --git a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java index 83870a8..4356467 100644 --- a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java @@ -904,7 +904,7 @@ public class IOUtilsTestCase extends FileBasedTestCase { try (FileInputStream fin = new FileInputStream(m_testFile)) { IOUtils.toByteArray(fin, -1); -fail("IllegalArgumentException excepted"); +fail("IllegalArgumentException expected"); } catch (final IllegalArgumentException exc) { assertTrue("Exception message does not start with \"Size must be equal or greater than zero\"", exc .getMessage().startsWith("Size must be equal or greater than zero"));
commons-io git commit: IOUtils#toByteArray: fix spelling of local variable name
Repository: commons-io Updated Branches: refs/heads/master 337828003 -> 41a3e9c52 IOUtils#toByteArray: fix spelling of local variable name Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/41a3e9c5 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/41a3e9c5 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/41a3e9c5 Branch: refs/heads/master Commit: 41a3e9c52d52f60d121ae99d281881a55e006bca Parents: 3378280 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Tue Apr 25 21:05:11 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Tue Apr 25 21:05:11 2017 +0200 -- src/main/java/org/apache/commons/io/IOUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/41a3e9c5/src/main/java/org/apache/commons/io/IOUtils.java -- diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java index 70caf4f..f4ccaf4 100644 --- a/src/main/java/org/apache/commons/io/IOUtils.java +++ b/src/main/java/org/apache/commons/io/IOUtils.java @@ -818,10 +818,10 @@ public class IOUtils { final byte[] data = new byte[size]; int offset = 0; -int readed; +int read; -while (offset < size && (readed = input.read(data, offset, size - offset)) != EOF) { -offset += readed; +while (offset < size && (read = input.read(data, offset, size - offset)) != EOF) { +offset += read; } if (offset != size) {
commons-io git commit: Correct error message in IOUtils (closes #35)
Repository: commons-io Updated Branches: refs/heads/master 156653ea5 -> 337828003 Correct error message in IOUtils (closes #35) This corrects the wording of the error message in IOUtils: There's no such word as "readed", and the author probably meant "expected" as opposed to "excepted". Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/33782800 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/33782800 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/33782800 Branch: refs/heads/master Commit: 3378280035f388157e007a06f7fcb74698b91e3e Parents: 156653e Author: Mark Raynsford <c...@io7m.com> Authored: Tue Apr 25 17:40:34 2017 + Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Tue Apr 25 21:00:25 2017 +0200 -- src/main/java/org/apache/commons/io/IOUtils.java | 2 +- src/test/java/org/apache/commons/io/IOUtilsTestCase.java | 8 2 files changed, 5 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/33782800/src/main/java/org/apache/commons/io/IOUtils.java -- diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java index daa9505..70caf4f 100644 --- a/src/main/java/org/apache/commons/io/IOUtils.java +++ b/src/main/java/org/apache/commons/io/IOUtils.java @@ -825,7 +825,7 @@ public class IOUtils { } if (offset != size) { -throw new IOException("Unexpected readed size. current: " + offset + ", excepted: " + size); +throw new IOException("Unexpected read size. current: " + offset + ", expected: " + size); } return data; http://git-wip-us.apache.org/repos/asf/commons-io/blob/33782800/src/test/java/org/apache/commons/io/IOUtilsTestCase.java -- diff --git a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java index a29a41e..83870a8 100644 --- a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java @@ -926,10 +926,10 @@ public class IOUtilsTestCase extends FileBasedTestCase { try (FileInputStream fin = new FileInputStream(m_testFile)) { IOUtils.toByteArray(fin, m_testFile.length() + 1); -fail("IOException excepted"); +fail("IOException expected"); } catch (final IOException exc) { -assertTrue("Exception message does not start with \"Unexpected readed size\"", -exc.getMessage().startsWith("Unexpected readed size")); +assertTrue("Exception message does not start with \"Unexpected read size\"", +exc.getMessage().startsWith("Unexpected read size")); } } @@ -938,7 +938,7 @@ public class IOUtilsTestCase extends FileBasedTestCase { try (FileInputStream fin = new FileInputStream(m_testFile)) { IOUtils.toByteArray(fin, (long) Integer.MAX_VALUE + 1); -fail("IOException excepted"); +fail("IOException expected"); } catch (final IllegalArgumentException exc) { assertTrue("Exception message does not start with \"Size cannot be greater than Integer max value\"", exc .getMessage().startsWith("Size cannot be greater than Integer max value"));
[text] fix some checkstyle voilations and remove their checkstyle-suppressions
Repository: commons-text Updated Branches: refs/heads/master c5863f4f9 -> 66cf58776 fix some checkstyle voilations and remove their checkstyle-suppressions Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/66cf5877 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/66cf5877 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/66cf5877 Branch: refs/heads/master Commit: 66cf58776ccc495f7710896b74060c15378cfac3 Parents: c5863f4 Author: Pascal SchumacherAuthored: Mon Apr 24 23:51:47 2017 +0200 Committer: Pascal Schumacher Committed: Mon Apr 24 23:51:47 2017 +0200 -- checkstyle-suppressions.xml | 5 - .../java/org/apache/commons/text/StrLookup.java | 1 + .../text/similarity/JaroWinklerDistance.java | 2 +- .../commons/text/translate/LookupTranslator.java | 18 +- 4 files changed, 11 insertions(+), 15 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/66cf5877/checkstyle-suppressions.xml -- diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml index d52e173..bdf6ecf 100644 --- a/checkstyle-suppressions.xml +++ b/checkstyle-suppressions.xml @@ -35,19 +35,14 @@ - - - - - http://git-wip-us.apache.org/repos/asf/commons-text/blob/66cf5877/src/main/java/org/apache/commons/text/StrLookup.java -- diff --git a/src/main/java/org/apache/commons/text/StrLookup.java b/src/main/java/org/apache/commons/text/StrLookup.java index 7c87670..d5abf43 100644 --- a/src/main/java/org/apache/commons/text/StrLookup.java +++ b/src/main/java/org/apache/commons/text/StrLookup.java @@ -173,6 +173,7 @@ public abstract class StrLookup { return System.getProperty(key); } catch (final SecurityException scex) { // Squelched. All lookup(String) will return null. +return null; } } return null; http://git-wip-us.apache.org/repos/asf/commons-text/blob/66cf5877/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java -- diff --git a/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java b/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java index f1c4d01..272b184 100644 --- a/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java +++ b/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java @@ -150,7 +150,7 @@ public class JaroWinklerDistance implements SimilarityScore { break; } } -return new int[] { matches, transpositions / 2, prefix, max.length() }; +return new int[] {matches, transpositions / 2, prefix, max.length()}; } } http://git-wip-us.apache.org/repos/asf/commons-text/blob/66cf5877/src/main/java/org/apache/commons/text/translate/LookupTranslator.java -- diff --git a/src/main/java/org/apache/commons/text/translate/LookupTranslator.java b/src/main/java/org/apache/commons/text/translate/LookupTranslator.java index 532c877..c4d5e2e 100644 --- a/src/main/java/org/apache/commons/text/translate/LookupTranslator.java +++ b/src/main/java/org/apache/commons/text/translate/LookupTranslator.java @@ -56,9 +56,9 @@ public class LookupTranslator extends CharSequenceTranslator { throw new InvalidParameterException("lookupMap cannot be null"); } this.lookupMap = new HashMap<>(); -prefixSet = new HashSet<>(); -int _shortest = Integer.MAX_VALUE; -int _longest = 0; +this.prefixSet = new HashSet<>(); +int currentShortest = Integer.MAX_VALUE; +int currentLongest = 0; Iterator > it = lookupMap.entrySet().iterator(); while (it.hasNext()) { @@ -66,15 +66,15 @@ public class LookupTranslator extends CharSequenceTranslator { this.lookupMap.put(pair.getKey().toString(), pair.getValue().toString()); this.prefixSet.add(pair.getKey().charAt(0)); final int sz = pair.getKey().length(); -if (sz < _shortest) { -_shortest = sz; +if (sz < currentShortest) { +currentShortest = sz; } -if (sz > _longest) { -_longest = sz; +if (sz > currentLongest) { +currentLongest = sz; }
commons-io git commit: IO-442: Javadoc contradictory for FileFilterUtils.ageFileFilter(cutoff) and the filter it constructs: AgeFileFilter(cutoff)
Repository: commons-io Updated Branches: refs/heads/master 872c74469 -> 156653ea5 IO-442: Javadoc contradictory for FileFilterUtils.ageFileFilter(cutoff) and the filter it constructs: AgeFileFilter(cutoff) correct FileFilterUtils.ageFileFilter(cutoff) javadoc Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/156653ea Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/156653ea Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/156653ea Branch: refs/heads/master Commit: 156653ea56fe215b97a263a770ea7094ff6adb84 Parents: 872c744 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 20:44:33 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 20:44:33 2017 +0200 -- src/changes/changes.xml | 3 +++ .../apache/commons/io/filefilter/FileFilterUtils.java | 12 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/156653ea/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 1247b0a..bb4e37e 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -47,6 +47,9 @@ The type attribute can be add,update,fix,remove. + +Javadoc contradictory for FileFilterUtils.ageFileFilter(cutoff) and the filter it constructs: AgeFileFilter(cutoff) + FileUtilTestCase.testForceDeleteDir() should not delete testDirectory parent http://git-wip-us.apache.org/repos/asf/commons-io/blob/156653ea/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java -- diff --git a/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java b/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java index 431bf2a..0326a40 100644 --- a/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java +++ b/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java @@ -518,8 +518,8 @@ public class FileFilterUtils { //--- /** - * Returns a filter that returns true if the file was last modified after - * the specified cutoff time. + * Returns a filter that returns true if the file was last modified before + * or at the specified cutoff time. * * @param cutoff the time threshold * @return an appropriately configured age file filter @@ -544,8 +544,8 @@ public class FileFilterUtils { } /** - * Returns a filter that returns true if the file was last modified after - * the specified cutoff date. + * Returns a filter that returns true if the file was last modified before + * or at the specified cutoff date. * * @param cutoffDate the time threshold * @return an appropriately configured age file filter @@ -570,8 +570,8 @@ public class FileFilterUtils { } /** - * Returns a filter that returns true if the file was last modified after - * the specified reference file. + * Returns a filter that returns true if the file was last modified before + * or at the same time as the specified reference file. * * @param cutoffReference the file whose last modification *time is used as the threshold age of the files
[1/3] commons-io git commit: use java 8 compatible clirr version and run clirr on travis
Repository: commons-io Updated Branches: refs/heads/master 8826617e8 -> 872c74469 use java 8 compatible clirr version and run clirr on travis Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/cdc90d71 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/cdc90d71 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/cdc90d71 Branch: refs/heads/master Commit: cdc90d71d93e6c55103779541886e423ee7276b1 Parents: 8826617 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 18:03:58 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 18:03:58 2017 +0200 -- .travis.yml | 2 +- pom.xml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/cdc90d71/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index 661c4a8..f689f55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ jdk: - oraclejdk8 script: - - mvn test apache-rat:check javadoc:javadoc + - mvn test apache-rat:check clirr:check javadoc:javadoc after_success: - mvn clean cobertura:cobertura coveralls:report http://git-wip-us.apache.org/repos/asf/commons-io/blob/cdc90d71/pom.xml -- diff --git a/pom.xml b/pom.xml index 2693e68..5241408 100644 --- a/pom.xml +++ b/pom.xml @@ -259,6 +259,8 @@ file comparators, endian transformation classes, and much more. site-content + +2.8
[3/3] commons-io git commit: Update checkstyle plugin version and remove no longer supported checkstyle module "RedundantThrows".
Update checkstyle plugin version and remove no longer supported checkstyle module "RedundantThrows". Make checkstyle run outside of the maven site lifecyle use checkstyle.xml. Enable checkstyle on travis-ci. Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/872c7446 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/872c7446 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/872c7446 Branch: refs/heads/master Commit: 872c744692dc2cd485e28790a1f532ca85ece2de Parents: d357d9d Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 18:37:24 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 18:37:24 2017 +0200 -- .travis.yml| 2 +- checkstyle.xml | 4 pom.xml| 12 +++- 3 files changed, 12 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/872c7446/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index f689f55..fd1f6f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ jdk: - oraclejdk8 script: - - mvn test apache-rat:check clirr:check javadoc:javadoc + - mvn test apache-rat:check clirr:check checkstyle:check javadoc:javadoc after_success: - mvn clean cobertura:cobertura coveralls:report http://git-wip-us.apache.org/repos/asf/commons-io/blob/872c7446/checkstyle.xml -- diff --git a/checkstyle.xml b/checkstyle.xml index bd420dd..b06c818 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -36,10 +36,6 @@ limitations under the License. - - - - http://git-wip-us.apache.org/repos/asf/commons-io/blob/872c7446/pom.xml -- diff --git a/pom.xml b/pom.xml index 5241408..6246c77 100644 --- a/pom.xml +++ b/pom.xml @@ -261,6 +261,7 @@ file comparators, endian transformation classes, and much more. site-content 2.8 +2.17 @@ -314,6 +315,15 @@ file comparators, endian transformation classes, and much more. org.apache.maven.plugins +maven-checkstyle-plugin +${checkstyle.plugin.version} + + ${basedir}/checkstyle.xml + false + + + +org.apache.maven.plugins maven-scm-publish-plugin @@ -334,7 +344,7 @@ file comparators, endian transformation classes, and much more. org.apache.maven.plugins maven-checkstyle-plugin -2.12.1 +${checkstyle.plugin.version} ${basedir}/checkstyle.xml false
[2/3] commons-io git commit: fix checkstyle violations by adding javadoc
fix checkstyle violations by adding javadoc Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/d357d9d5 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/d357d9d5 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/d357d9d5 Branch: refs/heads/master Commit: d357d9d563c4a34fa2ab3cdc68221c851a9de4f5 Parents: cdc90d7 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 18:33:45 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 18:33:45 2017 +0200 -- .../MessageDigestCalculatingInputStream.java| 15 + .../commons/io/input/ObservableInputStream.java | 32 ++-- .../commons/io/output/WriterOutputStream.java | 5 +++ 3 files changed, 50 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/d357d9d5/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java -- diff --git a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java index c360560..21d2d5c 100644 --- a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java +++ b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java @@ -31,9 +31,16 @@ import java.security.NoSuchAlgorithmException; */ public class MessageDigestCalculatingInputStream extends ObservableInputStream { +/** + * Maintains the message digest. + */ public static class MessageDigestMaintainingObserver extends Observer { private final MessageDigest md; +/** + * Creates an MessageDigestMaintainingObserver for the given MessageDigest. + * @param pMd the message digest to use + */ public MessageDigestMaintainingObserver(MessageDigest pMd) { md = pMd; } @@ -53,6 +60,8 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream { /** Creates a new instance, which calculates a signature on the given stream, * using the given {@link MessageDigest}. + * @param pStream the stream to calculate the message digest for + * @param pDigest the message digest to use */ public MessageDigestCalculatingInputStream(InputStream pStream, MessageDigest pDigest) { super(pStream); @@ -62,6 +71,9 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream { /** Creates a new instance, which calculates a signature on the given stream, * using a {@link MessageDigest} with the given algorithm. + * @param pStream the stream to calculate the message digest for + * @param pAlgorithm the name of the algorithm to use + * @throws NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation for the specified algorithm. */ public MessageDigestCalculatingInputStream(InputStream pStream, String pAlgorithm) throws NoSuchAlgorithmException { this(pStream, MessageDigest.getInstance(pAlgorithm)); @@ -69,6 +81,8 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream { /** Creates a new instance, which calculates a signature on the given stream, * using a {@link MessageDigest} with the "MD5" algorithm. + * @param pStream the stream to calculate the message digest for + * @throws NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation for the specified algorithm. */ public MessageDigestCalculatingInputStream(InputStream pStream) throws NoSuchAlgorithmException { this(pStream, MessageDigest.getInstance("MD5")); @@ -80,6 +94,7 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream { * This is probably not, what you expect. Make sure, that the complete data has been * read, if that is what you want. The easiest way to do so is by invoking * {@link #consume()}. + * @return the message digest used */ public MessageDigest getMessageDigest() { return messageDigest; http://git-wip-us.apache.org/repos/asf/commons-io/blob/d357d9d5/src/main/java/org/apache/commons/io/input/ObservableInputStream.java -- diff --git a/src/main/java/org/apache/commons/io/input/ObservableInputStream.java b/src/main/java/org/apache/commons/io/input/ObservableInputStream.java index a8dd078..bae3b46 100644 --- a/src/main/java/org/apache/commons/io/input/ObservableInputStream.java +++ b/src/main/java/org/apache/commons/io/input/Observabl
commons-io git commit: update commons-parent version to 42
Repository: commons-io Updated Branches: refs/heads/master 419ad3e4a -> 8826617e8 update commons-parent version to 42 Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/8826617e Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/8826617e Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/8826617e Branch: refs/heads/master Commit: 8826617e87982bdd0f5072f58ab21c12fdf57122 Parents: 419ad3e Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 17:36:22 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 17:36:47 2017 +0200 -- pom.xml | 2 +- src/site/resources/profile.clirr | 0 src/site/resources/profile.cobertura | 0 3 files changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/8826617e/pom.xml -- diff --git a/pom.xml b/pom.xml index 10c1df5..2693e68 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.apache.commons commons-parent -41 +42 4.0.0 commons-io http://git-wip-us.apache.org/repos/asf/commons-io/blob/8826617e/src/site/resources/profile.clirr -- diff --git a/src/site/resources/profile.clirr b/src/site/resources/profile.clirr new file mode 100644 index 000..e69de29 http://git-wip-us.apache.org/repos/asf/commons-io/blob/8826617e/src/site/resources/profile.cobertura -- diff --git a/src/site/resources/profile.cobertura b/src/site/resources/profile.cobertura new file mode 100644 index 000..e69de29
commons-io git commit: TailerTest: clean-up is done in tearDown so remove clean-up from individual test methods
Repository: commons-io Updated Branches: refs/heads/master 722a5af4f -> 5411db017 TailerTest: clean-up is done in tearDown so remove clean-up from individual test methods Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/5411db01 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/5411db01 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/5411db01 Branch: refs/heads/master Commit: 5411db017b093f0995a9b7807a6a4dabb0f1e0ea Parents: 722a5af Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 17:27:20 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 17:27:20 2017 +0200 -- .../org/apache/commons/io/input/TailerTest.java | 45 ++-- 1 file changed, 13 insertions(+), 32 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/5411db01/src/test/java/org/apache/commons/io/input/TailerTest.java -- diff --git a/src/test/java/org/apache/commons/io/input/TailerTest.java b/src/test/java/org/apache/commons/io/input/TailerTest.java index df16f45..db50efa 100644 --- a/src/test/java/org/apache/commons/io/input/TailerTest.java +++ b/src/test/java/org/apache/commons/io/input/TailerTest.java @@ -137,7 +137,7 @@ public class TailerTest extends FileBasedTestCase { out.close(); // ensure data is written final long testDelayMillis = delay * 10; -TestUtils.sleep(testDelayMillis); + TestUtils.sleep(testDelayMillis); List tailerlines = listener.getLines(); assertEquals("line count",lines.size(),tailerlines.size()); for(int i = 0,len = lines.size();i<len;i++){ @@ -149,8 +149,6 @@ public class TailerTest extends FileBasedTestCase { + "\nAct: (" + actual.length() + ") "+ actual); } } -} finally{ -tailer.stop(); } } @@ -161,30 +159,25 @@ public class TailerTest extends FileBasedTestCase { final File file = new File(getTestDirectory(), "tailer2-test.txt"); createFile(file, 0); final TestTailerListener listener = new TestTailerListener(); -final Tailer tailer = new Tailer(file, listener, delay, false); +tailer = new Tailer(file, listener, delay, false); final Thread thread = new Thread(tailer); thread.start(); // Write some lines to the file -try { -writeString(file, "Line"); +writeString(file, "Line"); -TestUtils.sleep(delay * 2); -List lines = listener.getLines(); -assertEquals("1 line count", 0, lines.size()); +TestUtils.sleep(delay * 2); +List lines = listener.getLines(); +assertEquals("1 line count", 0, lines.size()); -writeString(file, " one\n"); -TestUtils.sleep(delay * 2); -lines = listener.getLines(); +writeString(file, " one\n"); +TestUtils.sleep(delay * 2); +lines = listener.getLines(); -assertEquals("1 line count", 1, lines.size()); -assertEquals("1 line 1", "Line one", lines.get(0)); +assertEquals("1 line count", 1, lines.size()); +assertEquals("1 line 1", "Line one", lines.get(0)); -listener.clear(); -} finally { -tailer.stop(); -TestUtils.sleep(delay * 2); -} +listener.clear(); } @Test @@ -251,9 +244,6 @@ public class TailerTest extends FileBasedTestCase { assertEquals("Expected init to be called", 1 , listener.initialised); assertEquals("fileNotFound should not be called", 0 , listener.notFound); assertEquals("fileRotated should be be called", 1 , listener.rotated); -tailer.stop(); -tailer=null; - } @Test @@ -345,7 +335,6 @@ public class TailerTest extends FileBasedTestCase { tailer = Tailer.create(file, listener, delay, false); TestUtils.sleep(idle); tailer.stop(); -tailer=null; TestUtils.sleep(delay+idle); assertNull("Should not generate Exception", listener.exception); assertEquals("Expected init to be called", 1 , listener.initialised); @@ -365,13 +354,12 @@ public class TailerTest extends FileBasedTestCase { // Use a long delay to try to make sure the test thread calls interrupt() while the tailer thread is sleeping. final int delay = 1000; final
commons-io git commit: TrailerTest: replace usages of IOUtils#closeQuietly with try-with-resources statements
Repository: commons-io Updated Branches: refs/heads/master f5c46b9fc -> 722a5af4f TrailerTest: replace usages of IOUtils#closeQuietly with try-with-resources statements (side effects: close #7, close #21, close #20) Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/722a5af4 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/722a5af4 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/722a5af4 Branch: refs/heads/master Commit: 722a5af4f1786599f22e91a34af459883c7a6a8b Parents: f5c46b9 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 17:12:14 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 17:12:14 2017 +0200 -- .../org/apache/commons/io/input/TailerTest.java | 32 +--- 1 file changed, 7 insertions(+), 25 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/722a5af4/src/test/java/org/apache/commons/io/input/TailerTest.java -- diff --git a/src/test/java/org/apache/commons/io/input/TailerTest.java b/src/test/java/org/apache/commons/io/input/TailerTest.java index 5818f26..df16f45 100644 --- a/src/test/java/org/apache/commons/io/input/TailerTest.java +++ b/src/test/java/org/apache/commons/io/input/TailerTest.java @@ -125,11 +125,9 @@ public class TailerTest extends FileBasedTestCase { final Thread thread = new Thread(tailer); thread.start(); -Writer out = new OutputStreamWriter(new FileOutputStream(file), charsetUTF8); -BufferedReader reader = null; -try{ +try (Writer out = new OutputStreamWriter(new FileOutputStream(file), charsetUTF8); + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(origin), charsetUTF8))) { List lines = new ArrayList<>(); -reader = new BufferedReader(new InputStreamReader(new FileInputStream(origin), charsetUTF8)); String line; while((line = reader.readLine()) != null){ out.write(line); @@ -151,10 +149,8 @@ public class TailerTest extends FileBasedTestCase { + "\nAct: (" + actual.length() + ") "+ actual); } } -}finally{ +} finally{ tailer.stop(); -IOUtils.closeQuietly(reader); -IOUtils.closeQuietly(out); } } @@ -170,7 +166,6 @@ public class TailerTest extends FileBasedTestCase { thread.start(); // Write some lines to the file -final FileWriter writer = null; try { writeString(file, "Line"); @@ -189,7 +184,6 @@ public class TailerTest extends FileBasedTestCase { } finally { tailer.stop(); TestUtils.sleep(delay * 2); -IOUtils.closeQuietly(writer); } } @@ -298,12 +292,9 @@ public class TailerTest extends FileBasedTestCase { throw new IOException("Cannot create file " + file + " as the parent directory does not exist"); } -final BufferedOutputStream output = -new BufferedOutputStream(new FileOutputStream(file)); -try { +try (final BufferedOutputStream output = +new BufferedOutputStream(new FileOutputStream(file))) { TestUtils.generateTestData(output, size); -} finally { -IOUtils.closeQuietly(output); } // try to make sure file is found @@ -328,31 +319,22 @@ public class TailerTest extends FileBasedTestCase { /** Append some lines to a file */ private void write(final File file, final String... lines) throws Exception { -FileWriter writer = null; -try { -writer = new FileWriter(file, true); +try (FileWriter writer = new FileWriter(file, true)) { for (final String line : lines) { writer.write(line + "\n"); } -} finally { -IOUtils.closeQuietly(writer); } } /** Append a string to a file */ private void writeString(final File file, final String ... strings) throws Exception { -FileWriter writer = null; -try { -writer = new FileWriter(file, true); +try (FileWriter writer = new FileWriter(file, true)) { for (final String string : strings) { writer.write(string); } -} finally { -IOUtils.closeQuietly(writer); } } - @Test public void testStopWithNoFile() throws Exception { final File file = new File(getTestDirectory(),"nosuchfile");
commons-io git commit: FileUtilsTestCase: test directory is delete in tear down method, so remove clean up in individual tests
Repository: commons-io Updated Branches: refs/heads/master 46fc59ff1 -> f5c46b9fc FileUtilsTestCase: test directory is delete in tear down method, so remove clean up in individual tests Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/f5c46b9f Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/f5c46b9f Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/f5c46b9f Branch: refs/heads/master Commit: f5c46b9fc80754c601205e6ef13c5b7e9a5003e2 Parents: 46fc59f Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 16:16:35 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 16:16:35 2017 +0200 -- .../apache/commons/io/FileUtilsTestCase.java| 34 1 file changed, 13 insertions(+), 21 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/f5c46b9f/src/test/java/org/apache/commons/io/FileUtilsTestCase.java -- diff --git a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java index 949e87b..8f29835 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java @@ -763,23 +763,19 @@ public class FileUtilsTestCase extends FileBasedTestCase { // Tests with existing directory assertTrue(getTestDirectory().exists()); final File testParentDir = new File(getTestDirectory(), "testForceMkdirParent"); -try { -testParentDir.delete(); -assertFalse(testParentDir.exists()); -final File testFile = new File(testParentDir, "test.txt"); -assertFalse(testParentDir.exists()); -assertFalse(testFile.exists()); -// Create -FileUtils.forceMkdirParent(testFile); -assertTrue(testParentDir.exists()); -assertFalse(testFile.exists()); -// Again -FileUtils.forceMkdirParent(testFile); -assertTrue(testParentDir.exists()); -assertFalse(testFile.exists()); -} finally { -testParentDir.delete(); -} +testParentDir.delete(); +assertFalse(testParentDir.exists()); +final File testFile = new File(testParentDir, "test.txt"); +assertFalse(testParentDir.exists()); +assertFalse(testFile.exists()); +// Create +FileUtils.forceMkdirParent(testFile); +assertTrue(testParentDir.exists()); +assertFalse(testFile.exists()); +// Again +FileUtils.forceMkdirParent(testFile); +assertTrue(testParentDir.exists()); +assertFalse(testFile.exists()); } // sizeOfDirectory @@ -797,7 +793,6 @@ public class FileUtilsTestCase extends FileBasedTestCase { // Creates file file.createNewFile(); -file.deleteOnExit(); // Existing file try { @@ -2512,7 +2507,6 @@ public class FileUtilsTestCase extends FileBasedTestCase { assertTrue("Original deleted", !src.exists()); } - @Test public void testMoveFile_CopyDelete_Failed() throws Exception { final File destination = new File(getTestDirectory(), "move3.txt"); @@ -2599,7 +2593,6 @@ public class FileUtilsTestCase extends FileBasedTestCase { } catch (final FileExistsException e) { // expected } - } @Test @@ -2792,7 +2785,6 @@ public class FileUtilsTestCase extends FileBasedTestCase { } catch (final FileExistsException e) { // expected } - } @Test
commons-io git commit: run javadoc on travis
Repository: commons-io Updated Branches: refs/heads/master b5a2c343d -> 46fc59ff1 run javadoc on travis Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/46fc59ff Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/46fc59ff Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/46fc59ff Branch: refs/heads/master Commit: 46fc59ff1d9df4939c178ad749487bb5f5e7ab15 Parents: b5a2c34 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 12:53:49 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 12:53:49 2017 +0200 -- .travis.yml | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/46fc59ff/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index a969aba..661c4a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,5 +21,8 @@ jdk: - oraclejdk7 - oraclejdk8 +script: + - mvn test apache-rat:check javadoc:javadoc + after_success: - - mvn clean apache-rat:check cobertura:cobertura coveralls:report + - mvn clean cobertura:cobertura coveralls:report
commons-io git commit: FileUtils#listFiles: fix javadoc warnings
Repository: commons-io Updated Branches: refs/heads/master d675cd136 -> b5a2c343d FileUtils#listFiles: fix javadoc warnings Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/b5a2c343 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/b5a2c343 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/b5a2c343 Branch: refs/heads/master Commit: b5a2c343d52885dada56baa5c681b4c63533cf52 Parents: d675cd1 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 12:32:06 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 12:32:06 2017 +0200 -- src/main/java/org/apache/commons/io/FileUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/b5a2c343/src/main/java/org/apache/commons/io/FileUtils.java -- diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java index 24aa6f8..51f82d7 100644 --- a/src/main/java/org/apache/commons/io/FileUtils.java +++ b/src/main/java/org/apache/commons/io/FileUtils.java @@ -504,10 +504,10 @@ public class FileUtils { * * @param directory the directory to search in * @param fileFilter filter to apply when finding files. Must not be {@code null}, - * use {@link TrueFileFilter.INSTANCE} to match all files in selected directories. + * use {@link TrueFileFilter#INSTANCE} to match all files in selected directories. * @param dirFilter optional filter to apply when finding subdirectories. * If this parameter is {@code null}, subdirectories will not be included in the - * search. Use {@link TrueFileFilter.INSTANCE} to match all directories. + * search. Use {@link TrueFileFilter#INSTANCE} to match all directories. * @return a collection of java.io.File with the matching files * @see org.apache.commons.io.filefilter.FileFilterUtils * @see org.apache.commons.io.filefilter.NameFileFilter
commons-io git commit: FileUtilsTestCase: usage of IOUtils#closeQuietly with try-with-resources statements
Repository: commons-io Updated Branches: refs/heads/master f44180b97 -> d675cd136 FileUtilsTestCase: usage of IOUtils#closeQuietly with try-with-resources statements Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/d675cd13 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/d675cd13 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/d675cd13 Branch: refs/heads/master Commit: d675cd1362d502de0a94e0ff4d10e9c4ada579e4 Parents: f44180b Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 12:01:17 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 12:01:17 2017 +0200 -- .../apache/commons/io/FileUtilsTestCase.java| 77 1 file changed, 16 insertions(+), 61 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/d675cd13/src/test/java/org/apache/commons/io/FileUtilsTestCase.java -- diff --git a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java index 1e1dff7..949e87b 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java @@ -94,23 +94,17 @@ public class FileUtilsTestCase extends FileBasedTestCase { throw new IOException("Cannot create file " + testFile1 + " as the parent directory does not exist"); } -final BufferedOutputStream output3 = -new BufferedOutputStream(new FileOutputStream(testFile1)); -try { +try (final BufferedOutputStream output3 = +new BufferedOutputStream(new FileOutputStream(testFile1))) { TestUtils.generateTestData(output3, (long) testFile1Size); -} finally { -IOUtils.closeQuietly(output3); } if (!testFile2.getParentFile().exists()) { throw new IOException("Cannot create file " + testFile2 + " as the parent directory does not exist"); } -final BufferedOutputStream output2 = -new BufferedOutputStream(new FileOutputStream(testFile2)); -try { +try (final BufferedOutputStream output2 = +new BufferedOutputStream(new FileOutputStream(testFile2))) { TestUtils.generateTestData(output2, (long) testFile2Size); -} finally { -IOUtils.closeQuietly(output2); } FileUtils.deleteDirectory(getTestDirectory()); getTestDirectory().mkdirs(); @@ -118,23 +112,17 @@ public class FileUtilsTestCase extends FileBasedTestCase { throw new IOException("Cannot create file " + testFile1 + " as the parent directory does not exist"); } -final BufferedOutputStream output1 = -new BufferedOutputStream(new FileOutputStream(testFile1)); -try { +try (final BufferedOutputStream output1 = +new BufferedOutputStream(new FileOutputStream(testFile1))) { TestUtils.generateTestData(output1, (long) testFile1Size); -} finally { -IOUtils.closeQuietly(output1); } if (!testFile2.getParentFile().exists()) { throw new IOException("Cannot create file " + testFile2 + " as the parent directory does not exist"); } -final BufferedOutputStream output = -new BufferedOutputStream(new FileOutputStream(testFile2)); -try { +try (final BufferedOutputStream output = +new BufferedOutputStream(new FileOutputStream(testFile2))) { TestUtils.generateTestData(output, (long) testFile2Size); -} finally { -IOUtils.closeQuietly(output); } } @@ -216,12 +204,8 @@ public class FileUtilsTestCase extends FileBasedTestCase { public void test_openInputStream_exists() throws Exception { final File file = new File(getTestDirectory(), "test.txt"); TestUtils.createLineBasedFile(file, new String[]{"Hello"}); -FileInputStream in = null; -try { -in = FileUtils.openInputStream(file); +try (FileInputStream in = FileUtils.openInputStream(file)) { assertEquals('H', in.read()); -} finally { -IOUtils.closeQuietly(in); } } @@ -229,28 +213,20 @@ public class FileUtilsTestCase extends FileBasedTestCase { public void test_openInputStream_existsButIsDirectory() throws Exception { final File directory = ne
[1/2] commons-io git commit: IO-528: fix Tailer.run race condition runaway logging (closes #29)
Repository: commons-io Updated Branches: refs/heads/master 4b5fa7d8d -> f44180b97 IO-528: fix Tailer.run race condition runaway logging (closes #29) Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/45fbfb82 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/45fbfb82 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/45fbfb82 Branch: refs/heads/master Commit: 45fbfb82fd1f5168a7183e78ece89da7a60e21fe Parents: 4b5fa7d Author: Dave Moten <davidmo...@gmail.com> Authored: Wed Feb 1 14:54:00 2017 +1100 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 11:29:31 2017 +0200 -- src/main/java/org/apache/commons/io/input/Tailer.java | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/45fbfb82/src/main/java/org/apache/commons/io/input/Tailer.java -- diff --git a/src/main/java/org/apache/commons/io/input/Tailer.java b/src/main/java/org/apache/commons/io/input/Tailer.java index 999d397..9cb3887 100644 --- a/src/main/java/org/apache/commons/io/input/Tailer.java +++ b/src/main/java/org/apache/commons/io/input/Tailer.java @@ -446,6 +446,7 @@ public class Tailer implements Runnable { } catch (final FileNotFoundException e) { // in this case we continue to use the previous reader and position values listener.fileNotFound(); +Thread.sleep(delayMillis); } continue; } else {
[2/2] commons-io git commit: IO-528: fix Tailer.run race condition runaway logging
IO-528: fix Tailer.run race condition runaway logging add changes.xml entry Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/f44180b9 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/f44180b9 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/f44180b9 Branch: refs/heads/master Commit: f44180b972e3f881da8a3f981a1ca4f720e48125 Parents: 45fbfb8 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Apr 23 11:32:06 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Apr 23 11:32:06 2017 +0200 -- src/changes/changes.xml | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-io/blob/f44180b9/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index a953211..3994b6a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,7 +46,10 @@ The type attribute can be add,update,fix,remove. - + + +fix Tailer.run race condition runaway logging + getPrefixLength return -1 if unix file contains colon
[2/2] [lang] use Assert#assertFalse instead of Assert#assertTrue with a negated condition
use Assert#assertFalse instead of Assert#assertTrue with a negated condition Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/a060733e Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/a060733e Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/a060733e Branch: refs/heads/master Commit: a060733e63a9cc476342ca190d04ad027a241d33 Parents: d5be24a Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sat Apr 22 22:25:52 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sat Apr 22 22:25:52 2017 +0200 -- .../org/apache/commons/lang3/BitFieldTest.java | 12 +- .../lang3/builder/EqualsBuilderTest.java| 170 +-- .../exception/AbstractExceptionContextTest.java | 7 +- .../lang3/exception/ExceptionUtilsTest.java | 4 +- 4 files changed, 97 insertions(+), 96 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a060733e/src/test/java/org/apache/commons/lang3/BitFieldTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/BitFieldTest.java b/src/test/java/org/apache/commons/lang3/BitFieldTest.java index 0c80f5a..7d4ae9a 100644 --- a/src/test/java/org/apache/commons/lang3/BitFieldTest.java +++ b/src/test/java/org/apache/commons/lang3/BitFieldTest.java @@ -88,15 +88,15 @@ public class BitFieldTest { */ @Test public void testIsSet() { -assertTrue(!bf_multi.isSet(0)); -assertTrue(!bf_zero.isSet(0)); +assertFalse(bf_multi.isSet(0)); +assertFalse(bf_zero.isSet(0)); for (int j = 0x80; j <= 0x3F80; j += 0x80) { assertTrue(bf_multi.isSet(j)); } for (int j = 0x80; j <= 0x3F80; j += 0x80) { -assertTrue(!bf_zero.isSet(j)); +assertFalse(bf_zero.isSet(j)); } -assertTrue(!bf_single.isSet(0)); +assertFalse(bf_single.isSet(0)); assertTrue(bf_single.isSet(0x4000)); } @@ -106,11 +106,11 @@ public class BitFieldTest { @Test public void testIsAllSet() { for (int j = 0; j < 0x3F80; j += 0x80) { -assertTrue(!bf_multi.isAllSet(j)); +assertFalse(bf_multi.isAllSet(j)); assertTrue(bf_zero.isAllSet(j)); } assertTrue(bf_multi.isAllSet(0x3F80)); -assertTrue(!bf_single.isAllSet(0)); +assertFalse(bf_single.isAllSet(0)); assertTrue(bf_single.isAllSet(0x4000)); } http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a060733e/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java index bb7ca66..b5cfdfa 100644 --- a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java @@ -213,14 +213,14 @@ public class EqualsBuilderTest { final TestObject o1 = new TestObject(4); final TestObject o2 = new TestObject(5); assertTrue(EqualsBuilder.reflectionEquals(o1, o1)); -assertTrue(!EqualsBuilder.reflectionEquals(o1, o2)); +assertFalse(EqualsBuilder.reflectionEquals(o1, o2)); o2.setA(4); assertTrue(EqualsBuilder.reflectionEquals(o1, o2)); -assertTrue(!EqualsBuilder.reflectionEquals(o1, this)); +assertFalse(EqualsBuilder.reflectionEquals(o1, this)); -assertTrue(!EqualsBuilder.reflectionEquals(o1, null)); -assertTrue(!EqualsBuilder.reflectionEquals(null, o2)); +assertFalse(EqualsBuilder.reflectionEquals(o1, null)); +assertFalse(EqualsBuilder.reflectionEquals(null, o2)); assertTrue(EqualsBuilder.reflectionEquals(null, null)); } @@ -231,9 +231,9 @@ public class EqualsBuilderTest { // Transients assertTrue(EqualsBuilder.reflectionEquals(new TestTTLeafObject(1, 2, 3, 4), new TestTTLeafObject(1, 2, 3, 4), true)); assertTrue(EqualsBuilder.reflectionEquals(new TestTTLeafObject(1, 2, 3, 4), new TestTTLeafObject(1, 2, 3, 4), false)); -assertTrue(!EqualsBuilder.reflectionEquals(new TestTTLeafObject(1, 0, 0, 4), new TestTTLeafObject(1, 2, 3, 4), true)); -assertTrue(!EqualsBuilder.reflectionEquals(new TestTTLeafObject(1, 2, 3, 4), new TestTTLeafObject(1, 2, 3, 0), true)); -assertTrue(!EqualsBuilder.reflectionEquals(new TestTTLeafObject(0, 2, 3, 4), new TestTTLeafObject(1, 2, 3, 4), true)); +assertFalse(EqualsBuilder.reflectionEquals(new TestTTLeafObject(1, 0, 0, 4), n
[1/2] [lang] Use String#contains where possible (closes #263)
Repository: commons-lang Updated Branches: refs/heads/master 8cafd87c8 -> a060733e6 Use String#contains where possible (closes #263) Since the project defines a JDK 7 source compatibility, it's safe to use JDK 5's features. This patch replaces usages of String#indexOf with String#contains where possible to make the code easier to read and maintain. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/d5be24a1 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/d5be24a1 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/d5be24a1 Branch: refs/heads/master Commit: d5be24a12668a94712247d31f06ef7d416b8118c Parents: 8cafd87 Author: Allon Mureinik <amure...@redhat.com> Authored: Sat Apr 22 22:59:38 2017 +0300 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sat Apr 22 22:18:16 2017 +0200 -- .../ReflectionToStringBuilderExcludeTest.java | 4 +-- .../exception/AbstractExceptionContextTest.java | 24 +- .../lang3/exception/ContextedExceptionTest.java | 26 ++-- .../ContextedRuntimeExceptionTest.java | 26 ++-- .../lang3/exception/ExceptionUtilsTest.java | 8 +++--- 5 files changed, 44 insertions(+), 44 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/d5be24a1/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java index 75b80b2..c36d254 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java @@ -120,8 +120,8 @@ public class ReflectionToStringBuilderExcludeTest { } private void validateNonSecretField(final String toString) { -Assert.assertTrue(toString.indexOf(NOT_SECRET_FIELD) > ArrayUtils.INDEX_NOT_FOUND); -Assert.assertTrue(toString.indexOf(NOT_SECRET_VALUE) > ArrayUtils.INDEX_NOT_FOUND); +Assert.assertTrue(toString.contains(NOT_SECRET_FIELD)); +Assert.assertTrue(toString.contains(NOT_SECRET_VALUE)); } private void validateSecretFieldAbsent(final String toString) { http://git-wip-us.apache.org/repos/asf/commons-lang/blob/d5be24a1/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java index 6787bb5..85b5243 100644 --- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java @@ -63,13 +63,13 @@ public abstract class AbstractExceptionContextTest= 0); -assertTrue(message.indexOf("test1") >= 0); -assertTrue(message.indexOf("test2") >= 0); -assertTrue(message.indexOf("test Date") >= 0); -assertTrue(message.indexOf("test Nbr") >= 0); -assertTrue(message.indexOf("some value") >= 0); -assertTrue(message.indexOf("5") >= 0); +assertTrue(message.contains(TEST_MESSAGE)); +assertTrue(message.contains("test1")); +assertTrue(message.contains("test2")); +assertTrue(message.contains("test Date")); +assertTrue(message.contains("test Nbr")); +assertTrue(message.contains("some value")); +assertTrue(message.contains("5")); assertTrue(exceptionContext.getFirstContextValue("test1") == null); assertTrue(exceptionContext.getFirstContextValue("test2").equals("some value")); @@ -85,7 +85,7 @@ public abstract class AbstractExceptionContextTest= 0); -assertTrue(message.indexOf("test Poorly written obj") >= 0); -assertTrue(message.indexOf("Crap") >= 0); +assertTrue(message.contains(TEST_MESSAGE)); +assertTrue(message.contains("test Poorly written obj")); +assertTrue(message.contains("Crap")); assertTrue(exceptionContext.getFirstContextValue("crap") == null); assertTrue(exceptionContext.getFirstContextValue("test Poorly written obj&qu
[text] run findbugs on travis-ci
Repository: commons-text Updated Branches: refs/heads/master 0b8532b5b -> c5863f4f9 run findbugs on travis-ci Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/c5863f4f Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/c5863f4f Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/c5863f4f Branch: refs/heads/master Commit: c5863f4f9536e08da50a47f635500ea0b838bb08 Parents: 0b8532b Author: Pascal SchumacherAuthored: Sat Apr 22 15:47:18 2017 +0200 Committer: Pascal Schumacher Committed: Sat Apr 22 15:47:18 2017 +0200 -- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/c5863f4f/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index 8f4c08f..3c5ac3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ jdk: - oraclejdk8 script: - - mvn test apache-rat:check clirr:check checkstyle:check javadoc:javadoc + - mvn test apache-rat:check clirr:check checkstyle:check findbugs:check javadoc:javadoc after_success: - mvn clean test jacoco:report coveralls:report
[text] revert b0027e18d2e634e2a822962f6fbd3d296c82e722 "StrTokenizer#clone: add super.clone() call to fix findbug warning"
Repository: commons-text Updated Branches: refs/heads/master b0027e18d -> 0b8532b5b revert b0027e18d2e634e2a822962f6fbd3d296c82e722 "StrTokenizer#clone: add super.clone() call to fix findbug warning" use findbug version from commons-parent use fb-excludes when findbugs is run outside the site lifecyle Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/0b8532b5 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/0b8532b5 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/0b8532b5 Branch: refs/heads/master Commit: 0b8532b5bfcf8aedd303c2c0e97296a50d48fa1b Parents: b0027e1 Author: Pascal SchumacherAuthored: Sat Apr 22 15:45:12 2017 +0200 Committer: Pascal Schumacher Committed: Sat Apr 22 15:45:12 2017 +0200 -- pom.xml | 14 +++--- .../java/org/apache/commons/text/StrTokenizer.java| 1 - 2 files changed, 11 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/0b8532b5/pom.xml -- diff --git a/pom.xml b/pom.xml index c4d8e2c..eade4ce 100644 --- a/pom.xml +++ b/pom.xml @@ -176,6 +176,15 @@ +org.codehaus.mojo +findbugs-maven-plugin + +${commons.findbugs.version} + + ${basedir}/fb-excludes.xml + + + maven-assembly-plugin @@ -233,10 +242,9 @@ org.codehaus.mojo findbugs-maven-plugin -3.0.0 + +${commons.findbugs.version} - Normal - Default ${basedir}/fb-excludes.xml http://git-wip-us.apache.org/repos/asf/commons-text/blob/0b8532b5/src/main/java/org/apache/commons/text/StrTokenizer.java -- diff --git a/src/main/java/org/apache/commons/text/StrTokenizer.java b/src/main/java/org/apache/commons/text/StrTokenizer.java index b539268..66126ec 100644 --- a/src/main/java/org/apache/commons/text/StrTokenizer.java +++ b/src/main/java/org/apache/commons/text/StrTokenizer.java @@ -1088,7 +1088,6 @@ public class StrTokenizer implements ListIterator, Cloneable { @Override public Object clone() { try { -super.clone(); return cloneReset(); } catch (final CloneNotSupportedException ex) { return null;
[text] StrTokenizer#clone: add super.clone() call to fix findbug warning
Repository: commons-text Updated Branches: refs/heads/master 43b249b20 -> b0027e18d StrTokenizer#clone: add super.clone() call to fix findbug warning Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/b0027e18 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/b0027e18 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/b0027e18 Branch: refs/heads/master Commit: b0027e18d2e634e2a822962f6fbd3d296c82e722 Parents: 43b249b Author: Pascal SchumacherAuthored: Sat Apr 22 15:23:16 2017 +0200 Committer: Pascal Schumacher Committed: Sat Apr 22 15:23:16 2017 +0200 -- src/main/java/org/apache/commons/text/StrTokenizer.java | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/b0027e18/src/main/java/org/apache/commons/text/StrTokenizer.java -- diff --git a/src/main/java/org/apache/commons/text/StrTokenizer.java b/src/main/java/org/apache/commons/text/StrTokenizer.java index 66126ec..b539268 100644 --- a/src/main/java/org/apache/commons/text/StrTokenizer.java +++ b/src/main/java/org/apache/commons/text/StrTokenizer.java @@ -1088,6 +1088,7 @@ public class StrTokenizer implements ListIterator, Cloneable { @Override public Object clone() { try { +super.clone(); return cloneReset(); } catch (final CloneNotSupportedException ex) { return null;
[text] AlphabetConverter#createConverterFromMap: remove unused local variable
Repository: commons-text Updated Branches: refs/heads/master c9fd6cc68 -> 43b249b20 AlphabetConverter#createConverterFromMap: remove unused local variable Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/43b249b2 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/43b249b2 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/43b249b2 Branch: refs/heads/master Commit: 43b249b200b5bd901094207461b22144e2c1b56d Parents: c9fd6cc Author: Pascal SchumacherAuthored: Sat Apr 22 15:01:48 2017 +0200 Committer: Pascal Schumacher Committed: Sat Apr 22 15:01:48 2017 +0200 -- src/main/java/org/apache/commons/text/AlphabetConverter.java | 5 - 1 file changed, 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/43b249b2/src/main/java/org/apache/commons/text/AlphabetConverter.java -- diff --git a/src/main/java/org/apache/commons/text/AlphabetConverter.java b/src/main/java/org/apache/commons/text/AlphabetConverter.java index 27de69a..a216305 100644 --- a/src/main/java/org/apache/commons/text/AlphabetConverter.java +++ b/src/main/java/org/apache/commons/text/AlphabetConverter.java @@ -328,7 +328,6 @@ public final class AlphabetConverter { final Map unmodifiableOriginalToEncoded = Collections.unmodifiableMap(originalToEncoded); final Map encodedToOriginal = new LinkedHashMap<>(); -final Map doNotEncodeMap = new HashMap<>(); int encodedLetterLength = 1; @@ -337,10 +336,6 @@ public final class AlphabetConverter { final String originalAsString = codePointToString(e.getKey()); encodedToOriginal.put(e.getValue(), originalAsString); -if (e.getValue().equals(originalAsString)) { -doNotEncodeMap.put(e.getKey(), e.getValue()); -} - if (e.getValue().length() > encodedLetterLength) { encodedLetterLength = e.getValue().length(); }
[lang] LANG-1317: Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods
Repository: commons-lang Updated Branches: refs/heads/master 314b6b56b -> 8cafd87c8 LANG-1317: Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods fix bug introduced by last commit Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/8cafd87c Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/8cafd87c Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/8cafd87c Branch: refs/heads/master Commit: 8cafd87c83f4197f7e8d14de8cba453c844266c0 Parents: 314b6b5 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Fri Apr 21 10:53:17 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Fri Apr 21 10:53:17 2017 +0200 -- src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/8cafd87c/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java index 107f317..2855410 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java @@ -904,7 +904,7 @@ public class MethodUtils { Validate.isTrue(annotationCls != null, "The annotation class must not be null"); List<Class> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls) : new ArrayList<Class>()); -classes.add(cls); +classes.add(0, cls); final List annotatedMethods = new ArrayList<>(); for (Class acls : classes) { final Method[] methods = (ignoreAccess ? acls.getDeclaredMethods() : acls.getMethods());
[2/2] [lang] LANG-1317: Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods
LANG-1317: Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods Add changes.xml entry and minimal clean-up. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/314b6b56 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/314b6b56 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/314b6b56 Branch: refs/heads/master Commit: 314b6b56bec4af56dba667d66a25c1613f4bc800 Parents: 46007c1 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Fri Apr 21 10:45:03 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Fri Apr 21 10:45:03 2017 +0200 -- src/changes/changes.xml | 1 + .../commons/lang3/reflect/MethodUtils.java | 60 ++-- 2 files changed, 31 insertions(+), 30 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/314b6b56/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index e50441b..f4df009 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -85,6 +85,7 @@ The type attribute can be add,update,fix,remove. MethodUtils.invokeMethod throws ArrayStoreException if using varargs arguments and smaller types than the method defines Add ArchUtils - An utility class for the "os.arch" system property Add shuffle methods to ArrayUtils +Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods http://git-wip-us.apache.org/repos/asf/commons-lang/blob/314b6b56/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java index 55b5cb1..107f317 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java @@ -866,9 +866,9 @@ public class MethodUtils { * @param annotationCls *the {@link java.lang.annotation.Annotation} that must be present on a method to be matched * @param searchSupers - *determines if also a lookup in the entire inheritance hierarchy of the given class should be performed + *determines if a lookup in the entire inheritance hierarchy of the given class should be performed * @param ignoreAccess - *determines if also non public methods should be considered + *determines if non public methods should be considered * @return an array of Methods (possibly empty). * @throws IllegalArgumentException *if the class or annotation are {@code null} @@ -888,9 +888,9 @@ public class MethodUtils { * @param annotationCls *the {@link Annotation} that must be present on a method to be matched * @param searchSupers - *determines if also a lookup in the entire inheritance hierarchy of the given class should be performed + *determines if a lookup in the entire inheritance hierarchy of the given class should be performed * @param ignoreAccess - *determines if also non public methods should be considered + *determines if non public methods should be considered * @return a list of Methods (possibly empty). * @throws IllegalArgumentException *if the class or annotation are {@code null} @@ -904,7 +904,7 @@ public class MethodUtils { Validate.isTrue(annotationCls != null, "The annotation class must not be null"); List<Class> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls) : new ArrayList<Class>()); -classes.add(0, cls); +classes.add(cls); final List annotatedMethods = new ArrayList<>(); for (Class acls : classes) { final Method[] methods = (ignoreAccess ? acls.getDeclaredMethods() : acls.getMethods()); @@ -918,12 +918,12 @@ public class MethodUtils { } /** - * Gets the annotation object that is present on the given method or any equivalent method in - * super classes and interfaces, with the given annotation type. Returns null if the annotation - * type was not present on any of them. + * Gets the annotation object with the given annotation type that is present on the given method + * or optionally on any equivalent method in super classes and interf
[1/2] [lang] LANG-1317: Adds MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods (closes #261)
Repository: commons-lang Updated Branches: refs/heads/master 859224ffa -> 314b6b56b LANG-1317: Adds MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods (closes #261) Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/46007c15 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/46007c15 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/46007c15 Branch: refs/heads/master Commit: 46007c151e4cd79891eed4d289ff372ba39d5b8c Parents: 859224f Author: Yasser Zamani <yasser.zam...@live.com> Authored: Sun Mar 26 01:49:46 2017 +0430 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Fri Apr 21 10:44:41 2017 +0200 -- .../commons/lang3/reflect/MethodUtils.java | 158 ++- .../commons/lang3/reflect/MethodUtilsTest.java | 136 .../commons/lang3/reflect/testbed/Foo.java | 1 + .../commons/lang3/reflect/testbed/Parent.java | 7 + .../lang3/reflect/testbed/PublicChild.java | 16 ++ 5 files changed, 310 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/46007c15/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java index c6f9795..55b5cb1 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java @@ -830,7 +830,7 @@ public class MethodUtils { } /** - * Gets all methods of the given class that are annotated with the given annotation. + * Gets all class level public methods of the given class that are annotated with the given annotation. * @param cls *the {@link Class} to query * @param annotationCls @@ -841,12 +841,11 @@ public class MethodUtils { * @since 3.4 */ public static Method[] getMethodsWithAnnotation(final Class cls, final Class annotationCls) { -final List annotatedMethodsList = getMethodsListWithAnnotation(cls, annotationCls); -return annotatedMethodsList.toArray(new Method[annotatedMethodsList.size()]); +return getMethodsWithAnnotation(cls, annotationCls, false, false); } /** - * Gets all methods of the given class that are annotated with the given annotation. + * Gets all class level public methods of the given class that are annotated with the given annotation. * @param cls *the {@link Class} to query * @param annotationCls @@ -857,16 +856,159 @@ public class MethodUtils { * @since 3.4 */ public static List getMethodsListWithAnnotation(final Class cls, final Class annotationCls) { +return getMethodsListWithAnnotation(cls, annotationCls, false, false); +} + +/** + * Gets all methods of the given class that are annotated with the given annotation. + * @param cls + *the {@link Class} to query + * @param annotationCls + *the {@link java.lang.annotation.Annotation} that must be present on a method to be matched + * @param searchSupers + *determines if also a lookup in the entire inheritance hierarchy of the given class should be performed + * @param ignoreAccess + *determines if also non public methods should be considered + * @return an array of Methods (possibly empty). + * @throws IllegalArgumentException + *if the class or annotation are {@code null} + * @since 3.6 + */ +public static Method[] getMethodsWithAnnotation(final Class cls, final Class annotationCls, +boolean searchSupers, boolean ignoreAccess) { +final List annotatedMethodsList = getMethodsListWithAnnotation(cls, annotationCls, searchSupers, +ignoreAccess); +return annotatedMethodsList.toArray(new Method[annotatedMethodsList.size()]); +} + +/** + * Gets all methods of the given class that are annotated with the given annotation. + * @param cls + *the {@link Class} to query + * @param annotationCls + *the {@link Annotation} that must be present on a method to be matched + * @param searchSupers + *determines if also a lookup in the entire inheritance hierarchy of the given class should be performed + * @param ignoreAccess + *determines if also non public methods should be considered + * @return a list of Methods
[lang] LANG-1167: Add null filter to ReflectionToStringBuilder
Repository: commons-lang Updated Branches: refs/heads/master 0446364ff -> 859224ffa LANG-1167: Add null filter to ReflectionToStringBuilder Fix/add since javadoc tags, fix checkstyle violations and do other small clean-ups. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/859224ff Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/859224ff Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/859224ff Branch: refs/heads/master Commit: 859224ffadb79147088840732236c1fad341d842 Parents: 0446364 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Thu Apr 20 19:15:31 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Thu Apr 20 19:15:31 2017 +0200 -- .../lang3/builder/ReflectionToStringBuilder.java | 14 -- ...eflectionToStringBuilderExcludeNullValuesTest.java | 11 +++ 2 files changed, 15 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/859224ff/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java -- diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java index e315ed2..5e512d3 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java @@ -342,7 +342,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { *whether to include transient fields * @param outputStatics *whether to include static fields - * @param excludeNulls + * @param excludeNullValues *whether to exclude fields whose values are null * @param reflectUpToClass *the superclass to reflect up to (inclusive), may be null @@ -351,12 +351,12 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * if the Object is null * * @see ToStringExclude - * @since 2.1 + * @since 3.6 */ public static String toString( final T object, final ToStringStyle style, final boolean outputTransients, -final boolean outputStatics, boolean excludeNulls, final Class reflectUpToClass) { -return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics, excludeNulls) +final boolean outputStatics, boolean excludeNullValues, final Class reflectUpToClass) { +return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics, excludeNullValues) .toString(); } @@ -565,7 +565,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { *whether to include static fields * @param excludeNullValues *whether to exclude fields who value is null - * @since 2.1 + * @since 3.6 */ public ReflectionToStringBuilder( final T object, final ToStringStyle style, final StringBuffer buffer, @@ -641,7 +641,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { // Warning: Field.get(Object) creates wrappers objects // for primitive types. final Object fieldValue = this.getValue(field); -if(!excludeNullValues || fieldValue != null){ +if (!excludeNullValues || fieldValue != null) { this.append(fieldName, fieldValue); } } catch (final IllegalAccessException ex) { @@ -722,6 +722,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * * * @return Whether or not to append fields whose values are null. + * @since 3.6 */ public boolean isExcludeNullValues() { return this.excludeNullValues; @@ -773,6 +774,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * * @param excludeNullValues *Whether or not to append fields whose values are null. + * @since 3.6 */ public void setExcludeNullValues(final boolean excludeNullValues) { this.excludeNullValues = excludeNullValues; http://git-wip-us.apache.org/repos/asf/commons-lang/blob/859224ff/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValu
[lang] use Validate#isTrue to validate arguments
Repository: commons-lang Updated Branches: refs/heads/master 52d6e24d1 -> ff6b0ada7 use Validate#isTrue to validate arguments Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/ff6b0ada Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/ff6b0ada Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/ff6b0ada Branch: refs/heads/master Commit: ff6b0ada72106d67aef1ee21d51bacac2f3af7ac Parents: 52d6e24 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Wed Apr 19 21:07:05 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Wed Apr 19 21:07:05 2017 +0200 -- .../org/apache/commons/lang3/CharRange.java | 4 +- .../org/apache/commons/lang3/CharUtils.java | 12 +-- .../commons/lang3/SerializationUtils.java | 12 +-- .../org/apache/commons/lang3/ThreadUtils.java | 36 ++-- .../commons/lang3/builder/DiffBuilder.java | 93 ++-- .../commons/lang3/builder/DiffResult.java | 17 ++-- .../commons/lang3/builder/HashCodeBuilder.java | 5 +- .../builder/ReflectionToStringBuilder.java | 5 +- .../commons/lang3/builder/ToStringBuilder.java | 5 +- .../CallableBackgroundInitializer.java | 6 +- .../concurrent/MultiBackgroundInitializer.java | 12 +-- .../commons/lang3/exception/ExceptionUtils.java | 9 +- .../org/apache/commons/lang3/math/Fraction.java | 18 ++-- .../commons/lang3/math/IEEE754rUtils.java | 21 + .../apache/commons/lang3/math/NumberUtils.java | 4 +- .../apache/commons/lang3/time/DateUtils.java| 33 +++ 16 files changed, 86 insertions(+), 206 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/CharRange.java -- diff --git a/src/main/java/org/apache/commons/lang3/CharRange.java b/src/main/java/org/apache/commons/lang3/CharRange.java index 2ccda7c..bf82805 100644 --- a/src/main/java/org/apache/commons/lang3/CharRange.java +++ b/src/main/java/org/apache/commons/lang3/CharRange.java @@ -179,9 +179,7 @@ final class CharRange implements Iterable, Serializable { * @throws IllegalArgumentException if {@code null} input */ public boolean contains(final CharRange range) { -if (range == null) { -throw new IllegalArgumentException("The Range must not be null"); -} +Validate.isTrue(range != null, "The Range must not be null"); if (negated) { if (range.negated) { return start >= range.start && end <= range.end; http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/CharUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/CharUtils.java b/src/main/java/org/apache/commons/lang3/CharUtils.java index 92a8d44..bb45e5f 100644 --- a/src/main/java/org/apache/commons/lang3/CharUtils.java +++ b/src/main/java/org/apache/commons/lang3/CharUtils.java @@ -128,9 +128,7 @@ public class CharUtils { * @throws IllegalArgumentException if the Character is null */ public static char toChar(final Character ch) { -if (ch == null) { -throw new IllegalArgumentException("The Character must not be null"); -} +Validate.isTrue(ch != null, "The Character must not be null"); return ch.charValue(); } @@ -171,9 +169,7 @@ public class CharUtils { * @throws IllegalArgumentException if the String is empty */ public static char toChar(final String str) { -if (StringUtils.isEmpty(str)) { -throw new IllegalArgumentException("The String must not be empty"); -} +Validate.isTrue(StringUtils.isNotEmpty(str), "The String must not be empty"); return str.charAt(0); } @@ -261,9 +257,7 @@ public class CharUtils { * @throws IllegalArgumentException if the Character is not ASCII numeric or is null */ public static int toIntValue(final Character ch) { -if (ch == null) { -throw new IllegalArgumentException("The character must not be null"); -} +Validate.isTrue(ch != null, "The character must not be null"); return toIntValue(ch.charValue()); } http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/SerializationUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/SerializationUtils.java b/src/mai
[lang] use Validate#notNull instead of "throw new NullPointerException"
Repository: commons-lang Updated Branches: refs/heads/master 82cc24437 -> 52d6e24d1 use Validate#notNull instead of "throw new NullPointerException" Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/52d6e24d Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/52d6e24d Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/52d6e24d Branch: refs/heads/master Commit: 52d6e24d19465e6f468839650c969d5931f66d65 Parents: 82cc244 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Wed Apr 19 20:17:58 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Wed Apr 19 20:17:58 2017 +0200 -- .../java/org/apache/commons/lang3/ClassUtils.java | 5 ++--- .../java/org/apache/commons/lang3/ObjectUtils.java | 16 src/main/java/org/apache/commons/lang3/Range.java | 6 ++ .../lang3/concurrent/BasicThreadFactory.java | 17 + .../org/apache/commons/lang3/time/FormatCache.java | 6 +++--- 5 files changed, 16 insertions(+), 34 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/52d6e24d/src/main/java/org/apache/commons/lang3/ClassUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/ClassUtils.java b/src/main/java/org/apache/commons/lang3/ClassUtils.java index 012d2a6..60395ef 100644 --- a/src/main/java/org/apache/commons/lang3/ClassUtils.java +++ b/src/main/java/org/apache/commons/lang3/ClassUtils.java @@ -1053,9 +1053,8 @@ public class ClassUtils { */ private static String toCanonicalName(String className) { className = StringUtils.deleteWhitespace(className); -if (className == null) { -throw new NullPointerException("className must not be null."); -} else if (className.endsWith("[]")) { +Validate.notNull(className, "className must not be null."); +if (className.endsWith("[]")) { final StringBuilder classNameBuffer = new StringBuilder(); while (className.endsWith("[]")) { className = className.substring(0, className.length() - 2); http://git-wip-us.apache.org/repos/asf/commons-lang/blob/52d6e24d/src/main/java/org/apache/commons/lang3/ObjectUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java b/src/main/java/org/apache/commons/lang3/ObjectUtils.java index 2edd81f..13d1256 100644 --- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java +++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java @@ -353,9 +353,7 @@ public class ObjectUtils { * @since 3.2 */ public static void identityToString(final Appendable appendable, final Object object) throws IOException { -if (object == null) { -throw new NullPointerException("Cannot get the toString of a null identity"); -} +Validate.notNull(object, "Cannot get the toString of a null identity"); appendable.append(object.getClass().getName()) .append('@') .append(Integer.toHexString(System.identityHashCode(object))); @@ -379,9 +377,7 @@ public class ObjectUtils { */ @Deprecated public static void identityToString(final StrBuilder builder, final Object object) { -if (object == null) { -throw new NullPointerException("Cannot get the toString of a null identity"); -} +Validate.notNull(object, "Cannot get the toString of a null identity"); builder.append(object.getClass().getName()) .append('@') .append(Integer.toHexString(System.identityHashCode(object))); @@ -403,9 +399,7 @@ public class ObjectUtils { * @since 2.4 */ public static void identityToString(final StringBuffer buffer, final Object object) { -if (object == null) { -throw new NullPointerException("Cannot get the toString of a null identity"); -} +Validate.notNull(object, "Cannot get the toString of a null identity"); buffer.append(object.getClass().getName()) .append('@') .append(Integer.toHexString(System.identityHashCode(object))); @@ -427,9 +421,7 @@ public class ObjectUtils { * @since 3.2 */ public static void identityToString(final StringBuilder builder, final Object object) { -if (object == null) { -throw new NullPointerException("Cannot get the toString of a null identity"); -} +Validate.notNull(object, "
[3/6] [lang] Exclude SF_SWITCH_FALLTHROUGH on FastDatePrinter
Exclude SF_SWITCH_FALLTHROUGH on FastDatePrinter FastDatePrinter#appendFullDigits uses a switch statement that intentionally falls through the cases. This patch adds a FindBugs suppression for it. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/4d343ccc Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/4d343ccc Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/4d343ccc Branch: refs/heads/master Commit: 4d343ccc1181e306f8bb9431087ebb5e58b0c3c9 Parents: c40dcf6 Author: Allon Mureinik <amure...@redhat.com> Authored: Sat Apr 1 12:38:54 2017 +0300 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Wed Apr 19 18:24:57 2017 +0200 -- findbugs-exclude-filter.xml | 7 +++ 1 file changed, 7 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/4d343ccc/findbugs-exclude-filter.xml -- diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml index 772052a..edc6ead 100644 --- a/findbugs-exclude-filter.xml +++ b/findbugs-exclude-filter.xml @@ -150,6 +150,13 @@ + + + + + + +
[6/6] [lang] Add FindBugs to Travis CI (closes #262)
Add FindBugs to Travis CI (closes #262) This patch copies the FindBugs configuration in pom.xml from the reporting section to the build section so findbugs can be used as part of the build process (by using the maven goal findbugs:check). It then adds this goal to the Travis CI build so that FindBugs becomes part of the CI, and new patches would be prevented from introducing new FindBugs errors. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/9ceaaeb6 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/9ceaaeb6 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/9ceaaeb6 Branch: refs/heads/master Commit: 9ceaaeb6566c78b25da0ae8181964b13f09204a8 Parents: 9f7d03f Author: Allon Mureinik <amure...@redhat.com> Authored: Sat Apr 1 12:49:24 2017 +0300 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Wed Apr 19 18:25:04 2017 +0200 -- .travis.yml | 2 +- pom.xml | 9 + 2 files changed, 10 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9ceaaeb6/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index e81e8cd..f0a6c49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ jdk: - oraclejdk8 script: - - mvn test apache-rat:check clirr:check checkstyle:check javadoc:javadoc -B + - mvn test apache-rat:check clirr:check checkstyle:check findbugs:check javadoc:javadoc -B after_success: - mvn clean cobertura:cobertura coveralls:report http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9ceaaeb6/pom.xml -- diff --git a/pom.xml b/pom.xml index 8bea60c..bca6df4 100644 --- a/pom.xml +++ b/pom.xml @@ -660,6 +660,15 @@ false + +org.codehaus.mojo +findbugs-maven-plugin + +${commons.findbugs.version} + + ${basedir}/findbugs-exclude-filter.xml + +
[4/6] [lang] Exclude SF_SWITCH_NO_DEFAULT on FastDateParser
Exclude SF_SWITCH_NO_DEFAULT on FastDateParser FastDateParser#simpleQuote uses a switch case that actually has a default branch in it, but doesn't use break statements. SF_SWITCH_NO_DEFAULT unfortunately cannot recognize this pattern, and leave us with no choice but to suppress it. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/c40dcf65 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/c40dcf65 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/c40dcf65 Branch: refs/heads/master Commit: c40dcf659897edb26affa408c3fa62e80f906550 Parents: 3304965 Author: Allon Mureinik <amure...@redhat.com> Authored: Sat Apr 1 12:18:53 2017 +0300 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Wed Apr 19 18:24:57 2017 +0200 -- findbugs-exclude-filter.xml | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c40dcf65/findbugs-exclude-filter.xml -- diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml index f7623df..772052a 100644 --- a/findbugs-exclude-filter.xml +++ b/findbugs-exclude-filter.xml @@ -139,9 +139,14 @@ + - + + + +
[2/6] [lang] FindBugs exclude filter for StringUtils
FindBugs exclude filter for StringUtils Exclude ES_COMPARING_PARAMETER_STRING_WITH_EQ FindBugs warnings from StringUtils methods compare(String, String, boolean) and compareIgnoreCase(String, String, boolean). The usages of the == operator seem to be intentional optimizations similar to the usage in indexOfDifference. If this reasoning is ever overruled, this suppression should be removed. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/33049658 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/33049658 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/33049658 Branch: refs/heads/master Commit: 3304965840c139dae7b8c01e1779a806641a0159 Parents: 5a52446 Author: Allon Mureinik <amure...@redhat.com> Authored: Sat Apr 1 11:44:39 2017 +0300 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Wed Apr 19 18:24:57 2017 +0200 -- findbugs-exclude-filter.xml | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/33049658/findbugs-exclude-filter.xml -- diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml index def3ec8..f7623df 100644 --- a/findbugs-exclude-filter.xml +++ b/findbugs-exclude-filter.xml @@ -58,7 +58,11 @@ - + + + + +
[5/6] [lang] Add a default case to switch to appease FindBugs
Add a default case to switch to appease FindBugs Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/9f7d03f0 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/9f7d03f0 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/9f7d03f0 Branch: refs/heads/master Commit: 9f7d03f09172afcf0a7be40e3262d151ef053b3c Parents: 8069e1c Author: Allon Mureinik <amure...@redhat.com> Authored: Sat Apr 1 12:16:52 2017 +0300 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Wed Apr 19 18:24:58 2017 +0200 -- src/main/java/org/apache/commons/lang3/time/FastDateParser.java | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9f7d03f0/src/main/java/org/apache/commons/lang3/time/FastDateParser.java -- diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java index e27acf4..9cf1a1c 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java @@ -863,6 +863,8 @@ public class FastDateParser implements DateParser, Serializable { case 5: // offset 5 starts additional names, probably standard time tzInfo = standard; break; +default: +break; } if (zoneNames[i] != null) { final String key = zoneNames[i].toLowerCase(locale);
[1/6] [lang] Exclude SF_SWITCH_NO_DEFAULT on FastDatePrinter
Repository: commons-lang Updated Branches: refs/heads/master 5a5244609 -> 9ceaaeb65 Exclude SF_SWITCH_NO_DEFAULT on FastDatePrinter FastDatePrinter#appendFullDigits uses a switch case without break statements. SF_SWITCH_NO_DEFAULT unfortunately cannot recognize this pattern, and leave us with no choice but to suppress it. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/8069e1c1 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/8069e1c1 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/8069e1c1 Branch: refs/heads/master Commit: 8069e1c1ce7ec864c7bab2eae880742fac02376b Parents: 4d343cc Author: Allon Mureinik <amure...@redhat.com> Authored: Sat Apr 1 12:18:53 2017 +0300 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Wed Apr 19 18:24:57 2017 +0200 -- findbugs-exclude-filter.xml | 8 1 file changed, 8 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/8069e1c1/findbugs-exclude-filter.xml -- diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml index edc6ead..23dddbd 100644 --- a/findbugs-exclude-filter.xml +++ b/findbugs-exclude-filter.xml @@ -150,6 +150,14 @@ + + + + + + +
[text] index.xml: fix typo in apache license header
Repository: commons-text Updated Branches: refs/heads/master a6a2732ff -> c9fd6cc68 index.xml: fix typo in apache license header Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/c9fd6cc6 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/c9fd6cc6 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/c9fd6cc6 Branch: refs/heads/master Commit: c9fd6cc68d790890bb29a5d7e270751f78fe6ff1 Parents: a6a2732 Author: Pascal SchumacherAuthored: Tue Apr 18 23:32:56 2017 +0200 Committer: Pascal Schumacher Committed: Tue Apr 18 23:32:56 2017 +0200 -- src/site/xdoc/index.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/c9fd6cc6/src/site/xdoc/index.xml -- diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml index 0edbf88..ef34a5a 100644 --- a/src/site/xdoc/index.xml +++ b/src/site/xdoc/index.xml @@ -12,7 +12,7 @@ the License. You may obtain a copy of the License at 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 uage governing permissions and +See the License for the specific language governing permissions and limitations under the License. -->
[lang] LANG-1313: Add ArchUtils
Repository: commons-lang Updated Branches: refs/heads/master 30d4070af -> 5d3a2081c LANG-1313: Add ArchUtils add missing since javadoc tags Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/5d3a2081 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/5d3a2081 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/5d3a2081 Branch: refs/heads/master Commit: 5d3a2081c5a791f05811889e2b35e99c3b604731 Parents: 30d4070 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Mon Mar 27 21:59:42 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Mon Mar 27 21:59:42 2017 +0200 -- src/main/java/org/apache/commons/lang3/ArchUtils.java | 1 + src/main/java/org/apache/commons/lang3/arch/Processor.java| 1 + src/main/java/org/apache/commons/lang3/arch/package-info.java | 1 + 3 files changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/5d3a2081/src/main/java/org/apache/commons/lang3/ArchUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/ArchUtils.java b/src/main/java/org/apache/commons/lang3/ArchUtils.java index 41b770b..c7e28d9 100644 --- a/src/main/java/org/apache/commons/lang3/ArchUtils.java +++ b/src/main/java/org/apache/commons/lang3/ArchUtils.java @@ -28,6 +28,7 @@ import java.util.Map; * Important: The os.arch System Property returns the architecture used by the JVM * not of the operating system. * + * @since 3.6 */ public class ArchUtils { http://git-wip-us.apache.org/repos/asf/commons-lang/blob/5d3a2081/src/main/java/org/apache/commons/lang3/arch/Processor.java -- diff --git a/src/main/java/org/apache/commons/lang3/arch/Processor.java b/src/main/java/org/apache/commons/lang3/arch/Processor.java index e37b3f6..1d03a83 100644 --- a/src/main/java/org/apache/commons/lang3/arch/Processor.java +++ b/src/main/java/org/apache/commons/lang3/arch/Processor.java @@ -19,6 +19,7 @@ package org.apache.commons.lang3.arch; /** * The {@link Processor} represents a microprocessor and defines * some properties like architecture and type of the microprocessor. + * @since 3.6 */ public class Processor { http://git-wip-us.apache.org/repos/asf/commons-lang/blob/5d3a2081/src/main/java/org/apache/commons/lang3/arch/package-info.java -- diff --git a/src/main/java/org/apache/commons/lang3/arch/package-info.java b/src/main/java/org/apache/commons/lang3/arch/package-info.java index 9b832e3..0a60a81 100644 --- a/src/main/java/org/apache/commons/lang3/arch/package-info.java +++ b/src/main/java/org/apache/commons/lang3/arch/package-info.java @@ -16,5 +16,6 @@ */ /** * Provides classes to work with the values of the os.arch system property. + * @since 3.6 */ package org.apache.commons.lang3.arch; \ No newline at end of file
[3/3] [lang] Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/commons-lang
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/commons-lang Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/30d4070a Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/30d4070a Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/30d4070a Branch: refs/heads/master Commit: 30d4070af9fc623cf9723510bb46d1a19fcb5930 Parents: 46edb45 b06f13f Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Mon Mar 27 20:42:48 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Mon Mar 27 20:42:48 2017 +0200 -- .../org/apache/commons/lang3/ArrayUtils.java| 144 +-- .../org/apache/commons/lang3/StringUtils.java | 13 +- 2 files changed, 75 insertions(+), 82 deletions(-) --
[2/3] [lang] add changes.xml entry for LANG-1313
add changes.xml entry for LANG-1313 Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/46edb45d Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/46edb45d Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/46edb45d Branch: refs/heads/master Commit: 46edb45d3e7c3c0a3bf3e4e862f701f1a49ba73d Parents: 90f0a68 Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Mon Mar 27 20:39:47 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Mon Mar 27 20:41:07 2017 +0200 -- src/changes/changes.xml | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/46edb45d/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 78c3514..14f3ca4 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -81,6 +81,7 @@ The type attribute can be add,update,fix,remove. javadoc creation broken with Java 8 Deprecate classes/methods moved to commons-text MethodUtils.invokeMethod throws ArrayStoreException if using varargs arguments and smaller types than the method defines +Add ArchUtils - An utility class for the "os.arch" system property
[1/3] [lang] LANG-1313: Add ArchUtils - an utility class for the "os.arch" system property (closes #231)
Repository: commons-lang Updated Branches: refs/heads/master b06f13ff0 -> 30d4070af LANG-1313: Add ArchUtils - an utility class for the "os.arch" system property (closes #231) Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/90f0a680 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/90f0a680 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/90f0a680 Branch: refs/heads/master Commit: 90f0a680adf3eaa95e46e96d28ecd6848c74bfdd Parents: 1674c95 Author: Tomschi <toms...@users.noreply.github.com> Authored: Tue Mar 7 21:11:09 2017 +0100 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Mon Mar 27 20:40:28 2017 +0200 -- .../org/apache/commons/lang3/ArchUtils.java | 134 .../apache/commons/lang3/arch/Processor.java| 136 .../apache/commons/lang3/arch/package-info.java | 20 +++ .../org/apache/commons/lang3/ArchUtilsTest.java | 160 +++ 4 files changed, 450 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/90f0a680/src/main/java/org/apache/commons/lang3/ArchUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/ArchUtils.java b/src/main/java/org/apache/commons/lang3/ArchUtils.java new file mode 100644 index 000..41b770b --- /dev/null +++ b/src/main/java/org/apache/commons/lang3/ArchUtils.java @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.commons.lang3; + +import org.apache.commons.lang3.arch.Processor; + +import java.util.HashMap; +import java.util.Map; + +/** + * An utility class for the os.arch System Property. The class defines methods for + * identifying the architecture of the current JVM. + * + * Important: The os.arch System Property returns the architecture used by the JVM + * not of the operating system. + * + */ +public class ArchUtils { + +private static final Map<String, Processor> ARCH_TO_PROCESSOR; + +static { +ARCH_TO_PROCESSOR = new HashMap<>(); +init(); +} + +private static final void init() { +init_X86_32Bit(); +init_X86_64Bit(); +init_IA64_32Bit(); +init_IA64_64Bit(); +init_PPC_32Bit(); +init_PPC_64Bit(); +} + +private static final void init_X86_32Bit() { +Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.X86); +addProcessors(processor, "x86", "i386", "i486", "i586", "i686", "pentium"); +} + +private static final void init_X86_64Bit() { +Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.X86); +addProcessors(processor, "x86_64", "amd64", "em64t", "universal"); +} + +private static final void init_IA64_32Bit() { +Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.IA_64); +addProcessors(processor, "ia64_32", "ia64n"); +} + +private static final void init_IA64_64Bit() { +Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.IA_64); +addProcessors(processor, "ia64", "ia64w"); +} + +private static final void init_PPC_32Bit() { +Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.PPC); +addProcessors(processor, "ppc", "power", "powerpc", "power_pc", "power_rs"); +} + +private static final void init_PPC_64Bit() { +Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.PPC); +addProcessors(processor, "ppc64", "power64", "powerpc64", "power_pc64", "power_rs64"); +} + +/** + * Adds the given {@link Processor
[lang] Restore clirr report generation
Repository: commons-lang Updated Branches: refs/heads/master 4a300fee2 -> 1674c953f Restore clirr report generation Since commons-parent version 41, generation of the clirr report for the site has to be explicitly enabled by adding a "src\site\resources\profile.clirr" file. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/1674c953 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/1674c953 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/1674c953 Branch: refs/heads/master Commit: 1674c953fafe6438952d6290f30143aab22f33dd Parents: 4a300fe Author: pascalschumacher <pascalschumac...@gmx.net> Authored: Sun Mar 26 14:06:23 2017 +0200 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Mar 26 14:06:23 2017 +0200 -- src/site/resources/profile.clirr | 0 1 file changed, 0 insertions(+), 0 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1674c953/src/site/resources/profile.clirr -- diff --git a/src/site/resources/profile.clirr b/src/site/resources/profile.clirr new file mode 100644 index 000..e69de29
[lang] Fixed javadoc of MutableBoolean setTrue / setFalse (closes #260)
Repository: commons-lang Updated Branches: refs/heads/master 5d6c17638 -> 4a300fee2 Fixed javadoc of MutableBoolean setTrue / setFalse (closes #260) Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/4a300fee Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/4a300fee Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/4a300fee Branch: refs/heads/master Commit: 4a300fee2ef1c03902d0fb25ceb02aa01d0fab46 Parents: 5d6c176 Author: Tobias Soloschenko <tsolosche...@apache.org> Authored: Wed Mar 22 15:23:45 2017 +0100 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Wed Mar 22 17:32:14 2017 +0100 -- .../java/org/apache/commons/lang3/mutable/MutableBoolean.java| 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/4a300fee/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java -- diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java b/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java index 085df40..97781bf 100644 --- a/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java +++ b/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java @@ -90,7 +90,7 @@ public class MutableBoolean implements Mutable, Serializable, Comparabl } /** - * Sets the value to true. + * Sets the value to false. * * @since 3.3 */ @@ -99,7 +99,7 @@ public class MutableBoolean implements Mutable, Serializable, Comparabl } /** - * Sets the value to false. + * Sets the value to true. * * @since 3.3 */
[text] pom.xml: make site build use use clirr version defined in properties
Repository: commons-text Updated Branches: refs/heads/master 440d83bf1 -> b11451b26 pom.xml: make site build use use clirr version defined in properties Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/b11451b2 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/b11451b2 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/b11451b2 Branch: refs/heads/master Commit: b11451b26f5145000c71c2191aa306e911e6f12c Parents: 440d83b Author: Pascal SchumacherAuthored: Sun Mar 19 19:40:10 2017 +0100 Committer: Pascal Schumacher Committed: Sun Mar 19 19:40:10 2017 +0100 -- pom.xml | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/b11451b2/pom.xml -- diff --git a/pom.xml b/pom.xml index 8d54735..c4d8e2c 100644 --- a/pom.xml +++ b/pom.xml @@ -243,7 +243,6 @@ org.codehaus.mojo clirr-maven-plugin -2.8 info
[text] update clirr version to 2.8, which is java 8 compatible
Repository: commons-text Updated Branches: refs/heads/master 899edeb3b -> 440d83bf1 update clirr version to 2.8, which is java 8 compatible Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/440d83bf Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/440d83bf Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/440d83bf Branch: refs/heads/master Commit: 440d83bf15c07ed9cc7f815bbb1f4ec0165a4beb Parents: 899edeb Author: Pascal SchumacherAuthored: Sun Mar 19 19:36:14 2017 +0100 Committer: Pascal Schumacher Committed: Sun Mar 19 19:36:14 2017 +0100 -- pom.xml | 3 +++ 1 file changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/440d83bf/pom.xml -- diff --git a/pom.xml b/pom.xml index c339a6e..8d54735 100644 --- a/pom.xml +++ b/pom.xml @@ -139,6 +139,9 @@ 0.7.8 + +2.8 + 2.13
[3/3] [text] travis: run apache-rat, clirr, checkstyle and javadoc during the build
travis: run apache-rat, clirr, checkstyle and javadoc during the build Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/899edeb3 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/899edeb3 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/899edeb3 Branch: refs/heads/master Commit: 899edeb3b6b1ed2745f22677a80b61b7b03ca812 Parents: 2bd24ca Author: Pascal SchumacherAuthored: Sun Mar 19 19:28:21 2017 +0100 Committer: Pascal Schumacher Committed: Sun Mar 19 19:28:21 2017 +0100 -- .travis.yml | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/899edeb3/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index d51d8d8..8f4c08f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,5 +21,8 @@ jdk: - oraclejdk7 - oraclejdk8 +script: + - mvn test apache-rat:check clirr:check checkstyle:check javadoc:javadoc + after_success: - - mvn clean apache-rat:check test jacoco:report coveralls:report + - mvn clean test jacoco:report coveralls:report
[2/3] [text] pom.xml: make checkstyle plugin run-able outside of the site phase
pom.xml: make checkstyle plugin run-able outside of the site phase Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/2bd24caa Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/2bd24caa Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/2bd24caa Branch: refs/heads/master Commit: 2bd24caaf8629f94e7adb5c23f7477139828f385 Parents: cc9dc64 Author: Pascal SchumacherAuthored: Sun Mar 19 19:23:39 2017 +0100 Committer: Pascal Schumacher Committed: Sun Mar 19 19:23:39 2017 +0100 -- pom.xml | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/2bd24caa/pom.xml -- diff --git a/pom.xml b/pom.xml index 58ec51a..c339a6e 100644 --- a/pom.xml +++ b/pom.xml @@ -138,6 +138,8 @@ 0.7.8 + +2.13 @@ -160,6 +162,17 @@ +maven-checkstyle-plugin +${checkstyle.plugin.version} + + false + ${basedir}/checkstyle.xml + ${basedir}/license-header.txt + ${basedir}/checkstyle-suppressions.xml + ${basedir}/checkstyle-suppressions.xml + + + maven-assembly-plugin @@ -197,7 +210,7 @@ maven-checkstyle-plugin -2.13 +${checkstyle.plugin.version} false ${basedir}/checkstyle.xml
[1/3] [text] pox.xml: remove outdated comment about shading of commons-lang
Repository: commons-text Updated Branches: refs/heads/master 94ca2ca01 -> 899edeb3b pox.xml: remove outdated comment about shading of commons-lang Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/cc9dc64a Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/cc9dc64a Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/cc9dc64a Branch: refs/heads/master Commit: cc9dc64ac8d7b3dc629557187d0a9fcec44f03ee Parents: 94ca2ca Author: Pascal SchumacherAuthored: Sun Mar 19 17:57:55 2017 +0100 Committer: Pascal Schumacher Committed: Sun Mar 19 17:57:55 2017 +0100 -- pom.xml | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/commons-text/blob/cc9dc64a/pom.xml -- diff --git a/pom.xml b/pom.xml index cf03e86..58ec51a 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,6 @@ org.apache.commons commons-lang3 - 3.5
[1/2] [lang] LANG-1310: MethodUtils.invokeMethod throws ArrayStoreException if using varargs arguments and smaller types than the method defines (closes #256)
Repository: commons-lang Updated Branches: refs/heads/master 7ac12154b -> 5d6c17638 LANG-1310: MethodUtils.invokeMethod throws ArrayStoreException if using varargs arguments and smaller types than the method defines (closes #256) Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/1a20867d Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/1a20867d Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/1a20867d Branch: refs/heads/master Commit: 1a20867d01ef8ee5b32b0620125b7c38a10b80c5 Parents: 7ac1215 Author: drajakumar <drajaku...@paypal.com> Authored: Mon Mar 13 22:21:12 2017 +0530 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Sun Mar 19 17:12:16 2017 +0100 -- .../commons/lang3/reflect/MethodUtils.java | 14 + .../commons/lang3/reflect/MethodUtilsTest.java | 32 2 files changed, 40 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1a20867d/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java -- diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java index 0f94d93..4602378 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java @@ -700,6 +700,20 @@ public class MethodUtils { if (bestMatch != null) { MemberUtils.setAccessibleWorkaround(bestMatch); } + +if (bestMatch != null && bestMatch.isVarArgs() && bestMatch.getParameterTypes().length > 0 && parameterTypes.length > 0) { +final Class[] methodParameterTypes = bestMatch.getParameterTypes(); +final Class methodParameterComponentType = methodParameterTypes[methodParameterTypes.length - 1].getComponentType(); +final String methodParameterComponentTypeName = ClassUtils.primitiveToWrapper(methodParameterComponentType).getName(); +final String parameterTypeName = parameterTypes[parameterTypes.length - 1].getName(); +final String parameterTypeSuperClassName = parameterTypes[parameterTypes.length - 1].getSuperclass().getName(); + +if (!methodParameterComponentTypeName.equals(parameterTypeName) +&& !methodParameterComponentTypeName.equals(parameterTypeSuperClassName)) { +return null; +} +} + return bestMatch; } http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1a20867d/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java -- diff --git a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java index 351bed1..df57a13 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java @@ -96,6 +96,10 @@ public class MethodUtilsTest { return "bar(String...)"; } +public static String bar(final long... s) { +return "bar(long...)"; +} + public static String bar(final Integer i, final String... s) { return "bar(int, String...)"; } @@ -138,7 +142,6 @@ public class MethodUtilsTest { return "privateStringStuff(Object)"; } - public String foo() { return "foo()"; } @@ -155,6 +158,10 @@ public class MethodUtilsTest { return "foo(double)"; } +public String foo(final long l) { +return "foo(long)"; +} + public String foo(final String s) { return "foo(String)"; } @@ -167,6 +174,10 @@ public class MethodUtilsTest { return "foo(String...)"; } +public String foo(final long... l) { +return "foo(long...)"; +} + public String foo(final Integer i, final String... s) { return "foo(int, String...)"; } @@ -356,7 +367,7 @@ public class MethodUtilsTest { NumberUtils.INTEGER_ONE)); assertEquals("foo(int)", MethodUtils.invokeMethod(testBean, "foo", NumberUtils.BYTE_ONE)); -assertEquals("foo(double)", MethodUtils.invokeMethod(testBean, "foo", +assertEquals("foo(long)", MethodUtils.invokeMethod(