Made the static fields final in CSVStrategy

git-svn-id: https://svn.apache.org/repos/asf/commons/sandbox/csv/trunk@1199768 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Bourg 2011-11-09 14:16:22 +00:00
parent e6e80741d8
commit 43b777b982
1 changed files with 27 additions and 41 deletions

View File

@ -41,16 +41,13 @@ public class CSVStrategy implements Cloneable, Serializable {
// an EOF signal (-1), and because \ufffe in UTF-16 would be // an EOF signal (-1), and because \ufffe in UTF-16 would be
// encoded as two chars (using surrogates) and thus there should never // encoded as two chars (using surrogates) and thus there should never
// be a collision with a real text char. // be a collision with a real text char.
public static char COMMENTS_DISABLED = (char) -2; public static final char COMMENTS_DISABLED = (char) -2;
public static char ESCAPE_DISABLED = (char) -2; public static final char ESCAPE_DISABLED = (char) -2;
public static char ENCAPSULATOR_DISABLED = (char) -2; public static final char ENCAPSULATOR_DISABLED = (char) -2;
public static CSVStrategy DEFAULT_STRATEGY = new CSVStrategy(',', '"', COMMENTS_DISABLED, ESCAPE_DISABLED, true, public static final CSVStrategy DEFAULT_STRATEGY = new CSVStrategy(',', '"', COMMENTS_DISABLED, ESCAPE_DISABLED, true, true, false, true);
true, false, true); public static final CSVStrategy EXCEL_STRATEGY = new CSVStrategy(',', '"', COMMENTS_DISABLED, ESCAPE_DISABLED, false, false, false, false);
public static CSVStrategy EXCEL_STRATEGY = new CSVStrategy(',', '"', COMMENTS_DISABLED, ESCAPE_DISABLED, false, public static final CSVStrategy TDF_STRATEGY = new CSVStrategy('\t', '"', COMMENTS_DISABLED, ESCAPE_DISABLED, true, true, false, true);
false, false, false);
public static CSVStrategy TDF_STRATEGY = new CSVStrategy('\t', '"', COMMENTS_DISABLED, ESCAPE_DISABLED, true,
true, false, true);
public CSVStrategy(char delimiter, char encapsulator, char commentStart) { public CSVStrategy(char delimiter, char encapsulator, char commentStart) {
@ -58,18 +55,15 @@ public class CSVStrategy implements Cloneable, Serializable {
} }
/** /**
* Customized CSV strategy setter. * Customized CSV strategy constructor.
* *
* @param delimiter a Char used for value separation * @param delimiter a char used for value separation
* @param encapsulator a Char used as value encapsulation marker * @param encapsulator a char used as value encapsulation marker
* @param commentStart a Char used for comment identification * @param commentStart a char used for comment identification
* @param escape a Char used to escape special characters in values * @param escape a char used to escape special characters in values
* @param ignoreLeadingWhitespace TRUE when leading whitespaces should be * @param ignoreLeadingWhitespaces TRUE when leading whitespaces should be ignored
* ignored * @param ignoreTrailingWhitespaces TRUE when trailing whitespaces should be ignored
* @param ignoreTrailingWhitespace TRUE when trailing whitespaces should be * @param interpretUnicodeEscapes TRUE when unicode escapes should be interpreted
* ignored
* @param interpretUnicodeEscapes TRUE when unicode escapes should be
* interpreted
* @param ignoreEmptyLines TRUE when the parser should skip emtpy lines * @param ignoreEmptyLines TRUE when the parser should skip emtpy lines
*/ */
public CSVStrategy( public CSVStrategy(
@ -77,18 +71,18 @@ public class CSVStrategy implements Cloneable, Serializable {
char encapsulator, char encapsulator,
char commentStart, char commentStart,
char escape, char escape,
boolean ignoreLeadingWhitespace, boolean ignoreLeadingWhitespaces,
boolean ignoreTrailingWhitespace, boolean ignoreTrailingWhitespaces,
boolean interpretUnicodeEscapes, boolean interpretUnicodeEscapes,
boolean ignoreEmptyLines) { boolean ignoreEmptyLines) {
setDelimiter(delimiter); this.delimiter = delimiter;
setEncapsulator(encapsulator); this.encapsulator = encapsulator;
setCommentStart(commentStart); this.commentStart = commentStart;
setEscape(escape); this.escape = escape;
setIgnoreLeadingWhitespaces(ignoreLeadingWhitespace); this.ignoreLeadingWhitespaces = ignoreLeadingWhitespaces;
setIgnoreTrailingWhitespaces(ignoreTrailingWhitespace); this.ignoreTrailingWhitespaces = ignoreTrailingWhitespaces;
setUnicodeEscapeInterpretation(interpretUnicodeEscapes); this.interpretUnicodeEscapes = interpretUnicodeEscapes;
setIgnoreEmptyLines(ignoreEmptyLines); this.ignoreEmptyLines = ignoreEmptyLines;
} }
/** /**
@ -98,10 +92,10 @@ public class CSVStrategy implements Cloneable, Serializable {
char delimiter, char delimiter,
char encapsulator, char encapsulator,
char commentStart, char commentStart,
boolean ignoreLeadingWhitespace, boolean ignoreLeadingWhitespaces,
boolean interpretUnicodeEscapes, boolean interpretUnicodeEscapes,
boolean ignoreEmptyLines) { boolean ignoreEmptyLines) {
this(delimiter, encapsulator, commentStart, CSVStrategy.ESCAPE_DISABLED, ignoreLeadingWhitespace, this(delimiter, encapsulator, commentStart, CSVStrategy.ESCAPE_DISABLED, ignoreLeadingWhitespaces,
true, interpretUnicodeEscapes, ignoreEmptyLines); true, interpretUnicodeEscapes, ignoreEmptyLines);
} }
@ -165,18 +159,10 @@ public class CSVStrategy implements Cloneable, Serializable {
return this.interpretUnicodeEscapes; return this.interpretUnicodeEscapes;
} }
public void setIgnoreEmptyLines(boolean ignoreEmptyLines) {
this.ignoreEmptyLines = ignoreEmptyLines;
}
public boolean getIgnoreEmptyLines() { public boolean getIgnoreEmptyLines() {
return this.ignoreEmptyLines; return this.ignoreEmptyLines;
} }
public void setPrinterNewline(String newline) {
this.printerNewline = newline;
}
public String getPrinterNewline() { public String getPrinterNewline() {
return this.printerNewline; return this.printerNewline;
} }