If you think the Android project texthem listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/**
Copyright 2005 Bytecode Pty Ltd.//fromwww.java2s.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/package au.com.bytecode.opencsv;
importstatic au.com.bytecode.opencsv.CSVParser.*;
/**
* Builder for creating a CSVParser.
* <p/>
* <code>
* final CSVParser parser =
* new CSVParserBuilder()
* .withSeparator('\t')
* .withIgnoreQuotations(true)
* .build();
* </code>
*
* @see CSVParser
*/publicclass CSVParserBuilder {
char separator = DEFAULT_SEPARATOR;
char quoteChar = DEFAULT_QUOTE_CHARACTER;
char escapeChar = DEFAULT_ESCAPE_CHARACTER;
boolean strictQuotes = DEFAULT_STRICT_QUOTES;
boolean ignoreLeadingWhiteSpace = DEFAULT_IGNORE_LEADING_WHITESPACE;
boolean ignoreQuotations = DEFAULT_IGNORE_QUOTATIONS;
/**
* Sets the delimiter to use for separating entries
*
* @param separator the delimiter to use for separating entries
*/
CSVParserBuilder withSeparator(
finalchar separator) {
this.separator = separator;
returnthis;
}
/**
* Sets the character to use for quoted elements
*
* @param quotechar the character to use for quoted elements
*/
CSVParserBuilder withQuoteChar(
finalchar quoteChar) {
this.quoteChar = quoteChar;
returnthis;
}
/**
* Sets the character to use for escaping a separator or quote
*
* @param escape the character to use for escaping a separator or quote
*/
CSVParserBuilder withEscapeChar(
finalchar escapeChar) {
this.escapeChar = escapeChar;
returnthis;
}
/**
* Sets the strict quotes setting - if true, characters
* outside the quotes are ignored
*
* @param strictQuotes if true, characters outside the quotes are ignored
*/
CSVParserBuilder withStrictQuotes(
finalboolean strictQuotes) {
this.strictQuotes = strictQuotes;
returnthis;
}
/**
* Sets the ignore leading whitespace setting - if true, white space
* in front of a quote in a field is ignored
*
* @param ignoreLeadingWhiteSpace if true, white space in front of a quote in a field is ignored
*/
CSVParserBuilder withIgnoreLeadingWhiteSpace(
finalboolean ignoreLeadingWhiteSpace) {
this.ignoreLeadingWhiteSpace = ignoreLeadingWhiteSpace;
returnthis;
}
/**
* Sets the ignore quotations mode - if true, quotations are ignored
*
* @param ignoreQuotations if true, quotations are ignored
*/
CSVParserBuilder withIgnoreQuotations(
finalboolean ignoreQuotations) {
this.ignoreQuotations = ignoreQuotations;
returnthis;
}
/**
* Constructs CSVParser
*/
CSVParser build() {
returnnew CSVParser(
separator,
quoteChar,
escapeChar,
strictQuotes,
ignoreLeadingWhiteSpace,
ignoreQuotations);
}
}