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:34 UTC
[3/9] [text] TEXT-65: 25 checkstyle errors
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("'","'"); // XML apostrophe
+ initialMap.put("'", "'"); // 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<String, String> to be inverted
* @return Map<String, String> 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 &#[xX]?\d+;? to
+ * Translate XML numeric entities of the form &#[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<CharSequence, CharSequence>.
+ * @param inputMaps an array of Map<CharSequence, CharSequence>.
*/
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;