com.univocity.parsers.common
Class Format

java.lang.Object
  extended by com.univocity.parsers.common.Format
Direct Known Subclasses:
CsvFormat, FixedWidthFormat, TsvFormat

public abstract class Format
extends Object

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:
CsvFormat, FixedWidthFormat

Constructor Summary
protected Format()
           
 
Method Summary
 char getComment()
          Returns the character that represents a line comment.
 char[] getLineSeparator()
          Returns the current line separator character sequence, which can contain 1 to 2 characters.
 String getLineSeparatorString()
          Returns the current line separator sequence as a String of 1 to 2 characters.
 char getNormalizedNewline()
          Returns the normalized newline character, which is automatically replaced by lineSeparator when reading/writing.
 boolean isComment(char ch)
          Identifies whether or not a given character represents a comment
 boolean isNewLine(char ch)
          Compares the given character against the normalizedNewline character.
 void setComment(char comment)
          Defines the character that represents a line comment when found in the beginning of a line of text.
 void setLineSeparator(char[] lineSeparator)
          Defines the line separator sequence that should be used for parsing and writing.
 void setLineSeparator(String lineSeparator)
          Defines the line separator sequence that should be used for parsing and writing.
 void setNormalizedNewline(char normalizedNewline)
          Sets the normalized newline character, which is automatically replaced by lineSeparator when reading/writing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Format

protected Format()
Method Detail

getLineSeparator

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:
the sequence of 1 to 2 characters that identifies the end of a line

getLineSeparatorString

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:
the sequence of 1 to 2 characters that identifies the end of a line

setLineSeparator

public void setLineSeparator(String lineSeparator)
Defines the line separator sequence that should be used for parsing and writing.

Parameters:
lineSeparator - a sequence of 1 to 2 characters that identifies the end of a line

setLineSeparator

public void setLineSeparator(char[] lineSeparator)
Defines the line separator sequence that should be used for parsing and writing.

Parameters:
lineSeparator - a sequence of 1 to 2 characters that identifies the end of a line

getNormalizedNewline

public char getNormalizedNewline()
Returns the normalized newline character, which is automatically replaced by lineSeparator when reading/writing. Defaults to '\n'.

Returns:
the normalized newline character

setNormalizedNewline

public void setNormalizedNewline(char normalizedNewline)
Sets the normalized newline character, which is automatically replaced by lineSeparator when reading/writing

Parameters:
normalizedNewline - a single character used to represent a line separator.

isNewLine

public boolean isNewLine(char ch)
Compares the given character against the normalizedNewline character.

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

getComment

public char getComment()
Returns the character that represents a line comment. Defaults to '#'

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

Returns:
the comment character

setComment

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 - the comment character

isComment

public boolean isComment(char ch)
Identifies whether or not a given character represents a comment

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


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