org.knime.base.node.io.csvwriter
Class FileWriterSettings

java.lang.Object
  extended by org.knime.base.node.io.csvwriter.FileWriterSettings
Direct Known Subclasses:
FileWriterNodeSettings

public class FileWriterSettings
extends Object

Holds all settings used by the file writer. Writes them to and reads them from the node settings objects and checks the values. This object is used in the NodeModel to pass settings to the file writer.

Author:
ohl, University of Konstanz

Nested Class Summary
static class FileWriterSettings.quoteMode
          mode specifying how to quote the data.
 
Constructor Summary
FileWriterSettings()
          Creates a settings object with default settings (backward compatible to the old CSV writer).
FileWriterSettings(FileWriterSettings settings)
          Creates a copy of the specified settings object.
FileWriterSettings(NodeSettingsRO settings)
          Constructs a new object reading the settings from the specified NodeSettings object.
 
Method Summary
static String escapeString(String str)
          Returns a string with all TABS and newLines being replaced by "\t" or "\n" - and backslashes replaced by "\\".
 String getColSeparator()
           
(package private)  char getDecimalSeparator()
           
 String getMissValuePattern()
           
 String getQuoteBegin()
           
 String getQuoteEnd()
           
 FileWriterSettings.quoteMode getQuoteMode()
           
 String getQuoteReplacement()
           
 String getSeparatorReplacement()
           
 boolean replaceSeparatorInStrings()
           
 void saveSettingsTo(NodeSettingsWO settings)
          Saves the current values (even if they are incomplete or invalid) in the specified settings object.
 void setColSeparator(String colSeparator)
           
(package private)  void setDecimalSeparator(char newSeparator)
          Sets a new decimal separator character.
 void setMissValuePattern(String missValuePattern)
           
 void setQuoteBegin(String quoteBegin)
           
 void setQuoteEnd(String quoteEnd)
           
 void setQuoteMode(FileWriterSettings.quoteMode quoteMode)
           
 void setQuoteReplacement(String quoteReplacement)
           
 void setReplaceSeparatorInStrings(boolean replaceSepInStrings)
           
 void setSeparatorReplacement(String separatorReplacement)
           
 void setWriteColumnHeader(boolean writeColumnHeader)
           
 void setWriteRowID(boolean writeRowID)
           
static String unescapeString(String str)
          takes a string that could contain "\t", or "\n", or "\\", and returns a corresponding string with these patterns replaced by the characters '\t', '\n', '\'.
 boolean writeColumnHeader()
           
 boolean writeRowID()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileWriterSettings

public FileWriterSettings()
Creates a settings object with default settings (backward compatible to the old CSV writer). I. e. Comma as separator, always quote with double quotes and remove quotes.


FileWriterSettings

public FileWriterSettings(FileWriterSettings settings)
Creates a copy of the specified settings object.

Parameters:
settings - the settings to copy into the new object.

FileWriterSettings

public FileWriterSettings(NodeSettingsRO settings)
                   throws InvalidSettingsException
Constructs a new object reading the settings from the specified NodeSettings object. If the settings object doesn't contain all settings an exception is thrown. Settings are accepted and set internally even if they are invalid or inconsistent.

Parameters:
settings - the object to read the initial values from.
Throws:
InvalidSettingsException - if the settings object contains incomplete, invalid, or inconsistent values.
Method Detail

saveSettingsTo

public void saveSettingsTo(NodeSettingsWO settings)
Saves the current values (even if they are incomplete or invalid) in the specified settings object.

Parameters:
settings - the object to write the current values to.

getColSeparator

public String getColSeparator()
Returns:
the colSeparator

setColSeparator

public void setColSeparator(String colSeparator)
Parameters:
colSeparator - the string that is written our between data items.

getMissValuePattern

public String getMissValuePattern()
Returns:
the missValuePattern

setMissValuePattern

public void setMissValuePattern(String missValuePattern)
Parameters:
missValuePattern - the string that is written out for data cells with missing values.

getQuoteBegin

public String getQuoteBegin()
Returns:
the quoteBegin

setQuoteBegin

public void setQuoteBegin(String quoteBegin)
Parameters:
quoteBegin - the string that is used as opening quotation mark.

getQuoteEnd

public String getQuoteEnd()
Returns:
the quoteEnd

setQuoteEnd

public void setQuoteEnd(String quoteEnd)
Parameters:
quoteEnd - the string used as closing quotation mark.

getQuoteMode

public FileWriterSettings.quoteMode getQuoteMode()
Returns:
the quoteMode

setQuoteMode

public void setQuoteMode(FileWriterSettings.quoteMode quoteMode)
Parameters:
quoteMode - the quoteMode to set

getSeparatorReplacement

public String getSeparatorReplacement()
Returns:
the separatorReplacement

setSeparatorReplacement

public void setSeparatorReplacement(String separatorReplacement)
Parameters:
separatorReplacement - the separatorReplacement to set

replaceSeparatorInStrings

public boolean replaceSeparatorInStrings()
Returns:
the replaceSepInString

setReplaceSeparatorInStrings

public void setReplaceSeparatorInStrings(boolean replaceSepInStrings)
Parameters:
replaceSepInStrings - if set true, the column separator will be replaced in non-numerical columns - even if the data item written was quoted.

writeColumnHeader

public boolean writeColumnHeader()
Returns:
the writeColumnHeader

setWriteColumnHeader

public void setWriteColumnHeader(boolean writeColumnHeader)
Parameters:
writeColumnHeader - the writeColumnHeader to set

writeRowID

public boolean writeRowID()
Returns:
the writeRowID

setWriteRowID

public void setWriteRowID(boolean writeRowID)
Parameters:
writeRowID - the writeRowID to set

getQuoteReplacement

public String getQuoteReplacement()
Returns:
the quoteReplacement

setQuoteReplacement

public void setQuoteReplacement(String quoteReplacement)
Parameters:
quoteReplacement - the quoteReplacement to set

getDecimalSeparator

char getDecimalSeparator()
Returns:
the current decimal separator

setDecimalSeparator

void setDecimalSeparator(char newSeparator)
Sets a new decimal separator character.

Parameters:
newSeparator - the new decimal separator

unescapeString

public static String unescapeString(String str)
takes a string that could contain "\t", or "\n", or "\\", and returns a corresponding string with these patterns replaced by the characters '\t', '\n', '\'.

Parameters:
str - a string with escape sequences in
Returns:
a string with all sequences translated. If there are no escape sequences in the specified string the exact same reference will be returned.

escapeString

public static String escapeString(String str)
Returns a string with all TABS and newLines being replaced by "\t" or "\n" - and backslashes replaced by "\\".

Parameters:
str - a string with tabs and newlines
Returns:
a string with the special chars translated.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.