@@ -45,7 +45,7 @@ public class StringEscapeUtils {
4545
4646 /* ESCAPE TRANSLATORS */
4747
48- static class CsvEscaper extends CharSequenceTranslator {
48+ private static final class CsvEscaper extends CharSequenceTranslator {
4949
5050 private static final char CSV_DELIMITER = ',' ;
5151 private static final char CSV_QUOTE = '"' ;
@@ -54,11 +54,9 @@ static class CsvEscaper extends CharSequenceTranslator {
5454
5555 @ Override
5656 public int translate (final CharSequence input , final int index , final Writer out ) throws IOException {
57-
5857 if (index != 0 ) {
5958 throw new IllegalStateException ("CsvEscaper should never reach the [1] index" );
6059 }
61-
6260 if (StringUtils .containsNone (input .toString (), CSV_SEARCH_CHARS )) {
6361 out .write (input .toString ());
6462 } else {
@@ -70,7 +68,7 @@ public int translate(final CharSequence input, final int index, final Writer out
7068 }
7169 }
7270
73- static class CsvUnescaper extends CharSequenceTranslator {
71+ private static final class CsvUnescaper extends CharSequenceTranslator {
7472
7573 private static final char CSV_DELIMITER = ',' ;
7674 private static final char CSV_QUOTE = '"' ;
@@ -79,19 +77,15 @@ static class CsvUnescaper extends CharSequenceTranslator {
7977
8078 @ Override
8179 public int translate (final CharSequence input , final int index , final Writer out ) throws IOException {
82-
8380 if (index != 0 ) {
8481 throw new IllegalStateException ("CsvUnescaper should never reach the [1] index" );
8582 }
86-
8783 if (input .charAt (0 ) != CSV_QUOTE || input .charAt (input .length () - 1 ) != CSV_QUOTE ) {
8884 out .write (input .toString ());
8985 return Character .codePointCount (input , 0 , input .length ());
9086 }
91-
9287 // strip quotes
9388 final String quoteless = input .subSequence (1 , input .length () - 1 ).toString ();
94-
9589 if (StringUtils .containsAny (quoteless , CSV_SEARCH_CHARS )) {
9690 // deal with escaped quotes; ie) ""
9791 out .write (Strings .CS .replace (quoteless , CSV_QUOTE_STR + CSV_QUOTE_STR , CSV_QUOTE_STR ));
0 commit comments