com.univocity.api.entity.text
Class TextFormat

java.lang.Object
  extended by com.univocity.api.entity.Configuration
      extended by com.univocity.api.entity.text.TextFormat
Direct Known Subclasses:
CsvFormat, FixedWidthFormat, TsvFormat

public class TextFormat
extends Configuration

This is the parent class for all configuration classes that define a file format in uniVocity.

By default, all plain-text based entities in uniVocity require the following format definitions:

Author:
uniVocity Software Pty Ltd - dev@univocity.com
See Also:
CsvFormat, FixedWidthFormat, TextEntityConfiguration

Constructor Summary
protected TextFormat()
           
 
Method Summary
protected  void copyDefaultsFrom(Configuration defaultConfig)
          Applies default values to undefined settings using a Configuration object.
 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 a given character represents a comment.
 boolean isLineSeparator(char[] chars)
          Identifies whether a given character sequence matches the lineSeparator sequence.
 boolean isLineSeparator(String string)
          Identifies whether a given character sequence matches the lineSeparator sequence.
 boolean isNormalizedNewLine(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

TextFormat

protected TextFormat()
Method Detail

getLineSeparator

public final 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 final 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

isLineSeparator

public final boolean isLineSeparator(String string)
Identifies whether a given character sequence matches the lineSeparator sequence.

Parameters:
string - the character sequence to be matched
Returns:
true if the given character sequence matches the lineSeparator, otherwise false

isLineSeparator

public final boolean isLineSeparator(char[] chars)
Identifies whether a given character sequence matches the lineSeparator sequence.

Parameters:
chars - the character sequence to be matched
Returns:
true if the given character sequence matches the lineSeparator, otherwise false

setLineSeparator

public final 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 final 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 final 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 final 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.

isNormalizedNewLine

public final boolean isNormalizedNewLine(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, otherwise false

getComment

public final 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 a given character represents a comment.

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

copyDefaultsFrom

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

Specified by:
copyDefaultsFrom in class Configuration
Parameters:
defaultConfig - a configuration object from where to obtain default settings.


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