2020
2121/**
2222 * CSVStrategy
23- *
23+ *
2424 * Represents the strategy for a CSV.
2525 */
2626public class CSVStrategy implements Cloneable , Serializable {
@@ -41,47 +41,46 @@ public class CSVStrategy implements Cloneable, Serializable {
4141 // an EOF signal (-1), and because \ufffe in UTF-16 would be
4242 // encoded as two chars (using surrogates) and thus there should never
4343 // be a collision with a real text char.
44- public static char COMMENTS_DISABLED = (char )-2 ;
45- public static char ESCAPE_DISABLED = (char )-2 ;
46- public static char ENCAPSULATOR_DISABLED = (char )-2 ;
44+ public static char COMMENTS_DISABLED = (char ) -2 ;
45+ public static char ESCAPE_DISABLED = (char ) -2 ;
46+ public static char ENCAPSULATOR_DISABLED = (char ) -2 ;
4747
48- public static CSVStrategy DEFAULT_STRATEGY = new CSVStrategy (',' , '"' , COMMENTS_DISABLED , ESCAPE_DISABLED , true ,
49- true , false , true );
50- public static CSVStrategy EXCEL_STRATEGY = new CSVStrategy (',' , '"' , COMMENTS_DISABLED , ESCAPE_DISABLED , false ,
51- false , false , false );
52- public static CSVStrategy TDF_STRATEGY = new CSVStrategy ('\t' , '"' , COMMENTS_DISABLED , ESCAPE_DISABLED , true ,
53- true , false , true );
48+ public static CSVStrategy DEFAULT_STRATEGY = new CSVStrategy (',' , '"' , COMMENTS_DISABLED , ESCAPE_DISABLED , true ,
49+ true , false , true );
50+ public static CSVStrategy EXCEL_STRATEGY = new CSVStrategy (',' , '"' , COMMENTS_DISABLED , ESCAPE_DISABLED , false ,
51+ false , false , false );
52+ public static CSVStrategy TDF_STRATEGY = new CSVStrategy ('\t' , '"' , COMMENTS_DISABLED , ESCAPE_DISABLED , true ,
53+ true , false , true );
5454
5555
5656 public CSVStrategy (char delimiter , char encapsulator , char commentStart ) {
5757 this (delimiter , encapsulator , commentStart , true , false , true );
5858 }
59-
59+
6060 /**
6161 * Customized CSV strategy setter.
6262 *
63- * @param delimiter a Char used for value separation
64- * @param encapsulator a Char used as value encapsulation marker
65- * @param commentStart a Char used for comment identification
66- * @param escape a Char used to escape special characters in values
67- * @param ignoreLeadingWhitespace TRUE when leading whitespaces should be
68- * ignored
63+ * @param delimiter a Char used for value separation
64+ * @param encapsulator a Char used as value encapsulation marker
65+ * @param commentStart a Char used for comment identification
66+ * @param escape a Char used to escape special characters in values
67+ * @param ignoreLeadingWhitespace TRUE when leading whitespaces should be
68+ * ignored
6969 * @param ignoreTrailingWhitespace TRUE when trailing whitespaces should be
70- * ignored
71- * @param interpretUnicodeEscapes TRUE when unicode escapes should be
72- * interpreted
73- * @param ignoreEmptyLines TRUE when the parser should skip emtpy lines
70+ * ignored
71+ * @param interpretUnicodeEscapes TRUE when unicode escapes should be
72+ * interpreted
73+ * @param ignoreEmptyLines TRUE when the parser should skip emtpy lines
7474 */
7575 public CSVStrategy (
76- char delimiter ,
77- char encapsulator ,
78- char commentStart ,
79- char escape ,
80- boolean ignoreLeadingWhitespace ,
81- boolean ignoreTrailingWhitespace ,
82- boolean interpretUnicodeEscapes ,
83- boolean ignoreEmptyLines )
84- {
76+ char delimiter ,
77+ char encapsulator ,
78+ char commentStart ,
79+ char escape ,
80+ boolean ignoreLeadingWhitespace ,
81+ boolean ignoreTrailingWhitespace ,
82+ boolean interpretUnicodeEscapes ,
83+ boolean ignoreEmptyLines ) {
8584 setDelimiter (delimiter );
8685 setEncapsulator (encapsulator );
8786 setCommentStart (commentStart );
@@ -92,62 +91,101 @@ public CSVStrategy(
9291 setIgnoreEmptyLines (ignoreEmptyLines );
9392 }
9493
95- /** @deprecated */
94+ /**
95+ * @deprecated
96+ */
9697 public CSVStrategy (
97- char delimiter ,
98- char encapsulator ,
99- char commentStart ,
100- boolean ignoreLeadingWhitespace ,
101- boolean interpretUnicodeEscapes ,
102- boolean ignoreEmptyLines )
103- {
104- this (delimiter , encapsulator , commentStart , CSVStrategy .ESCAPE_DISABLED , ignoreLeadingWhitespace ,
105- true , interpretUnicodeEscapes , ignoreEmptyLines );
98+ char delimiter ,
99+ char encapsulator ,
100+ char commentStart ,
101+ boolean ignoreLeadingWhitespace ,
102+ boolean interpretUnicodeEscapes ,
103+ boolean ignoreEmptyLines ) {
104+ this (delimiter , encapsulator , commentStart , CSVStrategy .ESCAPE_DISABLED , ignoreLeadingWhitespace ,
105+ true , interpretUnicodeEscapes , ignoreEmptyLines );
106+ }
107+
108+ public void setDelimiter (char delimiter ) {
109+ this .delimiter = delimiter ;
110+ }
111+
112+ public char getDelimiter () {
113+ return this .delimiter ;
114+ }
115+
116+ public void setEncapsulator (char encapsulator ) {
117+ this .encapsulator = encapsulator ;
118+ }
119+
120+ public char getEncapsulator () {
121+ return this .encapsulator ;
122+ }
123+
124+ public void setCommentStart (char commentStart ) {
125+ this .commentStart = commentStart ;
106126 }
107127
108- public void setDelimiter (char delimiter ) { this .delimiter = delimiter ; }
109- public char getDelimiter () { return this .delimiter ; }
128+ public char getCommentStart () {
129+ return this .commentStart ;
130+ }
131+
132+ public boolean isCommentingDisabled () {
133+ return this .commentStart == COMMENTS_DISABLED ;
134+ }
135+
136+ public void setEscape (char escape ) {
137+ this .escape = escape ;
138+ }
139+
140+ public char getEscape () {
141+ return this .escape ;
142+ }
110143
111- public void setEncapsulator (char encapsulator ) { this .encapsulator = encapsulator ; }
112- public char getEncapsulator () { return this .encapsulator ; }
144+ public void setIgnoreLeadingWhitespaces (boolean ignoreLeadingWhitespaces ) {
145+ this .ignoreLeadingWhitespaces = ignoreLeadingWhitespaces ;
146+ }
113147
114- public void setCommentStart ( char commentStart ) { this . commentStart = commentStart ; }
115- public char getCommentStart () { return this .commentStart ; }
116- public boolean isCommentingDisabled () { return this . commentStart == COMMENTS_DISABLED ; }
148+ public boolean getIgnoreLeadingWhitespaces ( ) {
149+ return this .ignoreLeadingWhitespaces ;
150+ }
117151
118- public void setEscape (char escape ) { this .escape = escape ; }
119- public char getEscape () { return this .escape ; }
152+ public void setIgnoreTrailingWhitespaces (boolean ignoreTrailingWhitespaces ) {
153+ this .ignoreTrailingWhitespaces = ignoreTrailingWhitespaces ;
154+ }
120155
121- public void setIgnoreLeadingWhitespaces ( boolean ignoreLeadingWhitespaces ) {
122- this .ignoreLeadingWhitespaces = ignoreLeadingWhitespaces ;
156+ public boolean getIgnoreTrailingWhitespaces ( ) {
157+ return this .ignoreTrailingWhitespaces ;
123158 }
124- public boolean getIgnoreLeadingWhitespaces () { return this .ignoreLeadingWhitespaces ; }
125159
126- public void setIgnoreTrailingWhitespaces (boolean ignoreTrailingWhitespaces ) {
127- this .ignoreTrailingWhitespaces = ignoreTrailingWhitespaces ;
160+ public void setUnicodeEscapeInterpretation (boolean interpretUnicodeEscapes ) {
161+ this .interpretUnicodeEscapes = interpretUnicodeEscapes ;
128162 }
129- public boolean getIgnoreTrailingWhitespaces () { return this .ignoreTrailingWhitespaces ; }
130163
131- public void setUnicodeEscapeInterpretation ( boolean interpretUnicodeEscapes ) {
132- this .interpretUnicodeEscapes = interpretUnicodeEscapes ;
164+ public boolean getUnicodeEscapeInterpretation ( ) {
165+ return this .interpretUnicodeEscapes ;
133166 }
134- public boolean getUnicodeEscapeInterpretation () { return this .interpretUnicodeEscapes ; }
135167
136- public void setIgnoreEmptyLines (boolean ignoreEmptyLines ) { this .ignoreEmptyLines = ignoreEmptyLines ; }
137- public boolean getIgnoreEmptyLines () { return this .ignoreEmptyLines ; }
168+ public void setIgnoreEmptyLines (boolean ignoreEmptyLines ) {
169+ this .ignoreEmptyLines = ignoreEmptyLines ;
170+ }
171+
172+ public boolean getIgnoreEmptyLines () {
173+ return this .ignoreEmptyLines ;
174+ }
138175
139176 public void setPrinterNewline (String newline ) {
140- this .printerNewline = newline ;
177+ this .printerNewline = newline ;
141178 }
179+
142180 public String getPrinterNewline () {
143- return this .printerNewline ;
181+ return this .printerNewline ;
144182 }
145183
146184 public Object clone () {
147- try {
148- return super .clone ();
149- } catch (CloneNotSupportedException e ) {
150- throw new RuntimeException (e ); // impossible
151- }
185+ try {
186+ return super .clone ();
187+ } catch (CloneNotSupportedException e ) {
188+ throw new RuntimeException (e ); // impossible
189+ }
152190 }
153191}
0 commit comments