@@ -28,30 +28,31 @@ public class CSVFormat implements Cloneable, Serializable {
2828
2929 private char delimiter = ',' ;
3030 private char encapsulator = '"' ;
31- private char commentStart = COMMENTS_DISABLED ;
32- private char escape = ESCAPE_DISABLED ;
31+ private char commentStart = DISABLED ;
32+ private char escape = DISABLED ;
3333 private boolean leadingSpacesIgnored = true ;
3434 private boolean trailingSpacesIgnored = true ;
3535 private boolean unicodeEscapesInterpreted = false ;
3636 private boolean emptyLinesIgnored = true ;
3737 private String lineSeparator = "\n " ;
3838
39- // -2 is used to signal disabled, because it won't be confused with
40- // an EOF signal (-1), and because \ufffe in UTF-16 would be
41- // encoded as two chars (using surrogates) and thus there should never
42- // be a collision with a real text char.
43- public static final char COMMENTS_DISABLED = (char ) -2 ;
44- public static final char ESCAPE_DISABLED = (char ) -2 ;
45- public static final char ENCAPSULATOR_DISABLED = (char ) -2 ;
39+
40+ /**
41+ * Constant char to be used for disabling comments, escapes and encapsulation.
42+ * The value -2 is used because it won't be confused with an EOF signal (-1),
43+ * and because the unicode value FFFE would be encoded as two chars (using surrogates)
44+ * and thus there should never be a collision with a real text char.
45+ */
46+ public static final char DISABLED = '\ufffe' ;
4647
4748 /** Standard comma separated format. */
48- public static final CSVFormat DEFAULT = new CSVFormat (',' , '"' , COMMENTS_DISABLED , ESCAPE_DISABLED , true , true , false , true );
49-
49+ public static final CSVFormat DEFAULT = new CSVFormat (',' , '"' , DISABLED , DISABLED , true , true , false , true );
50+
5051 /** Excel file format (using a comma as the value delimiter). */
51- public static final CSVFormat EXCEL = new CSVFormat (',' , '"' , COMMENTS_DISABLED , ESCAPE_DISABLED , false , false , false , false );
52-
52+ public static final CSVFormat EXCEL = new CSVFormat (',' , '"' , DISABLED , DISABLED , false , false , false , false );
53+
5354 /** Tabulation delimited format. */
54- public static final CSVFormat TDF = new CSVFormat ('\t' , '"' , COMMENTS_DISABLED , ESCAPE_DISABLED , true , true , false , true );
55+ public static final CSVFormat TDF = new CSVFormat ('\t' , '"' , DISABLED , DISABLED , true , true , false , true );
5556
5657
5758 /**
@@ -61,7 +62,7 @@ public CSVFormat() {
6162 }
6263
6364 public CSVFormat (char delimiter , char encapsulator , char commentStart ) {
64- this (delimiter , encapsulator , commentStart , ESCAPE_DISABLED , true , true , false , true );
65+ this (delimiter , encapsulator , commentStart , DISABLED , true , true , false , true );
6566 }
6667
6768 /**
@@ -115,6 +116,10 @@ public CSVFormat withEncapsulator(char encapsulator) {
115116 return format ;
116117 }
117118
119+ boolean isEncapsulating () {
120+ return this .encapsulator != DISABLED ;
121+ }
122+
118123 public char getCommentStart () {
119124 return commentStart ;
120125 }
@@ -126,7 +131,7 @@ public CSVFormat withCommentStart(char commentStart) {
126131 }
127132
128133 public boolean isCommentingDisabled () {
129- return this .commentStart == COMMENTS_DISABLED ;
134+ return this .commentStart == DISABLED ;
130135 }
131136
132137 public char getEscape () {
@@ -139,6 +144,10 @@ public CSVFormat withEscape(char escape) {
139144 return format ;
140145 }
141146
147+ boolean isEscaping () {
148+ return this .escape != DISABLED ;
149+ }
150+
142151 public boolean isLeadingSpacesIgnored () {
143152 return leadingSpacesIgnored ;
144153 }
0 commit comments