com.univocity.api.entity.text.csv
Class CsvFormat

java.lang.Object
  extended by com.univocity.api.entity.Configuration
      extended by com.univocity.api.entity.text.TextFormat
          extended by com.univocity.api.entity.text.csv.CsvFormat

public final class CsvFormat
extends TextFormat

The CSV format configuration class. Used by CSV data entities in CsvEntityConfiguration.

It provides the following configuration options (in addition to the ones in TextFormat):

Author:
uniVocity Software Pty Ltd - dev@univocity.com
See Also:
CsvEntityConfiguration, TextFormat

Constructor Summary
CsvFormat()
           
 
Method Summary
protected  void copyDefaultsFrom(Configuration defaultConfig)
          Applies default values to undefined settings using a Configuration object.
 char getDelimiter()
          Returns the field delimiter character.
 char getQuote()
          Returns the character used for escaping values where the field delimiter is part of the value.
 char getQuoteEscape()
          Returns the character used for escaping quotes inside an already quoted value.
 boolean isDelimiter(char ch)
          Identifies whether or not a given character is the field delimiter used to separate individual fields in a CSV record.
 boolean isQuote(char ch)
          Identifies whether or not a given character is used for escaping values where the field delimiter is part of the value
 boolean isQuoteEscape(char ch)
          Identifies whether or not a given character is used for escaping quotes inside an already quoted value.
 void setDelimiter(char delimiter)
          Defines the field delimiter character.
 void setQuote(char quote)
          Defines the character used for escaping values where the field delimiter is part of the value.
 void setQuoteEscape(char quoteEscape)
          Defines the character used for escaping quotes inside an already quoted value.
 
Methods inherited from class com.univocity.api.entity.text.TextFormat
getComment, getLineSeparator, getLineSeparatorString, getNormalizedNewline, isComment, isLineSeparator, isLineSeparator, isNormalizedNewLine, setComment, setLineSeparator, setLineSeparator, setNormalizedNewline
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CsvFormat

public CsvFormat()
Method Detail

getQuote

public final char getQuote()
Returns the character used for escaping values where the field delimiter is part of the value.

e.g. the value " a , b " must be parsed as [ a , b ] (instead of [ a ],[ b ])

Defaults to '"'

Returns:
the quote character

setQuote

public final void setQuote(char quote)
Defines the character used for escaping values where the field delimiter is part of the value.

e.g. the value " a , b " must be parsed as [ a , b ] (instead of [ a ],[ b ])

Parameters:
quote - the quote character

isQuote

public final boolean isQuote(char ch)
Identifies whether or not a given character is used for escaping values where the field delimiter is part of the value

Parameters:
ch - the character to be verified
Returns:
true if the given character is the character used for escaping values that contain a field delimiter character, otherwise false

getQuoteEscape

public final char getQuoteEscape()
Returns the character used for escaping quotes inside an already quoted value.

e.g. using " as the quote escape, the value " "" a , b "" " is parsed as [ " a , b " ] (instead of [ " a ][ b " ] or [ "" a , b "" ])

Defaults to '"'

Returns:
the quote escape character

setQuoteEscape

public final void setQuoteEscape(char quoteEscape)
Defines the character used for escaping quotes inside an already quoted value.

e.g. using " as the quote escape, the value " "" a , b "" " is parsed as [ " a , b " ] (instead of [ " a ][ b " ] or [ "" a , b "" ])

Parameters:
quoteEscape - the quote escape character

isQuoteEscape

public final boolean isQuoteEscape(char ch)
Identifies whether or not a given character is used for escaping quotes inside an already quoted value.

Parameters:
ch - the character to be verified
Returns:
true if the given character is the quote escape character, otherwise false

getDelimiter

public final char getDelimiter()
Returns the field delimiter character. Used to separate individual fields in a CSV record.

e.g. using , as the delimiter, the value a , b is parsed as [ a ][ b ]

Defaults to ','

Returns:
the field delimiter character

setDelimiter

public final void setDelimiter(char delimiter)
Defines the field delimiter character. Used to separate individual fields in a CSV record.

e.g. using , as the delimiter, the value a , b is parsed as [ a ][ b ]

Parameters:
delimiter - the field delimiter character

isDelimiter

public final boolean isDelimiter(char ch)
Identifies whether or not a given character is the field delimiter used to separate individual fields in a CSV record.

Parameters:
ch - the character to be verified
Returns:
true if the given character is the field delimiter character, otherwise false

copyDefaultsFrom

protected final void copyDefaultsFrom(Configuration defaultConfig)
Applies default values to undefined settings using a Configuration object.

Overrides:
copyDefaultsFrom in class TextFormat
Parameters:
defaultConfig - a configuration object from where to obtain default settings.


Copyright © 2015 uniVocity Software Pty Ltd. All rights reserved.