You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/02/17 13:46:32 UTC

[1/9] [text] TEXT-65: 174 checkstyle errors

Repository: commons-text
Updated Branches:
  refs/heads/master 931fc7519 -> 40061c701


TEXT-65: 174 checkstyle errors


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

Branch: refs/heads/master
Commit: 1035cd6de87ece49aa2fdd7faa23e004e5748daf
Parents: c7cf533
Author: Rob Tompkins <ch...@apache.org>
Authored: Sat Feb 11 10:46:12 2017 -0500
Committer: Rob Tompkins <ch...@apache.org>
Committed: Sat Feb 11 10:46:12 2017 -0500

----------------------------------------------------------------------
 checkstyle-suppressions.xml                     |  6 ++-
 .../java/org/apache/commons/text/StrLookup.java |  1 +
 .../org/apache/commons/text/StrMatcher.java     |  8 ++--
 .../org/apache/commons/text/StrSubstitutor.java | 47 +++++++++++++-------
 4 files changed, 39 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/1035cd6d/checkstyle-suppressions.xml
----------------------------------------------------------------------
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
index f577e79..d6634e3 100644
--- a/checkstyle-suppressions.xml
+++ b/checkstyle-suppressions.xml
@@ -32,6 +32,8 @@
   <suppress checks="MagicNumber" files="JaroWinklerDistance.java" lines="0-99999" />
   <suppress checks="NoWhitespaceAfter" files="JaroWinklerDistance.java" lines="0-99999" />
   <suppress checks="FileLength" files="StrBuilder.java" lines="0-99999" />
-  <suppress checks="MagicNumber" files="StrBuilder.java" lines="0-99999"/>
-  <suppress checks="MagicNumber" files="StringEscapeUtils.java" lines="0-99999"/>
+  <suppress checks="MagicNumber" files="StrBuilder.java" lines="0-99999" />
+  <suppress checks="MagicNumber" files="StringEscapeUtils.java" lines="0-99999" />
+  <suppress checks="EmptyBlock" files="StrLookup.java" lines="0-99999" />
+  <suppress checks="MagicNumber" files="StrMatcher.java" lines="0-99999" />
 </suppressions>

http://git-wip-us.apache.org/repos/asf/commons-text/blob/1035cd6d/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 f9bffb5..7c87670 100644
--- a/src/main/java/org/apache/commons/text/StrLookup.java
+++ b/src/main/java/org/apache/commons/text/StrLookup.java
@@ -31,6 +31,7 @@ import java.util.Map;
  * For example, it would be possible to implement a lookup that used the
  * key as a primary key, and looked up the value on demand from the database
  *
+ * @param <V> the type of the values supported by the lookup
  * @since 1.0
  */
 public abstract class StrLookup<V> {

http://git-wip-us.apache.org/repos/asf/commons-text/blob/1035cd6d/src/main/java/org/apache/commons/text/StrMatcher.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/StrMatcher.java b/src/main/java/org/apache/commons/text/StrMatcher.java
index 97d6673..357118c 100644
--- a/src/main/java/org/apache/commons/text/StrMatcher.java
+++ b/src/main/java/org/apache/commons/text/StrMatcher.java
@@ -5,9 +5,9 @@
  * 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.
@@ -277,7 +277,7 @@ public abstract class StrMatcher {
          *
          * @param chars  the characters to match, must not be null
          */
-        CharSetMatcher(final char chars[]) {
+        CharSetMatcher(final char[] chars) {
             super();
             this.chars = chars.clone();
             Arrays.sort(this.chars);
@@ -371,7 +371,7 @@ public abstract class StrMatcher {
             }
             return len;
         }
-        
+
         @Override
         public String toString() {
             return super.toString() + ' ' + Arrays.toString(chars);

http://git-wip-us.apache.org/repos/asf/commons-text/blob/1035cd6d/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 00d05f7..82a4e22 100644
--- a/src/main/java/org/apache/commons/text/StrSubstitutor.java
+++ b/src/main/java/org/apache/commons/text/StrSubstitutor.java
@@ -152,7 +152,7 @@ public class StrSubstitutor {
      */
     private StrMatcher suffixMatcher;
     /**
-     * Stores the default variable value delimiter
+     * Stores the default variable value delimiter.
      */
     private StrMatcher valueDelimiterMatcher;
     /**
@@ -195,7 +195,10 @@ public class StrSubstitutor {
      * @return the result of the replace operation
      * @throws IllegalArgumentException if the prefix or suffix is null
      */
-    public static <V> String replace(final Object source, final Map<String, V> valueMap, final String prefix, final String suffix) {
+    public static <V> String replace(final Object source,
+                                     final Map<String, V> valueMap,
+                                     final String prefix,
+                                     final String suffix) {
         return new StrSubstitutor(valueMap, prefix, suffix).replace(source);
     }
 
@@ -211,10 +214,10 @@ public class StrSubstitutor {
         if (valueProperties == null) {
             return source.toString();
         }
-        final Map<String,String> valueMap = new HashMap<>();
+        final Map<String, String> valueMap = new HashMap<>();
         final Enumeration<?> propNames = valueProperties.propertyNames();
         while (propNames.hasMoreElements()) {
-            final String propName = (String)propNames.nextElement();
+            final String propName = (String) propNames.nextElement();
             final String propValue = valueProperties.getProperty(propName);
             valueMap.put(propName, propValue);
         }
@@ -390,7 +393,7 @@ public class StrSubstitutor {
             return null;
         }
         final StrBuilder buf = new StrBuilder(source);
-        if (substitute(buf, 0, source.length()) == false) {
+        if (!substitute(buf, 0, source.length())) {
             return source;
         }
         return buf.toString();
@@ -413,7 +416,7 @@ public class StrSubstitutor {
             return null;
         }
         final StrBuilder buf = new StrBuilder(length).append(source, offset, length);
-        if (substitute(buf, 0, length) == false) {
+        if (!substitute(buf, 0, length)) {
             return source.substring(offset, offset + length);
         }
         return buf.toString();
@@ -628,7 +631,7 @@ public class StrSubstitutor {
             return false;
         }
         final StrBuilder buf = new StrBuilder(length).append(source, offset, length);
-        if (substitute(buf, 0, length) == false) {
+        if (!substitute(buf, 0, length)) {
             return false;
         }
         source.replace(offset, offset + length, buf.toString());
@@ -669,7 +672,7 @@ public class StrSubstitutor {
             return false;
         }
         final StrBuilder buf = new StrBuilder(length).append(source, offset, length);
-        if (substitute(buf, 0, length) == false) {
+        if (!substitute(buf, 0, length)) {
             return false;
         }
         source.replace(offset, offset + length, buf.toString());
@@ -780,9 +783,11 @@ public class StrSubstitutor {
                     int nestedVarCount = 0;
                     while (pos < bufEnd) {
                         if (substitutionInVariablesEnabled
-                                && (endMatchLen = pfxMatcher.isMatch(chars,
-                                        pos, offset, bufEnd)) != 0) {
+                                && pfxMatcher.isMatch(chars,
+                                        pos, offset, bufEnd) != 0) {
                             // found a nested variable start
+                            endMatchLen = pfxMatcher.isMatch(chars,
+                                    pos, offset, bufEnd);
                             nestedVarCount++;
                             pos += endMatchLen;
                             continue;
@@ -813,12 +818,17 @@ public class StrSubstitutor {
                                     final char [] varNameExprChars = varNameExpr.toCharArray();
                                     int valueDelimiterMatchLen = 0;
                                     for (int i = 0; i < varNameExprChars.length; i++) {
-                                        // if there's any nested variable when nested variable substitution disabled, then stop resolving name and default value.
+                                        // if there's any nested variable when nested variable substitution disabled,
+                                        // then stop resolving name and default value.
                                         if (!substitutionInVariablesEnabled
-                                                && pfxMatcher.isMatch(varNameExprChars, i, i, varNameExprChars.length) != 0) {
+                                                && pfxMatcher.isMatch(varNameExprChars,
+                                                                        i,
+                                                                        i,
+                                                                        varNameExprChars.length) != 0) {
                                             break;
                                         }
-                                        if ((valueDelimiterMatchLen = valueDelimMatcher.isMatch(varNameExprChars, i)) != 0) {
+                                        if (valueDelimMatcher.isMatch(varNameExprChars, i) != 0) {
+                                            valueDelimiterMatchLen = valueDelimMatcher.isMatch(varNameExprChars, i);
                                             varName = varNameExpr.substring(0, i);
                                             varDefaultValue = varNameExpr.substring(i + valueDelimiterMatchLen);
                                             break;
@@ -884,7 +894,7 @@ public class StrSubstitutor {
      * @param priorVariables  the list of prior variables
      */
     private void checkCyclicSubstitution(final String varName, final List<String> priorVariables) {
-        if (priorVariables.contains(varName) == false) {
+        if (!priorVariables.contains(varName)) {
             return;
         }
         final StrBuilder buf = new StrBuilder(256);
@@ -912,7 +922,10 @@ public class StrSubstitutor {
      * @param endPos  the end position of the variable including the suffix, valid
      * @return the variable's value or <b>null</b> if the variable is unknown
      */
-    protected String resolveVariable(final String variableName, final StrBuilder buf, final int startPos, final int endPos) {
+    protected String resolveVariable(final String variableName,
+                                     final StrBuilder buf,
+                                     final int startPos,
+                                     final int endPos) {
         final StrLookup<?> resolver = getVariableResolver();
         if (resolver == null) {
             return null;
@@ -1189,7 +1202,7 @@ public class StrSubstitutor {
     /**
      * Returns the flag controlling whether escapes are preserved during
      * substitution.
-     * 
+     *
      * @return the preserve escape flag
      */
     public boolean isPreserveEscapes() {
@@ -1204,7 +1217,7 @@ public class StrSubstitutor {
      * character is removed during substitution (e.g.
      * <code>$${this-is-escaped}</code> becomes
      * <code>${this-is-escaped}</code>).  The default value is <b>false</b>
-     * 
+     *
      * @param preserveEscapes true if escapes are to be preserved
      */
     public void setPreserveEscapes(final boolean preserveEscapes) {


[4/9] [text] TEXT-65: 3 TODO checkstyle errors

Posted by ch...@apache.org.
TEXT-65: 3 TODO checkstyle errors


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

Branch: refs/heads/master
Commit: 0900a4c91cece58e6d14faeb92507c544a731df1
Parents: 3e07584
Author: Rob Tompkins <ch...@apache.org>
Authored: Tue Feb 14 20:55:14 2017 -0500
Committer: Rob Tompkins <ch...@apache.org>
Committed: Tue Feb 14 20:55:14 2017 -0500

----------------------------------------------------------------------
 checkstyle-suppressions.xml                             |  4 ++++
 .../commons/text/translate/NumericEntityUnescaper.java  |  2 +-
 .../apache/commons/text/translate/UnicodeEscaper.java   | 12 ++++++++----
 .../apache/commons/text/translate/UnicodeUnescaper.java | 11 ++++++-----
 .../text/translate/UnicodeUnpairedSurrogateRemover.java |  2 +-
 5 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/0900a4c9/checkstyle-suppressions.xml
----------------------------------------------------------------------
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
index cc03b22..d52e173 100644
--- a/checkstyle-suppressions.xml
+++ b/checkstyle-suppressions.xml
@@ -53,4 +53,8 @@
   <suppress checks="MagicNumber" files="NumericEntityUnescaper.java" lines="0-99999" />
 
   <suppress checks="MagicNumber" files="OctalUnescaper.java" lines="0-99999" />
+
+  <suppress checks="MagicNumber" files="UnicodeEscaper.java" lines="0-99999" />
+
+  <suppress checks="MagicNumber" files="UnicodeUnescaper.java" lines="0-99999" />
 </suppressions>

http://git-wip-us.apache.org/repos/asf/commons-text/blob/0900a4c9/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java b/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
index 42b38ef..6060cf8 100644
--- a/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
+++ b/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
@@ -35,7 +35,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
     public static enum OPTION { semiColonRequired, semiColonOptional, errorIfNoSemiColon }
 
     /** EnumSet of OPTIONS, given from the constructor. */
-    // TODO?: Create an OptionsSet class to hide some of the conditional logic below
+    // TODO: Create an OptionsSet class to hide some of the conditional logic below
     private final EnumSet<OPTION> options;
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-text/blob/0900a4c9/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java b/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java
index 04b24e2..8fba4b4 100644
--- a/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java
+++ b/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java
@@ -26,14 +26,18 @@ import java.io.Writer;
  */
 public class UnicodeEscaper extends CodePointTranslator {
 
+    /** int value representing the lowest codepoint boundary. */
     private final int below;
+    /** int value representing the highest codepoint boundary. */
     private final int above;
+    /** whether to escape between the boundaries or outside them. */
     private final boolean between;
 
     /**
-     * <p>Constructs a <code>UnicodeEscaper</code> for all characters. </p>
+     * <p>Constructs a <code>UnicodeEscaper</code> for all characters.
+     * </p>
      */
-    public UnicodeEscaper(){
+    public UnicodeEscaper() {
         this(0, Integer.MAX_VALUE, true);
     }
 
@@ -124,8 +128,8 @@ public class UnicodeEscaper extends CodePointTranslator {
     }
 
     /**
-     * Converts the given codepoint to a hex string of the form {@code "\\uXXXX"}
-     * 
+     * Converts the given codepoint to a hex string of the form {@code "\\uXXXX"}.
+     *
      * @param codepoint
      *            a Unicode code point
      * @return the hex string for the given codepoint

http://git-wip-us.apache.org/repos/asf/commons-text/blob/0900a4c9/src/main/java/org/apache/commons/text/translate/UnicodeUnescaper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/UnicodeUnescaper.java b/src/main/java/org/apache/commons/text/translate/UnicodeUnescaper.java
index 3a91d6c..1665d91 100644
--- a/src/main/java/org/apache/commons/text/translate/UnicodeUnescaper.java
+++ b/src/main/java/org/apache/commons/text/translate/UnicodeUnescaper.java
@@ -5,9 +5,9 @@
  * 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.
@@ -20,8 +20,8 @@ import java.io.IOException;
 import java.io.Writer;
 
 /**
- * Translates escaped Unicode values of the form \\u+\d\d\d\d back to 
- * Unicode. It supports multiple 'u' characters and will work with or 
+ * Translates escaped Unicode values of the form \\u+\d\d\d\d back to
+ * Unicode. It supports multiple 'u' characters and will work with or
  * without the +.
  *
  * @since 1.0
@@ -56,7 +56,8 @@ public class UnicodeUnescaper extends CharSequenceTranslator {
                 }
                 return i + 4;
             }
-            throw new IllegalArgumentException("Less than 4 hex digits in unicode value: '" + input.subSequence(index, input.length())
+            throw new IllegalArgumentException("Less than 4 hex digits in unicode value: '"
+                    + input.subSequence(index, input.length())
                     + "' due to end of CharSequence");
         }
         return 0;

http://git-wip-us.apache.org/repos/asf/commons-text/blob/0900a4c9/src/main/java/org/apache/commons/text/translate/UnicodeUnpairedSurrogateRemover.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/UnicodeUnpairedSurrogateRemover.java b/src/main/java/org/apache/commons/text/translate/UnicodeUnpairedSurrogateRemover.java
index ca90b89..09d69c7 100644
--- a/src/main/java/org/apache/commons/text/translate/UnicodeUnpairedSurrogateRemover.java
+++ b/src/main/java/org/apache/commons/text/translate/UnicodeUnpairedSurrogateRemover.java
@@ -26,7 +26,7 @@ import java.io.Writer;
  */
 public class UnicodeUnpairedSurrogateRemover extends CodePointTranslator {
     /**
-     * Implementation of translate that throws out unpaired surrogates. 
+     * Implementation of translate that throws out unpaired surrogates.
      * {@inheritDoc}
      */
     @Override


[2/9] [text] TEXT-65: 120 checkstyle errors now

Posted by ch...@apache.org.
TEXT-65: 120 checkstyle errors now


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

Branch: refs/heads/master
Commit: df0658f05b3113675d28dbe967d3326682f95dfe
Parents: 1035cd6
Author: Rob Tompkins <ch...@apache.org>
Authored: Mon Feb 13 07:53:54 2017 -0500
Committer: Rob Tompkins <ch...@apache.org>
Committed: Mon Feb 13 07:53:54 2017 -0500

----------------------------------------------------------------------
 .../org/apache/commons/text/StrTokenizer.java   | 44 ++++++++++++--------
 .../text/translate/AggregateTranslator.java     | 17 ++++----
 .../text/translate/CharSequenceTranslator.java  | 32 ++++++++------
 3 files changed, 56 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/df0658f0/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 8186f37..66126ec 100644
--- a/src/main/java/org/apache/commons/text/StrTokenizer.java
+++ b/src/main/java/org/apache/commons/text/StrTokenizer.java
@@ -83,7 +83,9 @@ import java.util.NoSuchElementException;
  */
 public class StrTokenizer implements ListIterator<String>, Cloneable {
 
+    /** Comma separated values tokenizer internal variable. */
     private static final StrTokenizer CSV_TOKENIZER_PROTOTYPE;
+    /** Tab separated values tokenizer internal variable. */
     private static final StrTokenizer TSV_TOKENIZER_PROTOTYPE;
     static {
         CSV_TOKENIZER_PROTOTYPE = new StrTokenizer();
@@ -104,24 +106,24 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
     }
 
     /** The text to work on. */
-    private char chars[];
-    /** The parsed tokens */
-    private String tokens[];
-    /** The current iteration position */
+    private char[] chars;
+    /** The parsed tokens. */
+    private String[] tokens;
+    /** The current iteration position. */
     private int tokenPos;
 
-    /** The delimiter matcher */
+    /** The delimiter matcher. */
     private StrMatcher delimMatcher = StrMatcher.splitMatcher();
-    /** The quote matcher */
+    /** The quote matcher. */
     private StrMatcher quoteMatcher = StrMatcher.noneMatcher();
-    /** The ignored matcher */
+    /** The ignored matcher. */
     private StrMatcher ignoredMatcher = StrMatcher.noneMatcher();
-    /** The trimmer matcher */
+    /** The trimmer matcher. */
     private StrMatcher trimmerMatcher = StrMatcher.noneMatcher();
 
-    /** Whether to return empty tokens as null */
+    /** Whether to return empty tokens as null. */
     private boolean emptyAsNull = false;
-    /** Whether to ignore empty tokens */
+    /** Whether to ignore empty tokens. */
     private boolean ignoreEmptyTokens = true;
 
     //-----------------------------------------------------------------------
@@ -686,16 +688,20 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
      * @return the starting position of the next field (the character
      *  immediately after the delimiter), or -1 if end of string found
      */
-    private int readNextToken(final char[] srcChars, int start, final int len, final StrBuilder workArea, final List<String> tokenList) {
+    private int readNextToken(final char[] srcChars,
+                              int start,
+                              final int len,
+                              final StrBuilder workArea,
+                              final List<String> tokenList) {
         // skip all leading whitespace, unless it is the
         // field delimiter or the quote character
         while (start < len) {
             final int removeLen = Math.max(
                     getIgnoredMatcher().isMatch(srcChars, start, start, len),
                     getTrimmerMatcher().isMatch(srcChars, start, start, len));
-            if (removeLen == 0 ||
-                getDelimiterMatcher().isMatch(srcChars, start, start, len) > 0 ||
-                getQuoteMatcher().isMatch(srcChars, start, start, len) > 0) {
+            if (removeLen == 0
+                    || getDelimiterMatcher().isMatch(srcChars, start, start, len) > 0
+                    || getQuoteMatcher().isMatch(srcChars, start, start, len) > 0) {
                 break;
             }
             start += removeLen;
@@ -832,7 +838,11 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
      * @param quoteLen  the length of the matched quote, 0 if no quoting
      * @return true if a quote is matched
      */
-    private boolean isQuote(final char[] srcChars, final int pos, final int len, final int quoteStart, final int quoteLen) {
+    private boolean isQuote(final char[] srcChars,
+                            final int pos,
+                            final int len,
+                            final int quoteStart,
+                            final int quoteLen) {
         for (int i = 0; i < quoteLen; i++) {
             if (pos + i >= len || srcChars[pos + i] != srcChars[quoteStart + i]) {
                 return false;
@@ -1072,7 +1082,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
      * Creates a new instance of this Tokenizer. The new instance is reset so
      * that it will be at the start of the token list.
      * If a {@link CloneNotSupportedException} is caught, return <code>null</code>.
-     * 
+     *
      * @return a new instance of this Tokenizer which has been reset.
      */
     @Override
@@ -1087,7 +1097,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
     /**
      * Creates a new instance of this Tokenizer. The new instance is reset so that
      * it will be at the start of the token list.
-     * 
+     *
      * @return a new instance of this Tokenizer which has been reset.
      * @throws CloneNotSupportedException if there is a problem cloning
      */

http://git-wip-us.apache.org/repos/asf/commons-text/blob/df0658f0/src/main/java/org/apache/commons/text/translate/AggregateTranslator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/AggregateTranslator.java b/src/main/java/org/apache/commons/text/translate/AggregateTranslator.java
index 010ab2a..788f8c5 100644
--- a/src/main/java/org/apache/commons/text/translate/AggregateTranslator.java
+++ b/src/main/java/org/apache/commons/text/translate/AggregateTranslator.java
@@ -5,9 +5,9 @@
  * 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.
@@ -22,17 +22,20 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * Executes a sequence of translators one after the other. Execution ends whenever 
+ * Executes a sequence of translators one after the other. Execution ends whenever
  * the first translator consumes codepoints from the input.
  *
  * @since 1.0
  */
 public class AggregateTranslator extends CharSequenceTranslator {
 
+    /**
+     * Translator list.
+     */
     private final List<CharSequenceTranslator> translators = new ArrayList<>();
 
     /**
-     * Specify the translators to be used at creation time. 
+     * Specify the translators to be used at creation time.
      *
      * @param translators CharSequenceTranslator array to aggregate
      */
@@ -47,15 +50,15 @@ public class AggregateTranslator extends CharSequenceTranslator {
     }
 
     /**
-     * The first translator to consume codepoints from the input is the 'winner'. 
-     * Execution stops with the number of consumed codepoints being returned. 
+     * The first translator to consume codepoints from the input is the 'winner'.
+     * Execution stops with the number of consumed codepoints being returned.
      * {@inheritDoc}
      */
     @Override
     public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
         for (final CharSequenceTranslator translator : translators) {
             final int consumed = translator.translate(input, index, out);
-            if(consumed != 0) {
+            if (consumed != 0) {
                 return consumed;
             }
         }

http://git-wip-us.apache.org/repos/asf/commons-text/blob/df0658f0/src/main/java/org/apache/commons/text/translate/CharSequenceTranslator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/CharSequenceTranslator.java b/src/main/java/org/apache/commons/text/translate/CharSequenceTranslator.java
index baec844..4a27472 100644
--- a/src/main/java/org/apache/commons/text/translate/CharSequenceTranslator.java
+++ b/src/main/java/org/apache/commons/text/translate/CharSequenceTranslator.java
@@ -5,9 +5,9 @@
  * 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.
@@ -22,21 +22,27 @@ import java.io.Writer;
 import java.util.Locale;
 
 /**
- * An API for translating text. 
- * Its core use is to escape and unescape text. Because escaping and unescaping 
+ * An API for translating text.
+ * Its core use is to escape and unescape text. Because escaping and unescaping
  * is completely contextual, the API does not present two separate signatures.
  *
  * @since 1.0
  */
 public abstract class CharSequenceTranslator {
 
-    static final char[] HEX_DIGITS = new char[] {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+    /**
+     * Array containing the hexadecimal alphabet.
+     */
+    static final char[] HEX_DIGITS = new char[] {'0', '1', '2', '3',
+                                                 '4', '5', '6', '7',
+                                                 '8', '9', 'A', 'B',
+                                                 'C', 'D', 'E', 'F'};
 
     /**
-     * Translate a set of codepoints, represented by an int index into a CharSequence, 
-     * into another set of codepoints. The number of codepoints consumed must be returned, 
-     * and the only IOExceptions thrown must be from interacting with the Writer so that 
-     * the top level API may reliably ignore StringWriter IOExceptions. 
+     * Translate a set of codepoints, represented by an int index into a CharSequence,
+     * into another set of codepoints. The number of codepoints consumed must be returned,
+     * and the only IOExceptions thrown must be from interacting with the Writer so that
+     * the top level API may reliably ignore StringWriter IOExceptions.
      *
      * @param input CharSequence that is being translated
      * @param index int representing the current point of translation
@@ -47,7 +53,7 @@ public abstract class CharSequenceTranslator {
     public abstract int translate(CharSequence input, int index, Writer out) throws IOException;
 
     /**
-     * Helper for non-Writer usage. 
+     * Helper for non-Writer usage.
      * @param input CharSequence to be translated
      * @return String output of translation
      */
@@ -66,8 +72,8 @@ public abstract class CharSequenceTranslator {
     }
 
     /**
-     * Translate an input onto a Writer. This is intentionally final as its algorithm is 
-     * tightly coupled with the abstract method of this class. 
+     * Translate an input onto a Writer. This is intentionally final as its algorithm is
+     * tightly coupled with the abstract method of this class.
      *
      * @param input CharSequence that is being translated
      * @param out Writer to translate the text to
@@ -108,7 +114,7 @@ public abstract class CharSequenceTranslator {
     }
 
     /**
-     * Helper method to create a merger of this translator with another set of 
+     * Helper method to create a merger of this translator with another set of
      * translators. Useful in customizing the standard functionality.
      *
      * @param translators CharSequenceTranslator array of translators to merge with this one


[7/9] [text] TEXT-65: created TEXT-68 removing TODO

Posted by ch...@apache.org.
TEXT-65: created TEXT-68 removing TODO


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

Branch: refs/heads/master
Commit: 1063a8d5e70394a55f24e26136f5f044b32fff28
Parents: 5842b23
Author: Rob Tompkins <ch...@apache.org>
Authored: Fri Feb 17 08:39:05 2017 -0500
Committer: Rob Tompkins <ch...@apache.org>
Committed: Fri Feb 17 08:39:05 2017 -0500

----------------------------------------------------------------------
 src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/1063a8d5/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java b/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java
index 8fba4b4..a78a719 100644
--- a/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java
+++ b/src/main/java/org/apache/commons/text/translate/UnicodeEscaper.java
@@ -114,7 +114,6 @@ public class UnicodeEscaper extends CodePointTranslator {
             }
         }
 
-        // TODO: Handle potential + sign per various Unicode escape implementations
         if (codepoint > 0xffff) {
             out.write(toUtf16Escape(codepoint));
         } else {


[3/9] [text] TEXT-65: 25 checkstyle errors

Posted by ch...@apache.org.
TEXT-65: 25 checkstyle errors


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

Branch: refs/heads/master
Commit: 3e07584624c170cc703a673b2ec6ee49c57fba08
Parents: df0658f
Author: Rob Tompkins <ch...@apache.org>
Authored: Mon Feb 13 08:37:30 2017 -0500
Committer: Rob Tompkins <ch...@apache.org>
Committed: Mon Feb 13 08:37:30 2017 -0500

----------------------------------------------------------------------
 checkstyle-suppressions.xml                     | 17 +++++++
 .../text/translate/CodePointTranslator.java     | 14 +++---
 .../commons/text/translate/CsvTranslators.java  | 10 +++-
 .../commons/text/translate/EntityArrays.java    |  4 +-
 .../text/translate/JavaUnicodeEscaper.java      | 14 +++---
 .../text/translate/LookupTranslator.java        |  8 +++-
 .../text/translate/NumericEntityEscaper.java    |  5 +-
 .../text/translate/NumericEntityUnescaper.java  | 50 ++++++++++----------
 .../commons/text/translate/OctalUnescaper.java  | 14 +++---
 .../text/translate/SingleLookupTranslator.java  |  8 +++-
 .../text/translate/SinglePassTranslator.java    | 10 ++--
 11 files changed, 98 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/3e075846/checkstyle-suppressions.xml
----------------------------------------------------------------------
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
index d6634e3..cc03b22 100644
--- a/checkstyle-suppressions.xml
+++ b/checkstyle-suppressions.xml
@@ -25,15 +25,32 @@
   <suppress checks="DesignForExtension" files=".+\.java" lines="0-99999" />
   <suppress checks="HideUtilityClassConstructor" files=".+\.java" lines="0-99999" />
   <suppress checks="VisibilityModifier" files=".+\.java" lines="0-99999" />
+
   <suppress checks="EmptyBlock" files="ExtendedMessageFormat.java" lines="0-99999" />
+
   <suppress checks="LocalFinalVariableName" files="FormattableUtils.java" lines="0-99999" />
+
   <suppress checks="MagicNumber" files="JaccardDistance.java" lines="0-99999" />
+
   <suppress checks="MagicNumber" files="JaccardSimilarity.java" lines="0-99999" />
+
   <suppress checks="MagicNumber" files="JaroWinklerDistance.java" lines="0-99999" />
   <suppress checks="NoWhitespaceAfter" files="JaroWinklerDistance.java" lines="0-99999" />
+
   <suppress checks="FileLength" files="StrBuilder.java" lines="0-99999" />
   <suppress checks="MagicNumber" files="StrBuilder.java" lines="0-99999" />
+
   <suppress checks="MagicNumber" files="StringEscapeUtils.java" lines="0-99999" />
+
   <suppress checks="EmptyBlock" files="StrLookup.java" lines="0-99999" />
+
   <suppress checks="MagicNumber" files="StrMatcher.java" lines="0-99999" />
+
+  <suppress checks="LocalVariableName" files="LookupTranslator.java" lines="0-99999" />
+
+  <suppress checks="MagicNumber" files="NumericEntityEscaper.java" lines="0-99999" />
+
+  <suppress checks="MagicNumber" files="NumericEntityUnescaper.java" lines="0-99999" />
+
+  <suppress checks="MagicNumber" files="OctalUnescaper.java" lines="0-99999" />
 </suppressions>

http://git-wip-us.apache.org/repos/asf/commons-text/blob/3e075846/src/main/java/org/apache/commons/text/translate/CodePointTranslator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/CodePointTranslator.java b/src/main/java/org/apache/commons/text/translate/CodePointTranslator.java
index 3318261..71828be 100644
--- a/src/main/java/org/apache/commons/text/translate/CodePointTranslator.java
+++ b/src/main/java/org/apache/commons/text/translate/CodePointTranslator.java
@@ -5,9 +5,9 @@
  * 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.
@@ -20,7 +20,7 @@ import java.io.IOException;
 import java.io.Writer;
 
 /**
- * Helper subclass to CharSequenceTranslator to allow for translations that 
+ * Helper subclass to CharSequenceTranslator to allow for translations that
  * will replace up to one character at a time.
  *
  * @since 1.0
@@ -28,19 +28,19 @@ import java.io.Writer;
 public abstract class CodePointTranslator extends CharSequenceTranslator {
 
     /**
-     * Implementation of translate that maps onto the abstract translate(int, Writer) method. 
+     * Implementation of translate that maps onto the abstract translate(int, Writer) method.
      * {@inheritDoc}
      */
     @Override
     public final int translate(final CharSequence input, final int index, final Writer out) throws IOException {
         final int codepoint = Character.codePointAt(input, index);
         final boolean consumed = translate(codepoint, out);
-        return consumed ? 1 : 0; 
+        return consumed ? 1 : 0;
     }
 
     /**
-     * Translate the specified codepoint into another. 
-     * 
+     * Translate the specified codepoint into another.
+     *
      * @param codepoint int character input to translate
      * @param out Writer to optionally push the translated output to
      * @return boolean as to whether translation occurred or not

http://git-wip-us.apache.org/repos/asf/commons-text/blob/3e075846/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 f11b9fe..a7a98e4 100644
--- a/src/main/java/org/apache/commons/text/translate/CsvTranslators.java
+++ b/src/main/java/org/apache/commons/text/translate/CsvTranslators.java
@@ -25,15 +25,21 @@ import java.io.Writer;
 /**
  * This class holds inner classes for escaping/unescaping Comma Separated Values.
  */
-public class CsvTranslators {
+public final class CsvTranslators {
 
+    /** Comma character. */
     private static final char CSV_DELIMITER = ',';
+    /** Quote character. */
     private static final char CSV_QUOTE = '"';
+    /** Quote character converted to string. */
     private static final String CSV_QUOTE_STR = String.valueOf(CSV_QUOTE);
+    /** Escaped quote string. */
     private static final String CSV_ESCAPED_QUOTE_STR = CSV_QUOTE_STR + CSV_QUOTE_STR;
+    /** CSV key characters in an array. */
     private static final char[] CSV_SEARCH_CHARS =
             new char[] {CSV_DELIMITER, CSV_QUOTE, CharUtils.CR, CharUtils.LF};
 
+    /** Hidden constructor. */
     private CsvTranslators() { }
 
     /**
@@ -79,4 +85,4 @@ public class CsvTranslators {
             }
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/3e075846/src/main/java/org/apache/commons/text/translate/EntityArrays.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/EntityArrays.java b/src/main/java/org/apache/commons/text/translate/EntityArrays.java
index f5876f2..f314386 100644
--- a/src/main/java/org/apache/commons/text/translate/EntityArrays.java
+++ b/src/main/java/org/apache/commons/text/translate/EntityArrays.java
@@ -390,7 +390,7 @@ public class EntityArrays {
     public static final Map<CharSequence, CharSequence> APOS_ESCAPE;
     static {
         Map<CharSequence, CharSequence> initialMap = new HashMap<>();
-        initialMap.put("'","&apos;"); // XML apostrophe
+        initialMap.put("'", "&apos;"); // XML apostrophe
         APOS_ESCAPE = Collections.unmodifiableMap(initialMap);
     }
 
@@ -428,7 +428,7 @@ public class EntityArrays {
     }
 
     /**
-     * Used to invert an escape Map into an unescape Map
+     * Used to invert an escape Map into an unescape Map.
      * @param map Map&lt;String, String&gt; to be inverted
      * @return Map&lt;String, String&gt; inverted array
      */

http://git-wip-us.apache.org/repos/asf/commons-text/blob/3e075846/src/main/java/org/apache/commons/text/translate/JavaUnicodeEscaper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/JavaUnicodeEscaper.java b/src/main/java/org/apache/commons/text/translate/JavaUnicodeEscaper.java
index 22549fa..b4b3aac 100644
--- a/src/main/java/org/apache/commons/text/translate/JavaUnicodeEscaper.java
+++ b/src/main/java/org/apache/commons/text/translate/JavaUnicodeEscaper.java
@@ -27,7 +27,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper {
      * <p>
      * Constructs a <code>JavaUnicodeEscaper</code> above the specified value (exclusive).
      * </p>
-     * 
+     *
      * @param codepoint
      *            above which to escape
      * @return the newly created {@code UnicodeEscaper} instance
@@ -40,7 +40,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper {
      * <p>
      * Constructs a <code>JavaUnicodeEscaper</code> below the specified value (exclusive).
      * </p>
-     * 
+     *
      * @param codepoint
      *            below which to escape
      * @return the newly created {@code UnicodeEscaper} instance
@@ -53,7 +53,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper {
      * <p>
      * Constructs a <code>JavaUnicodeEscaper</code> between the specified values (inclusive).
      * </p>
-     * 
+     *
      * @param codepointLow
      *            above which to escape
      * @param codepointHigh
@@ -68,7 +68,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper {
      * <p>
      * Constructs a <code>JavaUnicodeEscaper</code> outside of the specified values (exclusive).
      * </p>
-     * 
+     *
      * @param codepointLow
      *            below which to escape
      * @param codepointHigh
@@ -85,7 +85,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper {
      * other constructors/builders. The <code>below</code> and <code>above</code> boundaries are inclusive when
      * <code>between</code> is <code>true</code> and exclusive when it is <code>false</code>.
      * </p>
-     * 
+     *
      * @param below
      *            int value representing the lowest codepoint boundary
      * @param above
@@ -98,8 +98,8 @@ public class JavaUnicodeEscaper extends UnicodeEscaper {
     }
 
     /**
-     * Converts the given codepoint to a hex string of the form {@code "\\uXXXX\\uXXXX"}
-     * 
+     * Converts the given codepoint to a hex string of the form {@code "\\uXXXX\\uXXXX"}.
+     *
      * @param codepoint
      *            a Unicode code point
      * @return the hex string for the given codepoint

http://git-wip-us.apache.org/repos/asf/commons-text/blob/3e075846/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 ab3a7f6..51cafd9 100644
--- a/src/main/java/org/apache/commons/text/translate/LookupTranslator.java
+++ b/src/main/java/org/apache/commons/text/translate/LookupTranslator.java
@@ -5,9 +5,9 @@
  * 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.
@@ -31,9 +31,13 @@ import java.util.Map;
  */
 public class LookupTranslator extends CharSequenceTranslator {
 
+    /** The mapping to be used in translation. */
     private final Map<String, String> lookupMap;
+    /** The first character of each key in the lookupMap. */
     private final HashSet<Character> prefixSet;
+    /** The length of the shortest key in the lookupMap. */
     private final int shortest;
+    /** The length of the longest key in the lookupMap. */
     private final int longest;
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-text/blob/3e075846/src/main/java/org/apache/commons/text/translate/NumericEntityEscaper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/NumericEntityEscaper.java b/src/main/java/org/apache/commons/text/translate/NumericEntityEscaper.java
index a852964..0cdb808 100644
--- a/src/main/java/org/apache/commons/text/translate/NumericEntityEscaper.java
+++ b/src/main/java/org/apache/commons/text/translate/NumericEntityEscaper.java
@@ -26,8 +26,11 @@ import java.io.Writer;
  */
 public class NumericEntityEscaper extends CodePointTranslator {
 
+    /** int value representing the lowest codepoint boundary. */
     private final int below;
+    /** int value representing the highest codepoint boundary. */
     private final int above;
+    /** whether to escape between the boundaries or outside them. */
     private final boolean between;
 
     /**
@@ -100,7 +103,7 @@ public class NumericEntityEscaper extends CodePointTranslator {
      */
     @Override
     public boolean translate(final int codepoint, final Writer out) throws IOException {
-        if(between) {
+        if (between) {
             if (codepoint < below || codepoint > above) {
                 return false;
             }

http://git-wip-us.apache.org/repos/asf/commons-text/blob/3e075846/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java b/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
index 8b3d7c7..42b38ef 100644
--- a/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
+++ b/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
@@ -5,9 +5,9 @@
  * 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.
@@ -22,7 +22,7 @@ import java.util.Arrays;
 import java.util.EnumSet;
 
 /**
- * Translate XML numeric entities of the form &amp;#[xX]?\d+;? to 
+ * Translate XML numeric entities of the form &amp;#[xX]?\d+;? to
  * the specific codepoint.
  *
  * Note that the semi-colon is optional.
@@ -31,16 +31,18 @@ import java.util.EnumSet;
  */
 public class NumericEntityUnescaper extends CharSequenceTranslator {
 
+    /** NumericEntityUnescaper option enum. */
     public static enum OPTION { semiColonRequired, semiColonOptional, errorIfNoSemiColon }
 
+    /** EnumSet of OPTIONS, given from the constructor. */
     // TODO?: Create an OptionsSet class to hide some of the conditional logic below
     private final EnumSet<OPTION> options;
 
     /**
      * Create a UnicodeUnescaper.
      *
-     * The constructor takes a list of options, only one type of which is currently 
-     * available (whether to allow, error or ignore the semi-colon on the end of a 
+     * The constructor takes a list of options, only one type of which is currently
+     * available (whether to allow, error or ignore the semi-colon on the end of a
      * numeric entity to being missing).
      *
      * For example, to support numeric entities without a ';':
@@ -48,15 +50,15 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
      * and to throw an IllegalArgumentException when they're missing:
      *    new NumericEntityUnescaper(NumericEntityUnescaper.OPTION.errorIfNoSemiColon)
      *
-     * Note that the default behaviour is to ignore them. 
+     * Note that the default behaviour is to ignore them.
      *
      * @param options to apply to this unescaper
      */
     public NumericEntityUnescaper(final OPTION... options) {
-        if(options.length > 0) {
+        if (options.length > 0) {
             this.options = EnumSet.copyOf(Arrays.asList(options));
         } else {
-            this.options = EnumSet.copyOf(Arrays.asList(new OPTION[] { OPTION.semiColonRequired }));
+            this.options = EnumSet.copyOf(Arrays.asList(new OPTION[] {OPTION.semiColonRequired}));
         }
     }
 
@@ -66,7 +68,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
      * @param option to check state of
      * @return whether the option is set
      */
-    public boolean isSet(final OPTION option) { 
+    public boolean isSet(final OPTION option) {
         return options == null ? false : options.contains(option);
     }
 
@@ -77,53 +79,53 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
     public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
         final int seqEnd = input.length();
         // Uses -2 to ensure there is something after the &#
-        if(input.charAt(index) == '&' && index < seqEnd - 2 && input.charAt(index + 1) == '#') {
+        if (input.charAt(index) == '&' && index < seqEnd - 2 && input.charAt(index + 1) == '#') {
             int start = index + 2;
             boolean isHex = false;
 
             final char firstChar = input.charAt(start);
-            if(firstChar == 'x' || firstChar == 'X') {
+            if (firstChar == 'x' || firstChar == 'X') {
                 start++;
                 isHex = true;
 
                 // Check there's more than just an x after the &#
-                if(start == seqEnd) {
+                if (start == seqEnd) {
                     return 0;
                 }
             }
 
             int end = start;
             // Note that this supports character codes without a ; on the end
-            while(end < seqEnd && ( input.charAt(end) >= '0' && input.charAt(end) <= '9' ||
-                                    input.charAt(end) >= 'a' && input.charAt(end) <= 'f' ||
-                                    input.charAt(end) >= 'A' && input.charAt(end) <= 'F' ) )
-            {
+            while (end < seqEnd && (input.charAt(end) >= '0' && input.charAt(end) <= '9'
+                                    || input.charAt(end) >= 'a' && input.charAt(end) <= 'f'
+                                    || input.charAt(end) >= 'A' && input.charAt(end) <= 'F')) {
                 end++;
             }
 
             final boolean semiNext = end != seqEnd && input.charAt(end) == ';';
 
-            if(!semiNext) {
-                if(isSet(OPTION.semiColonRequired)) {
+            if (!semiNext) {
+                if (isSet(OPTION.semiColonRequired)) {
                     return 0;
-                } else
-                if(isSet(OPTION.errorIfNoSemiColon)) {
-                    throw new IllegalArgumentException("Semi-colon required at end of numeric entity");
+                } else {
+                    if (isSet(OPTION.errorIfNoSemiColon)) {
+                        throw new IllegalArgumentException("Semi-colon required at end of numeric entity");
+                    }
                 }
             }
 
             int entityValue;
             try {
-                if(isHex) {
+                if (isHex) {
                     entityValue = Integer.parseInt(input.subSequence(start, end).toString(), 16);
                 } else {
                     entityValue = Integer.parseInt(input.subSequence(start, end).toString(), 10);
                 }
-            } catch(final NumberFormatException nfe) {
+            } catch (final NumberFormatException nfe) {
                 return 0;
             }
 
-            if(entityValue > 0xFFFF) {
+            if (entityValue > 0xFFFF) {
                 final char[] chrs = Character.toChars(entityValue);
                 out.write(chrs[0]);
                 out.write(chrs[1]);

http://git-wip-us.apache.org/repos/asf/commons-text/blob/3e075846/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java b/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java
index e49cdd5..0443128 100644
--- a/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java
+++ b/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java
@@ -5,9 +5,9 @@
  * 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.
@@ -24,7 +24,7 @@ import java.io.Writer;
  *
  * For example, "\45" should go back to being the specific value (a %).
  *
- * Note that this currently only supports the viable range of octal for Java; namely 
+ * Note that this currently only supports the viable range of octal for Java; namely
  * 1 to 377. This is because parsing Java is the main use case.
  *
  * @since 1.0
@@ -38,7 +38,7 @@ public class OctalUnescaper extends CharSequenceTranslator {
     public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
         final int remaining = input.length() - index - 1; // how many characters left, ignoring the first \
         final StringBuilder builder = new StringBuilder();
-        if(input.charAt(index) == '\\' && remaining > 0 && isOctalDigit(input.charAt(index + 1)) ) {
+        if (input.charAt(index) == '\\' && remaining > 0 && isOctalDigit(input.charAt(index + 1))) {
             final int next = index + 1;
             final int next2 = index + 2;
             final int next3 = index + 3;
@@ -46,14 +46,14 @@ public class OctalUnescaper extends CharSequenceTranslator {
             // we know this is good as we checked it in the if block above
             builder.append(input.charAt(next));
 
-            if(remaining > 1 && isOctalDigit(input.charAt(next2))) {
+            if (remaining > 1 && isOctalDigit(input.charAt(next2))) {
                 builder.append(input.charAt(next2));
-                if(remaining > 2 && isZeroToThree(input.charAt(next)) && isOctalDigit(input.charAt(next3))) {
+                if (remaining > 2 && isZeroToThree(input.charAt(next)) && isOctalDigit(input.charAt(next3))) {
                     builder.append(input.charAt(next3));
                 }
             }
 
-            out.write( Integer.parseInt(builder.toString(), 8) );
+            out.write(Integer.parseInt(builder.toString(), 8));
             return 1 + builder.length();
         }
         return 0;

http://git-wip-us.apache.org/repos/asf/commons-text/blob/3e075846/src/main/java/org/apache/commons/text/translate/SingleLookupTranslator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/SingleLookupTranslator.java b/src/main/java/org/apache/commons/text/translate/SingleLookupTranslator.java
index 7af0579..8fafab8 100644
--- a/src/main/java/org/apache/commons/text/translate/SingleLookupTranslator.java
+++ b/src/main/java/org/apache/commons/text/translate/SingleLookupTranslator.java
@@ -31,11 +31,17 @@ import java.util.Map;
  */
 public class SingleLookupTranslator extends CharSequenceTranslator {
 
+    /** The lookupMap to be used for translation. */
     private final Map<String, String> lookupMap;
+    /** The first character of each key in the lookupMap. */
     private final HashSet<Character> prefixSet;
+    /** The length of the shortest key in the lookupMap. */
     private final int shortest;
+    /** The length of the longest key in the lookupMap. */
     private final int longest;
+    /** The length of the shortest value in the lookupMap. */
     private final int shortestValue;
+    /** The length of the longest value in the lookupMap. */
     private final int longestValue;
 
     /**
@@ -51,7 +57,7 @@ public class SingleLookupTranslator extends CharSequenceTranslator {
      * lookup table passed to this instance while deciding whether a value is
      * already translated or not.
      *
-     * @param inputMaps, an array of Map&lt;CharSequence, CharSequence&gt;.
+     * @param inputMaps an array of Map&lt;CharSequence, CharSequence&gt;.
      */
     public SingleLookupTranslator(Map<CharSequence, CharSequence>... inputMaps) {
         Map<CharSequence, CharSequence> lookup = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/commons-text/blob/3e075846/src/main/java/org/apache/commons/text/translate/SinglePassTranslator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/SinglePassTranslator.java b/src/main/java/org/apache/commons/text/translate/SinglePassTranslator.java
index 721e727..63bdde1 100644
--- a/src/main/java/org/apache/commons/text/translate/SinglePassTranslator.java
+++ b/src/main/java/org/apache/commons/text/translate/SinglePassTranslator.java
@@ -28,8 +28,8 @@ abstract class SinglePassTranslator extends CharSequenceTranslator {
     @Override
     public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
         if (index != 0) {
-            throw new IllegalArgumentException(getClassName() + ".translate(final CharSequence input, final int " +
-                    "index, final Writer out) can not handle a non-zero index.");
+            throw new IllegalArgumentException(getClassName() + ".translate(final CharSequence input, final int "
+                    + "index, final Writer out) can not handle a non-zero index.");
         }
 
         translateWhole(input, out);
@@ -37,6 +37,11 @@ abstract class SinglePassTranslator extends CharSequenceTranslator {
         return Character.codePointCount(input, index, input.length());
     }
 
+    /**
+     * A utility method to be used in the {@link #translate(CharSequence, int, Writer)} method.
+     *
+     * @return the name of this or the extending class.
+     */
     private String getClassName() {
         final Class<? extends SinglePassTranslator> clazz = this.getClass();
         return clazz.isAnonymousClass() ?  clazz.getName() : clazz.getSimpleName();
@@ -47,7 +52,6 @@ abstract class SinglePassTranslator extends CharSequenceTranslator {
      *
      * @param input CharSequence that is being translated
      * @param out Writer to translate the text to
-     * @return total count of codepoints in input
      * @throws IOException if and only if the Writer produces an IOException
      */
     abstract void translateWhole(final CharSequence input, final Writer out) throws IOException;


[6/9] [text] TEXT-65: created TEXT-67 removing TODO

Posted by ch...@apache.org.
TEXT-65: created TEXT-67 removing TODO


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

Branch: refs/heads/master
Commit: 5842b23a7231c9707f1373e80850959b2033f139
Parents: b2b4c21
Author: Rob Tompkins <ch...@apache.org>
Authored: Fri Feb 17 08:28:33 2017 -0500
Committer: Rob Tompkins <ch...@apache.org>
Committed: Fri Feb 17 08:28:33 2017 -0500

----------------------------------------------------------------------
 .../org/apache/commons/text/translate/NumericEntityUnescaper.java   | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/5842b23a/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java b/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
index 6060cf8..e8f59c6 100644
--- a/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
+++ b/src/main/java/org/apache/commons/text/translate/NumericEntityUnescaper.java
@@ -35,7 +35,6 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
     public static enum OPTION { semiColonRequired, semiColonOptional, errorIfNoSemiColon }
 
     /** EnumSet of OPTIONS, given from the constructor. */
-    // TODO: Create an OptionsSet class to hide some of the conditional logic below
     private final EnumSet<OPTION> options;
 
     /**


[8/9] [text] TEXT-65: adding line to changes.xml

Posted by ch...@apache.org.
TEXT-65: adding line to changes.xml


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

Branch: refs/heads/master
Commit: 893474192e765e379ccb8b572145d2738529cc2b
Parents: 1063a8d
Author: Rob Tompkins <ch...@apache.org>
Authored: Fri Feb 17 08:40:23 2017 -0500
Committer: Rob Tompkins <ch...@apache.org>
Committed: Fri Feb 17 08:40:23 2017 -0500

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


http://git-wip-us.apache.org/repos/asf/commons-text/blob/89347419/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6a567ec..94db412 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,7 +46,8 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
 
   <release version="TBA" date="TBA" description="TBA">
-  <action issue="TEXT-63" type="fix" dev="sebb">Mutable fields should be private</action>
+    <action issue="TEXT-65" type="fix" dev="chtompki">Fixing the 200 checkstyle errors present in 1.0-beta-1</action>
+    <action issue="TEXT-63" type="fix" dev="sebb">Mutable fields should be private</action>
   </release>
 
   <release version="1.0-beta-1" date="2017-01-30" description="First release (beta) of Commons Text">


[5/9] [text] TEXT-65: created TEXT-66 removing TODO

Posted by ch...@apache.org.
TEXT-65: created TEXT-66 removing TODO


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

Branch: refs/heads/master
Commit: b2b4c21ede2d80272dc73ea1d53c3c12463a9d5d
Parents: 0900a4c
Author: Rob Tompkins <ch...@apache.org>
Authored: Fri Feb 17 08:24:26 2017 -0500
Committer: Rob Tompkins <ch...@apache.org>
Committed: Fri Feb 17 08:24:26 2017 -0500

----------------------------------------------------------------------
 src/main/java/org/apache/commons/text/StringEscapeUtils.java | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/b2b4c21e/src/main/java/org/apache/commons/text/StringEscapeUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/StringEscapeUtils.java b/src/main/java/org/apache/commons/text/StringEscapeUtils.java
index aa6b071..f98f116 100644
--- a/src/main/java/org/apache/commons/text/StringEscapeUtils.java
+++ b/src/main/java/org/apache/commons/text/StringEscapeUtils.java
@@ -313,7 +313,6 @@ public class StringEscapeUtils {
      * object allows the Java unescaping functionality to be used
      * as the foundation for a custom translator.
      */
-    // TODO: throw "illegal character: \92" as an Exception if a \ on the end of the Java (as per the compiler)?
     public static final CharSequenceTranslator UNESCAPE_JAVA;
     static {
         Map<CharSequence, CharSequence> unescapeJavaMap = new HashMap<>();


[9/9] [text] Merge branch 'TEXT-65' of github.com:chtompki/commons-text

Posted by ch...@apache.org.
Merge branch 'TEXT-65' of github.com:chtompki/commons-text


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

Branch: refs/heads/master
Commit: 40061c701fa78c0808556ab98d6f68ccbe6728e6
Parents: 931fc75 8934741
Author: Rob Tompkins <ch...@apache.org>
Authored: Fri Feb 17 08:45:53 2017 -0500
Committer: Rob Tompkins <ch...@apache.org>
Committed: Fri Feb 17 08:45:53 2017 -0500

----------------------------------------------------------------------
 checkstyle-suppressions.xml                     | 27 ++++++++++-
 src/changes/changes.xml                         |  3 +-
 .../java/org/apache/commons/text/StrLookup.java |  1 +
 .../org/apache/commons/text/StrMatcher.java     |  8 +--
 .../org/apache/commons/text/StrSubstitutor.java | 47 +++++++++++-------
 .../org/apache/commons/text/StrTokenizer.java   | 44 ++++++++++-------
 .../apache/commons/text/StringEscapeUtils.java  |  1 -
 .../text/translate/AggregateTranslator.java     | 17 ++++---
 .../text/translate/CharSequenceTranslator.java  | 32 +++++++-----
 .../text/translate/CodePointTranslator.java     | 14 +++---
 .../commons/text/translate/CsvTranslators.java  | 10 +++-
 .../commons/text/translate/EntityArrays.java    |  4 +-
 .../text/translate/JavaUnicodeEscaper.java      | 14 +++---
 .../text/translate/LookupTranslator.java        |  8 ++-
 .../text/translate/NumericEntityEscaper.java    |  5 +-
 .../text/translate/NumericEntityUnescaper.java  | 51 ++++++++++----------
 .../commons/text/translate/OctalUnescaper.java  | 14 +++---
 .../text/translate/SingleLookupTranslator.java  |  8 ++-
 .../text/translate/SinglePassTranslator.java    | 10 ++--
 .../commons/text/translate/UnicodeEscaper.java  | 13 +++--
 .../text/translate/UnicodeUnescaper.java        | 11 +++--
 .../UnicodeUnpairedSurrogateRemover.java        |  2 +-
 22 files changed, 214 insertions(+), 130 deletions(-)
----------------------------------------------------------------------