org.apache.commons.csv.writer
Class CSVConfig

java.lang.Object
  extended by org.apache.commons.csv.writer.CSVConfig

public class CSVConfig
extends java.lang.Object

The CSVConfig is used to configure the CSV writer

Version:
$Id: $
Author:
Martin van den Bemt

Field Summary
private  char delimiter
          The seperator character.
private  boolean endTrimmed
          Specifies if the end of the line needs to be trimmed
private  boolean fieldHeader
          Specifies if we want to use a field header
private  java.util.List fields
          list of fields
private  int fill
          The fill pattern
private  char fillChar
          The fill char.
static int FILLLEFT
          Fill content the the left.
static int FILLNONE
          Do no do any filling
static int FILLRIGHT
          Fill content to the right.
private  boolean fixedWidth
          specifies if it is a fixed width csv file
private  boolean ignoreDelimiter
          Should we ignore the delimiter.
private  boolean ignoreValueDelimiter
          Should we ignore the value delimiter.
private  char valueDelimiter
          the value delimiter.
 
Constructor Summary
CSVConfig()
           
 
Method Summary
 void addField(CSVField field)
           
 boolean equals(java.lang.Object obj)
          TODO..
 char getDelimiter()
           
 CSVField getField(java.lang.String name)
           
 CSVField[] getFields()
           
 int getFill()
           
 char getFillChar()
           
 char getValueDelimiter()
           
static CSVConfig guessConfig(java.io.InputStream inputStream)
          Creates a config based on a stream.
 boolean isDelimiterIgnored()
           
 boolean isEndTrimmed()
           
 boolean isFieldHeader()
           
 boolean isFixedWidth()
           
 boolean isValueDelimiterIgnored()
           
 void setDelimiter(char delimiter)
          Set the delimiter to use
 void setEndTrimmed(boolean endTrimmed)
          Specify if the end of the line needs to be trimmed.
 void setFieldHeader(boolean fieldHeader)
          Specify if you want to use a field header.
 void setFields(java.util.Collection csvField)
          Set the fields that should be used by the writer
 void setFields(CSVField[] csvFields)
          Set the fields that should be used by the writer.
 void setFill(int fill)
          Set the fill pattern.
 void setFillChar(char fillChar)
          Set the fill char
 void setFixedWidth(boolean fixedWidth)
          Specify if the CSV file is fixed width.
 void setIgnoreDelimiter(boolean ignoreDelimiter)
          Specify if the writer should ignore the delimiter.
 void setIgnoreValueDelimiter(boolean ignoreValueDelimiter)
          Specify if the writer should ignore the value delimiter.
 void setValueDelimiter(char valueDelimiter)
          Set the value delimiter to use
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fixedWidth

private boolean fixedWidth
specifies if it is a fixed width csv file


fields

private java.util.List fields
list of fields


FILLNONE

public static final int FILLNONE
Do no do any filling

See Also:
Constant Field Values

FILLLEFT

public static final int FILLLEFT
Fill content the the left. Mainly usable together with fixedWidth

See Also:
Constant Field Values

FILLRIGHT

public static final int FILLRIGHT
Fill content to the right. Mainly usable together with fixedWidth

See Also:
Constant Field Values

fill

private int fill
The fill pattern


fillChar

private char fillChar
The fill char. Defaults to a space


delimiter

private char delimiter
The seperator character. Defaults to ,


ignoreDelimiter

private boolean ignoreDelimiter
Should we ignore the delimiter. Defaults to false


valueDelimiter

private char valueDelimiter
the value delimiter. Defaults to "


ignoreValueDelimiter

private boolean ignoreValueDelimiter
Should we ignore the value delimiter. Defaults to true


fieldHeader

private boolean fieldHeader
Specifies if we want to use a field header


endTrimmed

private boolean endTrimmed
Specifies if the end of the line needs to be trimmed

Constructor Detail

CSVConfig

public CSVConfig()
Method Detail

isFixedWidth

public boolean isFixedWidth()
Returns:
if the CSV file is fixedWidth

setFixedWidth

public void setFixedWidth(boolean fixedWidth)
Specify if the CSV file is fixed width. Defaults to false

Parameters:
fixedWidth - the fixedwidth

addField

public void addField(CSVField field)

setFields

public void setFields(CSVField[] csvFields)
Set the fields that should be used by the writer. This will overwrite currently added fields completely!

Parameters:
csvFields - the csvfields array. If null it will do nothing

setFields

public void setFields(java.util.Collection csvField)
Set the fields that should be used by the writer

Parameters:
csvField - a collection with fields. If null it will do nothing

getFields

public CSVField[] getFields()
Returns:
an array with the known fields (even if no fields are specified)

getField

public CSVField getField(java.lang.String name)

getFill

public int getFill()
Returns:
the fill pattern.

setFill

public void setFill(int fill)
Set the fill pattern. Defaults to FILLNONE
Other options are : FILLLEFT and FILLRIGHT

Parameters:
fill - the fill pattern.

getFillChar

public char getFillChar()
Returns:
the fillchar. Defaults to a space.

setFillChar

public void setFillChar(char fillChar)
Set the fill char

Parameters:
fillChar - the fill char

getDelimiter

public char getDelimiter()
Returns:
the delimeter used.

setDelimiter

public void setDelimiter(char delimiter)
Set the delimiter to use

Parameters:
delimiter - the delimiter character.

isDelimiterIgnored

public boolean isDelimiterIgnored()
Returns:
if the writer should ignore the delimiter character.

setIgnoreDelimiter

public void setIgnoreDelimiter(boolean ignoreDelimiter)
Specify if the writer should ignore the delimiter.

Parameters:
ignoreDelimiter - defaults to false.

getValueDelimiter

public char getValueDelimiter()
Returns:
the value delimeter used. Defaults to "

setValueDelimiter

public void setValueDelimiter(char valueDelimiter)
Set the value delimiter to use

Parameters:
valueDelimiter - the value delimiter character.

isValueDelimiterIgnored

public boolean isValueDelimiterIgnored()
Returns:
if the writer should ignore the value delimiter character. Defaults to true.

setIgnoreValueDelimiter

public void setIgnoreValueDelimiter(boolean ignoreValueDelimiter)
Specify if the writer should ignore the value delimiter.

Parameters:
ignoreValueDelimiter - defaults to false.

isFieldHeader

public boolean isFieldHeader()
Returns:
if a field header is used. Defaults to false

setFieldHeader

public void setFieldHeader(boolean fieldHeader)
Specify if you want to use a field header.

Parameters:
fieldHeader - true or false.

equals

public boolean equals(java.lang.Object obj)
TODO..

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

guessConfig

public static CSVConfig guessConfig(java.io.InputStream inputStream)
Creates a config based on a stream. It tries to guess
NOTE : The stream will be closed.

Parameters:
inputStream - the inputstream.
Returns:
the guessed config.

isEndTrimmed

public boolean isEndTrimmed()
Returns:
if the end of the line should be trimmed. Default is false.

setEndTrimmed

public void setEndTrimmed(boolean endTrimmed)
Specify if the end of the line needs to be trimmed. Defaults to false.

Parameters:
endTrimmed -