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

public abstract Class Format

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
com.univocity.parsers.csv.CsvFormat, com.univocity.parsers.fixed.FixedWidthFormat, com.univocity.parsers.tsv.TsvFormat, com.univocity.parsers.common.DummyFormat
Imports
java.util.Map.*, java.util.*

This is the parent class for all configuration classes that define a text format.

By default, all parsers and writers have to handle, at least, the following format definitions:

Author
Univocity Software Pty Ltd - [email protected]
See Also
com.univocity.parsers.csv.CsvFormat, com.univocity.parsers.fixed.FixedWidthFormat

Field Summary

Modifier and TypeField and Description
private char
private char[]
private String
private char
private static final char[]
private static final String

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected Format
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public char

Returns:

the comment character
getComment
()

Returns the character that represents a line comment.

protected abstract TreeMap<String, Object>
private static String
public char[]

Returns:

the sequence of 1 to 2 characters that identifies the end of a line
getLineSeparator
()

Returns the current line separator character sequence, which can contain 1 to 2 characters.

public String

Returns:

the sequence of 1 to 2 characters that identifies the end of a line
getLineSeparatorString
()

Returns the current line separator sequence as a String of 1 to 2 characters.

public char

Returns:

the normalized newline character
getNormalizedNewline
()

Returns the normalized newline character, which is automatically replaced by Format#lineSeparator when reading/writing.

public static char[]

Returns:

a sequence of 1 to 2 characters used as the system's line ending.
getSystemLineSeparator
()

Returns the system's line separator sequence, which can contain 1 to 2 characters.

public boolean

Returns:

true if the given character is the comment character, false otherwise
isComment
(char
the character to be verified
ch
)

Identifies whether or not a given character represents a comment

public boolean

Returns:

true if the given character is the normalized newline character, false otherwise
isNewLine
(char
the character to be verified
ch
)

Compares the given character against the Format#normalizedNewline character.

public void
setComment(char
the comment character
comment
)

Defines the character that represents a line comment when found in the beginning of a line of text.

public void
setLineSeparator(String
a sequence of 1 to 2 characters that identifies the end of a line
lineSeparator
)

Defines the line separator sequence that should be used for parsing and writing.

public void
setLineSeparator(char[]
a sequence of 1 to 2 characters that identifies the end of a line
lineSeparator
)

Defines the line separator sequence that should be used for parsing and writing.

public void
setNormalizedNewline(char
a single character used to represent a line separator.
normalizedNewline
)

Sets the normalized newline character, which is automatically replaced by Format#lineSeparator when reading/writing

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

commentback to summary
private char comment
lineSeparatorback to summary
private char[] lineSeparator
lineSeparatorStringback to summary
private String lineSeparatorString
normalizedNewlineback to summary
private char normalizedNewline
systemLineSeparatorback to summary
private static final char[] systemLineSeparator
systemLineSeparatorStringback to summary
private static final String systemLineSeparatorString

Constructor Detail

Formatback to summary
protected Format()

Method Detail

cloneback to summary
protected Format clone()

Overrides java.lang.Object.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:Format

a clone of this instance.

Annotations
@Override
getCommentback to summary
public char getComment()

Returns the character that represents a line comment. Defaults to '#'

Set it to '\0' to disable comment skipping.

Returns:char

the comment character

getConfigurationback to summary
protected abstract TreeMap<String, Object> getConfiguration()
getFormattedValueback to summary
private static String getFormattedValue(Object value)
getLineSeparatorback to summary
public char[] getLineSeparator()

Returns the current line separator character sequence, which can contain 1 to 2 characters. Defaults to the system's line separator sequence (usually '\r\n' in Windows, '\r' in MacOS, and '\n' in Linux/Unix).

Returns:char[]

the sequence of 1 to 2 characters that identifies the end of a line

getLineSeparatorStringback to summary
public String getLineSeparatorString()

Returns the current line separator sequence as a String of 1 to 2 characters. Defaults to the system's line separator sequence (usually "\r\n" in Windows, "\r" in MacOS, and "\n" in Linux/Unix).

Returns:String

the sequence of 1 to 2 characters that identifies the end of a line

getNormalizedNewlineback to summary
public char getNormalizedNewline()

Returns the normalized newline character, which is automatically replaced by Format#lineSeparator when reading/writing. Defaults to '\n'.

Returns:char

the normalized newline character

getSystemLineSeparatorback to summary
public static char[] getSystemLineSeparator()

Returns the system's line separator sequence, which can contain 1 to 2 characters.

Returns:char[]

a sequence of 1 to 2 characters used as the system's line ending.

isCommentback to summary
public boolean isComment(char ch)

Identifies whether or not a given character represents a comment

Parameters
ch:char

the character to be verified

Returns:boolean

true if the given character is the comment character, false otherwise

isNewLineback to summary
public boolean isNewLine(char ch)

Compares the given character against the Format#normalizedNewline character.

Parameters
ch:char

the character to be verified

Returns:boolean

true if the given character is the normalized newline character, false otherwise

setCommentback to summary
public void setComment(char comment)

Defines the character that represents a line comment when found in the beginning of a line of text. Defaults to '#'

Use '\0' to disable comment skipping.

Parameters
comment:char

the comment character

setLineSeparatorback to summary
public void setLineSeparator(String lineSeparator)

Defines the line separator sequence that should be used for parsing and writing.

Parameters
lineSeparator:String

a sequence of 1 to 2 characters that identifies the end of a line

setLineSeparatorback to summary
public void setLineSeparator(char[] lineSeparator)

Defines the line separator sequence that should be used for parsing and writing.

Parameters
lineSeparator:char[]

a sequence of 1 to 2 characters that identifies the end of a line

setNormalizedNewlineback to summary
public void setNormalizedNewline(char normalizedNewline)

Sets the normalized newline character, which is automatically replaced by Format#lineSeparator when reading/writing

Parameters
normalizedNewline:char

a single character used to represent a line separator.

toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override