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