[text] TEXT-81: changes.xml syntax fix

2017-04-28 Thread chtompki
Repository: commons-text
Updated Branches:
  refs/heads/master f945dd26d -> c0dd79eca


TEXT-81: changes.xml syntax fix


Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/c0dd79ec
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/c0dd79ec
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/c0dd79ec

Branch: refs/heads/master
Commit: c0dd79ecad8861399a0e446a1229a3ddac994870
Parents: f945dd2
Author: Rob Tompkins 
Authored: Fri Apr 28 20:30:43 2017 -0400
Committer: Rob Tompkins 
Committed: Fri Apr 28 20:30:43 2017 -0400

--
 src/changes/changes.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/commons-text/blob/c0dd79ec/src/changes/changes.xml
--
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 91067bb..c862bf7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,7 +46,7 @@ The  type attribute can be add,update,fix,remove.
   
 
   
-Add 
RandomStringGenerator
+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.



[lang] LANG-1256: Add JMH maven dependencies.

2017-04-28 Thread pascalschumacher
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 
Authored: Fri Apr 28 19:09:14 2017 +0200
Committer: pascalschumacher 
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.

2017-04-28 Thread pascalschumacher
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 
Authored: Fri Apr 28 18:34:29 2017 +0200
Committer: pascalschumacher 
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

2017-04-28 Thread pascalschumacher
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 
Authored: Fri Apr 28 17:36:58 2017 +0200
Committer: pascalschumacher 
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(count, result.length);
-return elapsed;
+return 

[1/2] [lang] LANG-1256: Add JMH maven dependencies. (closes #182)

2017-04-28 Thread pascalschumacher
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 
Authored: Sat Aug 13 03:33:08 2016 +0300
Committer: pascalschumacher 
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

2017-04-28 Thread pascalschumacher
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 
Authored: Fri Apr 28 16:43:27 2017 +0200
Committer: pascalschumacher 
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

2017-04-28 Thread pascalschumacher
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 Schumacher 
Authored: 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)

2017-04-28 Thread pascalschumacher
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 Schumacher 
Authored: 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

2017-04-28 Thread pascalschumacher
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 Schumacher 
Authored: 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

2017-04-28 Thread pascalschumacher
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 Schumacher 
Authored: 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)

2017-04-28 Thread pascalschumacher
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 DeCampo 
Authored: 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(...);
+ *