BeanIO 1.2.3

org.beanio.stream.csv
Class CsvReaderConfiguration

java.lang.Object
  extended by org.beanio.stream.csv.CsvReaderConfiguration
Direct Known Subclasses:
CsvReaderFactory

public class CsvReaderConfiguration
extends Object

Stores configuration settings for a CsvReader.

Since:
1.2
Author:
Kevin Seim
See Also:
CsvReader

Constructor Summary
CsvReaderConfiguration()
          Constructs a new CsvReaderConfiguration.
 
Method Summary
 String[] getComments()
          Returns the array of comment prefixes.
 char getDelimiter()
          Returns the field delimiter.
 Character getEscape()
          Returns the escape character.
 char getQuote()
          Returns the character to use for a quotation mark.
 boolean isCommentEnabled()
          Returns whether one or more comment prefixes have been configured.
 boolean isEscapeEnabled()
          Returns whether escaping is enabled.
 boolean isMultilineEnabled()
          Returns whether a record may span multiple lines (when quoted).
 boolean isUnquotedQuotesAllowed()
          Returns whether quotes are allowed to appear in an unquoted field.
 boolean isWhitespaceAllowed()
          Returns whether to ignore unquoted whitespace.
 void setComments(String[] comments)
          Sets the array of comment prefixes.
 void setDelimiter(char c)
          Sets the field delimiter.
 void setEscape(Character c)
          Sets the escape character.
 void setMultilineEnabled(boolean multilineEnabled)
          Sets whether a record may span multiple lines (when quoted).
 void setQuote(char quote)
          Sets the character to use for a quotation mark.
 void setUnquotedQuotesAllowed(boolean unquotedQuotesAllowed)
          Sets wheter quotes are allowed to appear in an unquoted field.
 void setWhitespaceAllowed(boolean whitespaceAllowed)
          Sets whether unquoted whitespace is ignored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CsvReaderConfiguration

public CsvReaderConfiguration()
Constructs a new CsvReaderConfiguration.

Method Detail

setDelimiter

public void setDelimiter(char c)
Sets the field delimiter. By default, the delimiter is a comma.

Parameters:
c - the character used to delimit fields

getDelimiter

public char getDelimiter()
Returns the field delimiter. By default, the delimiter is a comma.

Returns:
the character used to delimit fields

getQuote

public char getQuote()
Returns the character to use for a quotation mark. Defaults to '"'.

Returns:
the quotation mark character

setQuote

public void setQuote(char quote)
Sets the character to use for a quotation mark.

Parameters:
quote - the new quotation mark character

setEscape

public void setEscape(Character c)
Sets the escape character. Quotation marks can be escaped within quoted values using the escape character. For example, using the default escape character, '"Hello ""friend"""' is parsed into 'Hello "friend"'. Set to null to disable escaping.

Parameters:
c - new escape character

getEscape

public Character getEscape()
Returns the escape character. Quotation marks can be escaped within quoted values using the escape character. For example, using the default escape character, '"Hello ""friend"""' is parsed into 'Hello "friend"'. Defaults to the quotation mark, ".

Returns:
the escape character or null if escaping is disabled

isEscapeEnabled

public boolean isEscapeEnabled()
Returns whether escaping is enabled. By default, escaping is enabled.

Returns:
true if an escape character is enabled
See Also:
getEscape()

isMultilineEnabled

public boolean isMultilineEnabled()
Returns whether a record may span multiple lines (when quoted). Defaults to false.

Returns:
true if a record may span multiple lines

setMultilineEnabled

public void setMultilineEnabled(boolean multilineEnabled)
Sets whether a record may span multiple lines (when quoted).

Parameters:
multilineEnabled - set to true true to allow records to span multiple lines

isWhitespaceAllowed

public boolean isWhitespaceAllowed()
Returns whether to ignore unquoted whitespace. Returns false by default which causes the following record cause an exception:
 "Field1", "Field2"
          ^
        Unquoted whitespace here
 

Returns:
true if unquoted whitespace is allowed

setWhitespaceAllowed

public void setWhitespaceAllowed(boolean whitespaceAllowed)
Sets whether unquoted whitespace is ignored.

Parameters:
whitespaceAllowed - set to true to ignore unquoted whitespace

isUnquotedQuotesAllowed

public boolean isUnquotedQuotesAllowed()
Returns whether quotes are allowed to appear in an unquoted field. Set to false by default which will cause the following record to throw an exception:
 Field1,Field"2,Field3
 

Returns:
true if quotes may appear in an unquoted field

setUnquotedQuotesAllowed

public void setUnquotedQuotesAllowed(boolean unquotedQuotesAllowed)
Sets wheter quotes are allowed to appear in an unquoted field.

Parameters:
unquotedQuotesAllowed - set to true if quotes may appear in an unquoted field

getComments

public String[] getComments()
Returns the array of comment prefixes. If a line read from a stream begins with a configured comment prefix, the line is ignored. By default, no lines are considered commented.

Returns:
the array of comment prefixes

setComments

public void setComments(String[] comments)
Sets the array of comment prefixes. If a line read from a stream begins with a configured comment prefix, the line is ignored.

Parameters:
comments - the array of comment prefixes

isCommentEnabled

public boolean isCommentEnabled()
Returns whether one or more comment prefixes have been configured.

Returns:
true if one or more comment prefixes have been configured

BeanIO 1.2.3

Copyright © 2010-2012 Kevin Seim