Skip to content

Commit 02b2146

Browse files
committed
SANDBOX-322: CSVPrinter overhaul
git-svn-id: https://svn.apache.org/repos/asf/commons/sandbox/csv/trunk@955284 13f79535-47bb-0310-9956-ffa450edef68
1 parent 404b05e commit 02b2146

7 files changed

Lines changed: 421 additions & 240 deletions

File tree

src/java/org/apache/commons/csv/CSVParser.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ public class CSVParser {
7070
// the input stream
7171
private final ExtendedBufferedReader in;
7272

73-
// TODO: this can be made final if setStrategy is removed
74-
private CSVStrategy strategy;
73+
private final CSVStrategy strategy;
7574

7675
// the following objects are shared to reduce garbage
7776
/** A record buffer for getLine(). Grows as necessary and is reused. */
@@ -346,7 +345,7 @@ protected Token nextToken(Token tkn) throws IOException {
346345
// important: make sure a new char gets consumed in each iteration
347346
while (!tkn.isReady) {
348347
// ignore whitespaces at beginning of a token
349-
while (isWhitespace(c) && !eol) {
348+
while (strategy.getIgnoreLeadingWhitespaces() && isWhitespace(c) && !eol) {
350349
wsBuf.append((char) c);
351350
c = in.read();
352351
eol = isEndOfLine(c);
@@ -561,18 +560,7 @@ private int readEscape(int c) throws IOException {
561560
// ======================================================
562561

563562
/**
564-
* Sets the specified CSV Strategy
565-
*
566-
* @return current instance of CSVParser to allow chained method calls
567-
* @deprecated the strategy should be set in the constructor {@link #CSVParser(Reader,CSVStrategy)}.
568-
*/
569-
public CSVParser setStrategy(CSVStrategy strategy) {
570-
this.strategy = strategy;
571-
return this;
572-
}
573-
574-
/**
575-
* Obtain the specified CSV Strategy
563+
* Obtain the specified CSV Strategy. This should not be modified.
576564
*
577565
* @return strategy currently being used
578566
*/

0 commit comments

Comments
 (0)