diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java index a2526ab2..c2d9562e 100644 --- a/src/main/java/org/apache/commons/csv/CSVFormat.java +++ b/src/main/java/org/apache/commons/csv/CSVFormat.java @@ -24,7 +24,7 @@ import java.io.StringWriter; /** * The format specification of a CSV file. - * + * * This class is immutable. */ public class CSVFormat implements Serializable { @@ -95,7 +95,7 @@ public class CSVFormat implements Serializable { * locale dependent, it might be necessary to customize this format to accomodate to your regional settings. *

* For example for parsing or generating a CSV file on a French system the following format will be used: - * + * *

      * CSVFormat fmt = CSVFormat.EXCEL.withDelimiter(';');
      * 
@@ -120,8 +120,8 @@ public class CSVFormat implements Serializable { * a tab-delimited format with a LF character as the line separator. Values are not quoted and special characters * are escaped with '\'. * - * @see http://dev.mysql.com/doc/refman/5.1/en/load-data.html + * @see + * http://dev.mysql.com/doc/refman/5.1/en/load-data.html */ public static final CSVFormat MYSQL = PRISTINE @@ -132,7 +132,7 @@ public class CSVFormat implements Serializable { /** * Creates a customized CSV format. - * + * * @param delimiter * the char used for value separation * @param encapsulator @@ -167,10 +167,10 @@ public class CSVFormat implements Serializable { /** * Returns true if the given character is a line break character. - * + * * @param c * the character to check - * + * * @return true if c is a line break character */ private static boolean isLineBreak(char c) { @@ -209,7 +209,7 @@ public class CSVFormat implements Serializable { /** * Returns the character delimiting the values (typically ';', ',' or '\t'). - * + * * @return the delimiter character */ public char getDelimiter() { @@ -218,7 +218,7 @@ public class CSVFormat implements Serializable { /** * Returns a copy of this format using the specified delimiter character. - * + * * @param delimiter * the delimiter character * @return A copy of this format using the specified delimiter character @@ -236,7 +236,7 @@ public class CSVFormat implements Serializable { /** * Returns the character used to encapsulate values containing special characters. - * + * * @return the encapsulator character */ public char getEncapsulator() { @@ -245,7 +245,7 @@ public class CSVFormat implements Serializable { /** * Returns a copy of this format using the specified encapsulator character. - * + * * @param encapsulator * the encapsulator character * @return A copy of this format using the specified encapsulator character @@ -263,7 +263,7 @@ public class CSVFormat implements Serializable { /** * Returns whether an encapsulator has been defined. - * + * * @return {@code true} if an encapsulator is defined */ public boolean isEncapsulating() { @@ -272,7 +272,7 @@ public class CSVFormat implements Serializable { /** * Returns the character marking the start of a line comment. - * + * * @return the comment start marker. */ public char getCommentStart() { @@ -281,9 +281,9 @@ public class CSVFormat implements Serializable { /** * Returns a copy of this format using the specified character as the comment start marker. - * + * * Note that the comment introducer character is only recognised at the start of a line. - * + * * @param commentStart * the comment start marker * @return A copy of this format using the specified character as the comment start marker @@ -301,9 +301,9 @@ public class CSVFormat implements Serializable { /** * Specifies whether comments are supported by this format. - * + * * Note that the comment introducer character is only recognised at the start of a line. - * + * * @return true is comments are supported, false otherwise */ public boolean isCommentingEnabled() { @@ -312,7 +312,7 @@ public class CSVFormat implements Serializable { /** * Returns the escape character. - * + * * @return the escape character */ public char getEscape() { @@ -321,7 +321,7 @@ public class CSVFormat implements Serializable { /** * Returns a copy of this format using the specified escape character. - * + * * @param escape * the escape character * @return A copy of this format using the specified escape character @@ -339,7 +339,7 @@ public class CSVFormat implements Serializable { /** * Returns whether escape are being processed. - * + * * @return {@code true} if escapes are processed */ public boolean isEscaping() { @@ -348,7 +348,7 @@ public class CSVFormat implements Serializable { /** * Specifies whether spaces around values are ignored when parsing input. - * + * * @return true if spaces around values are ignored, false if they are treated as part of the * value. */ @@ -358,7 +358,7 @@ public class CSVFormat implements Serializable { /** * Returns a copy of this format with the specified trimming behavior. - * + * * @param surroundingSpacesIgnored * the trimming behavior, true to remove the surrounding spaces, false to leave the * spaces as is. @@ -371,7 +371,7 @@ public class CSVFormat implements Serializable { /** * Specifies whether empty lines between records are ignored when parsing input. - * + * * @return true if empty lines between records are ignored, false if they are turned into empty * records. */ @@ -381,7 +381,7 @@ public class CSVFormat implements Serializable { /** * Returns a copy of this format with the specified empty line skipping behavior. - * + * * @param emptyLinesIgnored * the empty line skipping behavior, true to ignore the empty lines between the records, * false to translate empty lines to empty records. @@ -394,7 +394,7 @@ public class CSVFormat implements Serializable { /** * Returns the line separator delimiting output records. - * + * * @return the line separator */ public String getLineSeparator() { @@ -403,10 +403,10 @@ public class CSVFormat implements Serializable { /** * Returns a copy of this format using the specified output line separator. - * + * * @param lineSeparator * the line separator to be used for output. - * + * * @return A copy of this format using the specified output line separator */ public CSVFormat withLineSeparator(String lineSeparator) { @@ -421,20 +421,20 @@ public class CSVFormat implements Serializable { /** * Returns a copy of this format using the specified header. The header can either be parsed automatically from the * input file with: - * + * *
      * CSVFormat format = aformat.withHeader();
      * 
- * + * * or specified manually with: - * + * *
      * CSVFormat format = aformat.withHeader("name", "email", "phone");
      * 
- * + * * @param header * the header, null if disabled, empty if parsed automatically, user specified otherwise. - * + * * @return A copy of this format using the specified header */ public CSVFormat withHeader(String... header) { @@ -444,7 +444,7 @@ public class CSVFormat implements Serializable { /** * Parses the specified content. - * + * * @param in * the input stream */ @@ -454,7 +454,7 @@ public class CSVFormat implements Serializable { /** * Format the specified values. - * + * * @param values * the values to format */ diff --git a/src/main/java/org/apache/commons/csv/CSVLexer.java b/src/main/java/org/apache/commons/csv/CSVLexer.java index 0563b998..3f58fdb8 100644 --- a/src/main/java/org/apache/commons/csv/CSVLexer.java +++ b/src/main/java/org/apache/commons/csv/CSVLexer.java @@ -32,7 +32,7 @@ class CSVLexer extends Lexer { * Returns the next token. *

* A token corresponds to a term, a record change or an end-of-file indicator. - * + * * @param token * an existing Token object to reuse. The caller is responsible to initialize the Token. * @return the next token found @@ -128,7 +128,7 @@ class CSVLexer extends Lexer { *

  • end of stream has been reached (EOF)
  • *
  • an unescaped delimiter has been reached (TOKEN)
  • * - * + * * @param tkn * the current token * @param c @@ -179,7 +179,7 @@ class CSVLexer extends Lexer { *
  • end of line (EORECORD)
  • * *
  • end of stream has been reached (EOF)
  • - * + * * @param tkn * the current token * @return a valid token object diff --git a/src/main/java/org/apache/commons/csv/CSVParser.java b/src/main/java/org/apache/commons/csv/CSVParser.java index 41ef7b4e..1e241b4f 100644 --- a/src/main/java/org/apache/commons/csv/CSVParser.java +++ b/src/main/java/org/apache/commons/csv/CSVParser.java @@ -27,24 +27,29 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; - import static org.apache.commons.csv.Token.Type.*; /** * Parses CSV files according to the specified configuration. * - * Because CSV appears in many different dialects, the parser supports many - * configuration settings by allowing the specification of a {@link CSVFormat}. + * Because CSV appears in many different dialects, the parser supports many configuration settings by allowing the + * specification of a {@link CSVFormat}. + * + *

    + * Parsing of a csv-string having tabs as separators, '"' as an optional value encapsulator, and comments starting with + * '#': + *

    * - *

    Parsing of a csv-string having tabs as separators, - * '"' as an optional value encapsulator, and comments starting with '#':

    *
    - * CSVFormat format = new CSVFormat('\t', '"', '#');
    - * Reader in = new StringReader("a\tb\nc\td");
    - * List<CSVRecord> records = new CSVParser(in, format).getRecords();
    + * CSVFormat format = new CSVFormat('\t', '"', '#');
    + * Reader in = new StringReader("a\tb\nc\td");
    + * List<CSVRecord> records = new CSVParser(in, format).getRecords();
      * 
    * - *

    Parsing of a csv-string in Excel CSV format, using a for-each loop:

    + *

    + * Parsing of a csv-string in Excel CSV format, using a for-each loop: + *

    + * *
      * Reader in = new StringReader("a;b\nc;d");
      * CSVParser parser = new CSVParser(in, CSVFormat.EXCEL);
    @@ -54,11 +59,12 @@ import static org.apache.commons.csv.Token.Type.*;
      * 
    * *

    - * Internal parser state is completely covered by the format - * and the reader-state.

    + * Internal parser state is completely covered by the format and the reader-state. + *

    * - *

    see package documentation - * for more details

    + *

    + * see package documentation for more details + *

    */ public class CSVParser implements Iterable { @@ -74,8 +80,10 @@ public class CSVParser implements Iterable { /** * CSV parser using the default {@link CSVFormat}. * - * @param input a Reader containing "csv-formatted" input - * @throws IllegalArgumentException thrown if the parameters of the format are inconsistent + * @param input + * a Reader containing "csv-formatted" input + * @throws IllegalArgumentException + * thrown if the parameters of the format are inconsistent */ public CSVParser(Reader input) throws IOException { this(input, CSVFormat.DEFAULT); @@ -84,9 +92,12 @@ public class CSVParser implements Iterable { /** * Customized CSV parser using the given {@link CSVFormat} * - * @param input a Reader containing "csv-formatted" input - * @param format the CSVFormat used for CSV parsing - * @throws IllegalArgumentException thrown if the parameters of the format are inconsistent + * @param input + * a Reader containing "csv-formatted" input + * @param format + * the CSVFormat used for CSV parsing + * @throws IllegalArgumentException + * thrown if the parameters of the format are inconsistent */ public CSVParser(Reader input, CSVFormat format) throws IOException { format.validate(); @@ -99,23 +110,26 @@ public class CSVParser implements Iterable { /** * Customized CSV parser using the given {@link CSVFormat} * - * @param input a String containing "csv-formatted" input - * @param format the CSVFormat used for CSV parsing - * @throws IllegalArgumentException thrown if the parameters of the format are inconsistent + * @param input + * a String containing "csv-formatted" input + * @param format + * the CSVFormat used for CSV parsing + * @throws IllegalArgumentException + * thrown if the parameters of the format are inconsistent */ - public CSVParser(String input, CSVFormat format) throws IOException{ + public CSVParser(String input, CSVFormat format) throws IOException { this(new StringReader(input), format); } - /** - * Parses the CSV input according to the given format and returns the content - * as an array of {@link CSVRecord} entries. + * Parses the CSV input according to the given format and returns the content as an array of {@link CSVRecord} + * entries. *

    * The returned content starts at the current parse-position in the stream. * * @return list of {@link CSVRecord} entries, may be empty - * @throws IOException on parse error or input read-failure + * @throws IOException + * on parse error or input read-failure */ public List getRecords() throws IOException { List records = new ArrayList(); @@ -130,7 +144,8 @@ public class CSVParser implements Iterable { * Parses the next record from the current point in the stream. * * @return the record as an array of values, or null if the end of the stream has been reached - * @throws IOException on parse error or input read-failure + * @throws IOException + * on parse error or input read-failure */ CSVRecord getRecord() throws IOException { CSVRecord result = new CSVRecord(null, headerMapping, null); @@ -140,36 +155,36 @@ public class CSVParser implements Iterable { reusableToken.reset(); lexer.nextToken(reusableToken); switch (reusableToken.type) { - case TOKEN: + case TOKEN: + record.add(reusableToken.content.toString()); + break; + case EORECORD: + record.add(reusableToken.content.toString()); + break; + case EOF: + if (reusableToken.isReady) { record.add(reusableToken.content.toString()); - break; - case EORECORD: - record.add(reusableToken.content.toString()); - break; - case EOF: - if (reusableToken.isReady) { - record.add(reusableToken.content.toString()); - } else { - result = null; - } - break; - case INVALID: - throw new IOException("(line " + getLineNumber() + ") invalid parse sequence"); - case COMMENT: // Ignored currently - if (sb == null) { // first comment for this record - sb = new StringBuilder(); - } else { - sb.append("\n"); - } - sb.append(reusableToken.content); - reusableToken.type = TOKEN; // Read another token - break; + } else { + result = null; + } + break; + case INVALID: + throw new IOException("(line " + getLineNumber() + ") invalid parse sequence"); + case COMMENT: // Ignored currently + if (sb == null) { // first comment for this record + sb = new StringBuilder(); + } else { + sb.append("\n"); + } + sb.append(reusableToken.content); + reusableToken.type = TOKEN; // Read another token + break; } } while (reusableToken.type == TOKEN); if (!record.isEmpty()) { - result = new CSVRecord(record.toArray(new String[record.size()]), headerMapping, - sb == null ? null : sb.toString()); + result = new CSVRecord(record.toArray(new String[record.size()]), headerMapping, sb == null ? null + : sb.toString()); } return result; } @@ -204,8 +219,8 @@ public class CSVParser implements Iterable { } /** - * Returns an iterator on the records. IOExceptions occuring - * during the iteration are wrapped in a RuntimeException. + * Returns an iterator on the records. IOExceptions occuring during the iteration are wrapped in a + * RuntimeException. */ public Iterator iterator() { return new Iterator() { @@ -251,8 +266,7 @@ public class CSVParser implements Iterable { /** * Returns the current line number in the input stream. *

    - * ATTENTION: in case your csv has multiline-values the returned - * number does not correspond to the record-number + * ATTENTION: in case your csv has multiline-values the returned number does not correspond to the record-number * * @return current line number */ diff --git a/src/main/java/org/apache/commons/csv/CSVPrinter.java b/src/main/java/org/apache/commons/csv/CSVPrinter.java index ccea0a60..7590a617 100644 --- a/src/main/java/org/apache/commons/csv/CSVPrinter.java +++ b/src/main/java/org/apache/commons/csv/CSVPrinter.java @@ -35,12 +35,15 @@ public class CSVPrinter { /** * Create a printer that will print values to the given stream following the CSVFormat. *

    - * Currently, only a pure encapsulation format or a pure escaping format - * is supported. Hybrid formats (encapsulation and escaping with a different character) are not supported. + * Currently, only a pure encapsulation format or a pure escaping format is supported. Hybrid formats + * (encapsulation and escaping with a different character) are not supported. * - * @param out stream to which to print. - * @param format the CSV format. If null the default format is used ({@link CSVFormat#DEFAULT}) - * @throws IllegalArgumentException thrown if the parameters of the format are inconsistent + * @param out + * stream to which to print. + * @param format + * the CSV format. If null the default format is used ({@link CSVFormat#DEFAULT}) + * @throws IllegalArgumentException + * thrown if the parameters of the format are inconsistent */ public CSVPrinter(Appendable out, CSVFormat format) { this.out = out; @@ -49,7 +52,7 @@ public class CSVPrinter { } // ====================================================== - // printing implementation + // printing implementation // ====================================================== /** @@ -72,11 +75,11 @@ public class CSVPrinter { } /** - * Print a single line of comma separated values. - * The values will be quoted if needed. Quotes and - * newLine characters will be escaped. + * Print a single line of comma separated values. The values will be quoted if needed. Quotes and newLine + * characters will be escaped. * - * @param values values to be outputted. + * @param values + * values to be outputted. */ public void println(String... values) throws IOException { for (String value : values) { @@ -85,16 +88,15 @@ public class CSVPrinter { println(); } - /** - * Put a comment on a new line among the comma separated values. Comments - * will always begin on a new line and occupy a least one full line. The - * character specified to start comments and a space will be inserted at - * the beginning of each new line in the comment. + * Put a comment on a new line among the comma separated values. Comments will always begin on a new line and + * occupy a least one full line. The character specified to start comments and a space will be inserted at the + * beginning of each new line in the comment. *

    * If comments are disabled in the current CSV format this method does nothing. * - * @param comment the comment to output + * @param comment + * the comment to output */ public void printComment(String comment) throws IOException { if (!format.isCommentingEnabled()) { @@ -108,25 +110,24 @@ public class CSVPrinter { for (int i = 0; i < comment.length(); i++) { char c = comment.charAt(i); switch (c) { - case '\r': - if (i + 1 < comment.length() && comment.charAt(i + 1) == '\n') { - i++; - } + case '\r': + if (i + 1 < comment.length() && comment.charAt(i + 1) == '\n') { + i++; + } //$FALL-THROUGH$ break intentionally excluded. case '\n': - println(); - out.append(format.getCommentStart()); - out.append(' '); - break; - default: - out.append(c); - break; + println(); + out.append(format.getCommentStart()); + out.append(' '); + break; + default: + out.append(c); + break; } } println(); } - private void print(CharSequence value, int offset, int len) throws IOException { if (format.isEncapsulating()) { printAndEncapsulate(value, offset, len); @@ -185,7 +186,7 @@ public class CSVPrinter { } void printAndEncapsulate(CharSequence value, int offset, int len) throws IOException { - boolean first = newLine; // is this the first value on this line? + boolean first = newLine; // is this the first value on this line? boolean quote = false; int start = offset; int pos = offset; @@ -208,16 +209,12 @@ public class CSVPrinter { char c = value.charAt(pos); // Hmmm, where did this rule come from? - if (first - && (c < '0' - || (c > '9' && c < 'A') - || (c > 'Z' && c < 'a') - || (c > 'z'))) { + if (first && (c < '0' || (c > '9' && c < 'A') || (c > 'Z' && c < 'a') || (c > 'z'))) { quote = true; // } else if (c == ' ' || c == '\f' || c == '\t') { } else if (c <= '#') { // Some other chars at the start of a value caused the parser to fail, so for now - // encapsulate if we start in anything less than '#'. We are being conservative + // encapsulate if we start in anything less than '#'. We are being conservative // by including the default comment char too. quote = true; } else { @@ -274,10 +271,11 @@ public class CSVPrinter { } /** - * Print the string as the next value on the line. The value - * will be escaped or encapsulated as needed if checkForEscape==true + * Print the string as the next value on the line. The value will be escaped or encapsulated as needed if + * checkForEscape==true * - * @param value value to be outputted. + * @param value + * value to be outputted. */ public void print(String value, boolean checkForEscape) throws IOException { if (value == null) { @@ -295,10 +293,10 @@ public class CSVPrinter { } /** - * Print the string as the next value on the line. The value - * will be escaped or encapsulated as needed. + * Print the string as the next value on the line. The value will be escaped or encapsulated as needed. * - * @param value value to be outputted. + * @param value + * value to be outputted. */ public void print(String value) throws IOException { print(value, true); diff --git a/src/main/java/org/apache/commons/csv/CSVRecord.java b/src/main/java/org/apache/commons/csv/CSVRecord.java index bd25b106..3cab8d46 100644 --- a/src/main/java/org/apache/commons/csv/CSVRecord.java +++ b/src/main/java/org/apache/commons/csv/CSVRecord.java @@ -49,7 +49,8 @@ public class CSVRecord implements Serializable, Iterable { /** * Returns a value by index. * - * @param i the index of the column retrieved + * @param i + * the index of the column retrieved */ public String get(int i) { return values[i]; @@ -58,9 +59,11 @@ public class CSVRecord implements Serializable, Iterable { /** * Returns a value by name. * - * @param name the name of the column to be retrieved + * @param name + * the name of the column to be retrieved * @return the column value, or {@code null} if the column name is not found - * @throws IllegalStateException if no header mapping was provided + * @throws IllegalStateException + * if no header mapping was provided */ public String get(String name) { if (mapping == null) { @@ -83,6 +86,7 @@ public class CSVRecord implements Serializable, Iterable { public String getComment() { return comment; } + /** * Returns the number of values in this record. */ diff --git a/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java b/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java index 663aab9f..beb0fd5f 100644 --- a/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java +++ b/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java @@ -22,11 +22,9 @@ import java.io.IOException; import java.io.Reader; /** - * A special reader decorator which supports more - * sophisticated access to the underlying reader object. + * A special reader decorator which supports more sophisticated access to the underlying reader object. *

    - * In particular the reader supports a look-ahead option, - * which allows you to see the next char returned by + * In particular the reader supports a look-ahead option, which allows you to see the next char returned by * {@link #read()}. */ class ExtendedBufferedReader extends BufferedReader { @@ -65,12 +63,10 @@ class ExtendedBufferedReader extends BufferedReader { } /** - * Returns the last character that was read as an integer (0 to 65535). This - * will be the last character returned by any of the read methods. This will - * not include a character read using the {@link #peek()} method. If no - * character has been read then this will return {@link #UNDEFINED}. If the - * end of the stream was reached on the last read then this will return - * {@link #END_OF_STREAM}. + * Returns the last character that was read as an integer (0 to 65535). This will be the last character returned by + * any of the read methods. This will not include a character read using the {@link #peek()} method. If no + * character has been read then this will return {@link #UNDEFINED}. If the end of the stream was reached on the + * last read then this will return {@link #END_OF_STREAM}. * * @return the last character that was read */ @@ -91,7 +87,7 @@ class ExtendedBufferedReader extends BufferedReader { for (int i = offset; i < offset + len; i++) { char ch = buf[i]; if (ch == LF) { - if (CR != (i > 0 ? buf[i-1]: lastChar)) { + if (CR != (i > 0 ? buf[i - 1] : lastChar)) { lineCounter++; } } else if (ch == CR) { @@ -109,14 +105,12 @@ class ExtendedBufferedReader extends BufferedReader { } /** - * Calls {@link BufferedReader#readLine()} which drops the line terminator(s). - * This method should only be called when processing a comment, otherwise - * information can be lost. + * Calls {@link BufferedReader#readLine()} which drops the line terminator(s). This method should only be called + * when processing a comment, otherwise information can be lost. *

    - * Increments {@link #lineCounter} + * Increments {@link #lineCounter} *

    - * Sets {@link #lastChar} to {@link #END_OF_STREAM} at EOF, - * otherwise to LF + * Sets {@link #lastChar} to {@link #END_OF_STREAM} at EOF, otherwise to LF * * @return the line that was read, or null if reached EOF. */ @@ -135,12 +129,13 @@ class ExtendedBufferedReader extends BufferedReader { } /** - * Returns the next character in the current reader without consuming it. So - * the next call to {@link #read()} will still return this value. + * Returns the next character in the current reader without consuming it. So the next call to {@link #read()} will + * still return this value. * * @return the next character * - * @throws IOException if there is an error in reading + * @throws IOException + * if there is an error in reading */ int lookAhead() throws IOException { super.mark(1); diff --git a/src/main/java/org/apache/commons/csv/Lexer.java b/src/main/java/org/apache/commons/csv/Lexer.java index 20200501..31743b53 100644 --- a/src/main/java/org/apache/commons/csv/Lexer.java +++ b/src/main/java/org/apache/commons/csv/Lexer.java @@ -64,20 +64,20 @@ abstract class Lexer { // assume c is the escape char (normally a backslash) int c = in.read(); switch (c) { - case 'r': - return '\r'; - case 'n': - return '\n'; - case 't': - return '\t'; - case 'b': - return '\b'; - case 'f': - return '\f'; - case ExtendedBufferedReader.END_OF_STREAM: - throw new IOException("EOF whilst processing escape sequence"); - default: - return c; + case 'r': + return '\r'; + case 'n': + return '\n'; + case 't': + return '\t'; + case 'b': + return '\b'; + case 'f': + return '\f'; + case ExtendedBufferedReader.END_OF_STREAM: + throw new IOException("EOF whilst processing escape sequence"); + default: + return c; } } @@ -99,8 +99,7 @@ abstract class Lexer { } /** - * Greedy - accepts \n, \r and \r\n - * This checker consumes silently the second control-character... + * Greedy - accepts \n, \r and \r\n This checker consumes silently the second control-character... * * @return true if the given character is a line-terminator */ @@ -114,8 +113,7 @@ abstract class Lexer { } /** - * Checks if the current character represents the start of a line: - * a CR, LF or is at the start of the file. + * Checks if the current character represents the start of a line: a CR, LF or is at the start of the file. * * @param c * @return true if the character is at the start of a line. @@ -123,6 +121,7 @@ abstract class Lexer { boolean isStartOfLine(int c) { return c == '\n' || c == '\r' || c == ExtendedBufferedReader.UNDEFINED; } + /** * @return true if the given character indicates end of file */ diff --git a/src/main/java/org/apache/commons/csv/Token.java b/src/main/java/org/apache/commons/csv/Token.java index 42e4b775..0ceff9e3 100644 --- a/src/main/java/org/apache/commons/csv/Token.java +++ b/src/main/java/org/apache/commons/csv/Token.java @@ -65,6 +65,6 @@ class Token { // Provide toString method for IDE debugging @Override public String toString() { - return type.name()+" ["+content.toString()+"]"; + return type.name() + " [" + content.toString() + "]"; } }