Top Description Fields Constructors Methods
com.univocity.parsers.csv

public Class CsvFormat

extends Format
Class Inheritance
Imports
com.univocity.parsers.common.*, java.util.*

The CSV format configuration. In addition to the default configuration in Format, the CSV format defines:
Author
Univocity Software Pty Ltd - [email protected]
See Also
com.univocity.parsers.common.Format

Field Summary

Modifier and TypeField and Description
private Character
private String
private char
private char

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final CsvFormat
clone()

Overrides com.univocity.parsers.common.Format.clone.

Creates and returns a copy of this object.
public final char

Returns:

the character to escape the character used for escaping quotes defined
getCharToEscapeQuoteEscaping
()

Returns the character used to escape the character used for escaping quotes defined by getQuoteEscape().

protected TreeMap<String, Object>
public char

Returns:

the field delimiter character
getDelimiter
()

Returns the field delimiter character.

public String

Returns:

the field delimiter as a String.
getDelimiterString
()

Returns the field delimiter sequence.

public char

Returns:

the quote character
getQuote
()

Returns the character used for escaping values where the field delimiter is part of the value.

public char

Returns:

the quote escape character
getQuoteEscape
()

Returns the character used for escaping quotes inside an already quoted value.

public final boolean

Returns:

true if the given character is used to escape the quote escape character, false otherwise
isCharToEscapeQuoteEscaping
(char
the character to be verified
ch
)

Identifies whether or not a given character is used to escape the character used for escaping quotes defined by getQuoteEscape().

public boolean

Returns:

true if the given character is the field delimiter character, false otherwise
isDelimiter
(char
the character to be verified
ch
)

Identifies whether or not a given character represents a field delimiter

public boolean

Returns:

true if the given sequence is the field delimiter character sequence, false otherwise
isDelimiter
(String
the character sequence to be verified
sequence
)

Identifies whether or not a given character represents a field delimiter

public boolean

Returns:

true if the given character is the character used for escaping values, false otherwise
isQuote
(char
the character to be verified
ch
)

Identifies whether or not a given character is used for escaping values where the field delimiter is part of the value

public boolean

Returns:

true if the given character is the quote escape character, false otherwise
isQuoteEscape
(char
the character to be verified
ch
)

Identifies whether or not a given character is used for escaping quotes inside an already quoted value.

public final void
setCharToEscapeQuoteEscaping(char
the character to escape the character used for escaping quotes defined
charToEscapeQuoteEscaping
)

Defines the character used to escape the character used for escaping quotes defined by getQuoteEscape().

public void
setDelimiter(char
the field delimiter character
delimiter
)

Defines the field delimiter character.

public void
setDelimiter(String
the field delimiter sequence.
delimiter
)

Defines the field delimiter as a sequence of characters.

public void
setQuote(char
the quote character
quote
)

Defines the character used for escaping values where the field delimiter is part of the value.

public void
setQuoteEscape(char
the quote escape character
quoteEscape
)

Defines the character used for escaping quotes inside an already quoted value.

Inherited from com.univocity.parsers.common.Format:
getCommentgetLineSeparatorgetLineSeparatorStringgetNormalizedNewlinegetSystemLineSeparatorisCommentisNewLinesetCommentsetLineSeparatorsetLineSeparatorsetNormalizedNewlinetoString

Field Detail

charToEscapeQuoteEscapingback to summary
private Character charToEscapeQuoteEscaping
delimiterback to summary
private String delimiter
quoteback to summary
private char quote
quoteEscapeback to summary
private char quoteEscape

Constructor Detail

CsvFormatback to summary
public CsvFormat()

Method Detail

cloneback to summary
public final CsvFormat clone()

Overrides com.univocity.parsers.common.Format.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:CsvFormat

a clone of this instance.

Annotations
@Override
getCharToEscapeQuoteEscapingback to summary
public final char getCharToEscapeQuoteEscaping()

Returns the character used to escape the character used for escaping quotes defined by getQuoteEscape(). For example, if the quote escape is set to '\', and the quoted value ends with: \", as in the following example:

[ " a\\", b ]

Then:
  • If the character to escape the '\' is undefined, the record won't be parsed. The parser will read characters: [a],[\],["],[,],[ ],[b] and throw an error because it cannot find a closing quote
  • If the character to escape the '\' is defined as '\', the record will be read with 2 values: [a\] and [b]
Defaults to '\0' (undefined)
Returns:char

the character to escape the character used for escaping quotes defined

getConfigurationback to summary
protected TreeMap<String, Object> getConfiguration()

Implements abstract com.univocity.parsers.common.Format.getConfiguration.

Annotations
@Override
getDelimiterback to summary
public char getDelimiter()

Returns the field delimiter character. Defaults to ','

Returns:char

the field delimiter character

getDelimiterStringback to summary
public String getDelimiterString()

Returns the field delimiter sequence.

Returns:String

the field delimiter as a String.

getQuoteback to summary
public char getQuote()

Returns the character used for escaping values where the field delimiter is part of the value. Defaults to '"'

Returns:char

the quote character

getQuoteEscapeback to summary
public char getQuoteEscape()

Returns the character used for escaping quotes inside an already quoted value. Defaults to '"'

Returns:char

the quote escape character

isCharToEscapeQuoteEscapingback to summary
public final boolean isCharToEscapeQuoteEscaping(char ch)

Identifies whether or not a given character is used to escape the character used for escaping quotes defined by getQuoteEscape().

Parameters
ch:char

the character to be verified

Returns:boolean

true if the given character is used to escape the quote escape character, false otherwise

isDelimiterback to summary
public boolean isDelimiter(char ch)

Identifies whether or not a given character represents a field delimiter

Parameters
ch:char

the character to be verified

Returns:boolean

true if the given character is the field delimiter character, false otherwise

isDelimiterback to summary
public boolean isDelimiter(String sequence)

Identifies whether or not a given character represents a field delimiter

Parameters
sequence:String

the character sequence to be verified

Returns:boolean

true if the given sequence is the field delimiter character sequence, false otherwise

isQuoteback to summary
public 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:char

the character to be verified

Returns:boolean

true if the given character is the character used for escaping values, false otherwise

isQuoteEscapeback to summary
public boolean isQuoteEscape(char ch)

Identifies whether or not a given character is used for escaping quotes inside an already quoted value.

Parameters
ch:char

the character to be verified

Returns:boolean

true if the given character is the quote escape character, false otherwise

setCharToEscapeQuoteEscapingback to summary
public final void setCharToEscapeQuoteEscaping(char charToEscapeQuoteEscaping)

Defines the character used to escape the character used for escaping quotes defined by getQuoteEscape(). For example, if the quote escape is set to '\', and the quoted value ends with: \", as in the following example:

[ " a\\", b ]

Then:
  • If the character to escape the '\' is undefined, the record won't be parsed. The parser will read characters: [a],[\],["],[,],[ ],[b] and throw an error because it cannot find a closing quote
  • If the character to escape the '\' is defined as '\', the record will be read with 2 values: [a\] and [b]
Defaults to '\0' (undefined)
Parameters
charToEscapeQuoteEscaping:char

the character to escape the character used for escaping quotes defined

setDelimiterback to summary
public void setDelimiter(char delimiter)

Defines the field delimiter character. Defaults to ','

Parameters
delimiter:char

the field delimiter character

setDelimiterback to summary
public void setDelimiter(String delimiter)

Defines the field delimiter as a sequence of characters. Defaults to ','

Parameters
delimiter:String

the field delimiter sequence.

setQuoteback to summary
public void setQuote(char quote)

Defines the character used for escaping values where the field delimiter is part of the value. Defaults to '"'

Parameters
quote:char

the quote character

setQuoteEscapeback to summary
public void setQuoteEscape(char quoteEscape)

Defines the character used for escaping quotes inside an already quoted value. Defaults to '"'

Parameters
quoteEscape:char

the quote escape character