org.knime.base.node.io.filereader
Class FileReaderNodeSettings

java.lang.Object
  extended by org.knime.core.util.tokenizer.TokenizerSettings
      extended by org.knime.base.node.io.filereader.FileReaderSettings
          extended by org.knime.base.node.io.filereader.FileReaderNodeSettings
Direct Known Subclasses:
VariableFileReaderNodeSettings

public class FileReaderNodeSettings
extends FileReaderSettings

Author:
Peter Ohl, University of Konstanz

Field Summary
 
Fields inherited from class org.knime.base.node.io.filereader.FileReaderSettings
CFGKEY_DATAURL, DEF_ROWPREFIX
 
Constructor Summary
FileReaderNodeSettings()
          Creates an empty settings object.
FileReaderNodeSettings(FileReaderNodeSettings clonee)
          Creates a new settings object with the exact same settings as the object passed in.
FileReaderNodeSettings(NodeSettingsRO cfg)
          Creates a new settings object for the file reader note and initializes it from the config object passed.
 
Method Summary
protected  void addStatusOfSettings(SettingsStatus status, boolean openDataFile, DataTableSpec tableSpec)
          Call this from derived classes to add the status of all super classes.
(package private)  boolean analyzeUsedAllRows()
           
 DataTableSpec createDataTableSpec()
          Derives a DataTableSpec from the current settings.
 boolean decimalSeparatorUserSet()
          Tells whether the decimal separator is set by the user or guessed by the analyzer (or still at its default).
 Vector<ColProperty> getColumnProperties()
           
 String getMissingValueOfColumn(int colIdx)
          Overriding super method because we store these missing values now in the column properties.
 int getNumberOfColumns()
           
(package private)  boolean getPreserveSettings()
          Checks the flag that indicates if settings will be reset at location change.
 boolean[] getSkippedColumns()
           
 SettingsStatus getStatusOfSettings()
          Method to check consistency and completeness of the current settings.
 SettingsStatus getStatusOfSettings(boolean openDataFile, DataTableSpec tableSpec)
          Method to check consistency and completeness of the current settings.
 boolean ignoreDelimsAtEORUserSet()
           
 boolean ignoreDelimsAtEORUserValue()
           
 boolean isCommentUserSet()
           
 boolean isDelimiterUserSet()
           
 boolean isFileHasColumnHeadersUserSet()
           
 boolean isFileHasRowHeadersUserSet()
           
 boolean isIgnoreEmptyLinesUserSet()
           
 boolean isQuoteUserSet()
           
 boolean isWhiteSpaceUserSet()
           
static FileReaderNodeSettings readSettingsFromXMLFile(String xmlLocation)
          Reads the FileReaderNodeSettings from the specified XML file and returns a new settings object.
 void saveToConfiguration(NodeSettingsWO cfg)
          Writes all settings into the passed configuration object.
(package private)  void setAnalyzeUsedAllRows(boolean val)
          Sets the value of the flag which is used to indicate if the FileAnalyzer looked at all rows when it extracts the default settings.
 void setColumnProperties(Vector<? extends ColProperty> colProps)
          Stores a copy of the vector of properties in the structure.
 void setCommentUserSet(boolean s)
          Set true to indicate that the flag is actually set and is not still the default value.
 void setDecimalSeparatorUserSet(boolean value)
          Sets a new value to the flag that indicates that the decimal value is explictly set by the user.
 void setDelimiterUserSet(boolean s)
          Set true to indicate that the flag is actually set and is not still the default value.
 void setFileHasColumnHeadersUserSet(boolean s)
          Set true to indicate that the flag is actually set and is not still the default value.
 void setFileHasRowHeadersUserSet(boolean s)
          Set true to indicate that the flag is actually set and is not still the default value.
 void setIgnoreDelimsAtEndOfRowUserValue(boolean ignoreEm)
          Sets the "is user set" flag and stores the user value.
 void setIgnoreEmptyLinesUserSet(boolean s)
          Set true to indicate that the flag is actually set and is not still the default value.
 void setMissingValueForColumn(int colIdx, String pattern)
          Overriding super method because we store these missing values now in the column properties.
 void setNumberOfColumns(int numOfCols)
          Stores the number of columns set by the user.
(package private)  void setPreserveSettings(boolean preserveSettings)
          Sets the flag that determines if settings are reset if a new data location is entered in the dialog.
 void setQuoteUserSet(boolean s)
          Set true to indicate that the flag is actually set and is not still the default value.
 void setWhiteSpaceUserSet(boolean s)
          Set true to indicate that the flag is actually set and is not still the default value.
 String toString()
          
 
Methods inherited from class org.knime.base.node.io.filereader.FileReaderSettings
addRowDelimiter, combinesMultipleRowDelimiters, createNewInputReader, getCharsetName, getColumnNumDeterminingLineNumber, getDataFileLocation, getDecimalSeparator, getFileHasColumnHeaders, getFileHasRowHeaders, getIgnoreEmtpyLines, getMaximumNumberOfRowsToRead, getMissValuePatternStrCols, getRowHeaderPrefix, getSupportShortLines, getTableName, getThousandsSeparator, ignoreEmptyTokensAtEndOfRow, isRowDelimiter, removeAllDelimiters, removeAllRowDelimiters, removeDelimiterPattern, removeRowDelimiter, setCharsetName, setColumnNumDeterminingLineNumber, setDataFileLocationAndUpdateTableName, setDecimalSeparator, setFileHasColumnHeaders, setFileHasRowHeaders, setIgnoreEmptyLines, setIgnoreEmptyTokensAtEndOfRow, setMaximumNumberOfRowsToRead, setMissValuePatternStrCols, setRowHeaderPrefix, setSupportShortLines, setTableName, setThousandsSeparator, setUniquifyRowIDs, uniquifyRowIDs
 
Methods inherited from class org.knime.core.util.tokenizer.TokenizerSettings
addBlockCommentPattern, addDelimiterPattern, addDelimiterPattern, addOrReplaceDelimiterPattern, addQuotePattern, addQuotePattern, addQuotePattern, addQuotePattern, addSingleLineCommentPattern, addStatusOfSettings, addWhiteSpaceCharacter, addWhiteSpaceCharacter, getAllComments, getAllDelimiters, getAllQuotes, getAllWhiteSpaces, getCombineMultipleDelimiters, getDelimiterPattern, getLineContinuationCharacter, printableStr, removeAllComments, removeAllQuotes, removeAllWhiteSpaces, removeQuotePattern, setCombineMultipleDelimiters, setLineContinuationCharacter, unescapeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileReaderNodeSettings

FileReaderNodeSettings(NodeSettingsRO cfg)
                 throws InvalidSettingsException
Creates a new settings object for the file reader note and initializes it from the config object passed. If null is passed default settings will be applied where applicable. The default setting are not valid in the sense that they can't be used without modification.

Parameters:
cfg - a config object containing all settings or null to create default settings
Throws:
InvalidSettingsException - if the settings in the config object are incomplete, inconsistent or in any other was invalid

FileReaderNodeSettings

FileReaderNodeSettings(FileReaderNodeSettings clonee)
Creates a new settings object with the exact same settings as the object passed in.

Parameters:
clonee - the settings object to copy the settings values from.

FileReaderNodeSettings

public FileReaderNodeSettings()
Creates an empty settings object. It contains no default values.

Method Detail

saveToConfiguration

public void saveToConfiguration(NodeSettingsWO cfg)
Writes all settings into the passed configuration object. Except for the analyzedAllRows flag. Saves all settings into a NodeSettingsWO object. Using the cfg object to construct a new FileReaderSettings object should lead to an object identical to this.

Overrides:
saveToConfiguration in class FileReaderSettings
Parameters:
cfg - the config object the settings are stored into

setColumnProperties

public void setColumnProperties(Vector<? extends ColProperty> colProps)
Stores a copy of the vector of properties in the structure.

Parameters:
colProps - the column properties to store

getColumnProperties

public Vector<ColProperty> getColumnProperties()
Returns:
a copy of the Vector storing ColProperty objects or null if not set

getMissingValueOfColumn

public String getMissingValueOfColumn(int colIdx)
Overriding super method because we store these missing values now in the column properties. Returns the pattern that, if read in for the specified column, will be considered placeholder for a missing value, and the data table will contain a missing cell instead of that value then.

Overrides:
getMissingValueOfColumn in class FileReaderSettings
Parameters:
colIdx - the index of the column the missing value is asked for
Returns:
the pattern that will be considered placeholder for a missing value in the specified column. Or null if no patern is set for that column.

setMissingValueForColumn

public void setMissingValueForColumn(int colIdx,
                                     String pattern)
Overriding super method because we store these missing values now in the column properties. Specifies a pattern that, if read in for the specified column, will be considered placeholder for a missing value, and the data table will contain a missing cell instead of that value then.

Overrides:
setMissingValueForColumn in class FileReaderSettings
Parameters:
colIdx - the index of the column this missing value is set for
pattern - the pattern specifying the missing value in the data file for the specified column. Can be null to delete a previously set pattern.

setNumberOfColumns

public void setNumberOfColumns(int numOfCols)
Stores the number of columns set by the user. (Must not be the same as the number of column properties stored in this object).

Parameters:
numOfCols - the number of columns to store

getNumberOfColumns

public int getNumberOfColumns()
Returns:
the number set with the method above.

createDataTableSpec

public DataTableSpec createDataTableSpec()
Derives a DataTableSpec from the current settings. The spec will not contain any domain information. It will contain only the columns to include in the table (excl. the columns to skip).

Returns:
a DataTableSpec corresponding to the current settings or null if the current settings are invalid

getSkippedColumns

public boolean[] getSkippedColumns()
Returns:
an array whose elements are set to true if the corresponding column should be skipped - not included in the table.

readSettingsFromXMLFile

public static FileReaderNodeSettings readSettingsFromXMLFile(String xmlLocation)
Reads the FileReaderNodeSettings from the specified XML file and returns a new settings object. It throws an exception if something goes wrong. The settings are not checked. They could be incomplete or invalid. It also reads possible values from the data file - but only if the settings are useable and the table contains a string column.

Parameters:
xmlLocation - location of the xml file to read. Must be a valid URL.
Returns:
a new settings object containing the settings read fromt the specified XML file.
Throws:
IllegalStateException - if something goes wrong

setIgnoreEmptyLinesUserSet

public void setIgnoreEmptyLinesUserSet(boolean s)
Set true to indicate that the flag is actually set and is not still the default value.

Parameters:
s - the new value of the flag

isIgnoreEmptyLinesUserSet

public boolean isIgnoreEmptyLinesUserSet()
Returns:
true if the value was set by the user, false if it's still at constructor's default value

setFileHasRowHeadersUserSet

public void setFileHasRowHeadersUserSet(boolean s)
Set true to indicate that the flag is actually set and is not still the default value.

Parameters:
s - the new value of the flag

isFileHasRowHeadersUserSet

public boolean isFileHasRowHeadersUserSet()
Returns:
true is the value was set, false if it's still at constructor's default value

setFileHasColumnHeadersUserSet

public void setFileHasColumnHeadersUserSet(boolean s)
Set true to indicate that the flag is actually set and is not still the default value.

Parameters:
s - the new value of the flag

isFileHasColumnHeadersUserSet

public boolean isFileHasColumnHeadersUserSet()
Returns:
true is the value was set, false if it's still at constructor's default value

setCommentUserSet

public void setCommentUserSet(boolean s)
Set true to indicate that the flag is actually set and is not still the default value.

Parameters:
s - the new value of the flag

isCommentUserSet

public boolean isCommentUserSet()
Returns:
true is the value was set by the user, false if it's still at constructor's default value

setDelimiterUserSet

public void setDelimiterUserSet(boolean s)
Set true to indicate that the flag is actually set and is not still the default value.

Parameters:
s - the new value of the flag

isDelimiterUserSet

public boolean isDelimiterUserSet()
Returns:
true is the value was set by the user, false if it's still at constructor's default value

setQuoteUserSet

public void setQuoteUserSet(boolean s)
Set true to indicate that the flag is actually set and is not still the default value.

Parameters:
s - the new value of the flag

isQuoteUserSet

public boolean isQuoteUserSet()
Returns:
true is the value was set by the user, false if it's still at constructor's default value

setWhiteSpaceUserSet

public void setWhiteSpaceUserSet(boolean s)
Set true to indicate that the flag is actually set and is not still the default value.

Parameters:
s - the new value of the flag

isWhiteSpaceUserSet

public boolean isWhiteSpaceUserSet()
Returns:
true is the value was set by the user, false if it's still at constructor's default value

setIgnoreDelimsAtEndOfRowUserValue

public void setIgnoreDelimsAtEndOfRowUserValue(boolean ignoreEm)
Sets the "is user set" flag and stores the user value.

Parameters:
ignoreEm - if true extra delims at the end of the row (in case of a tab or space delim) will be ignored.

ignoreDelimsAtEORUserSet

public boolean ignoreDelimsAtEORUserSet()
Returns:
true, if user set the value for "ignore delims at end of row"

decimalSeparatorUserSet

public boolean decimalSeparatorUserSet()
Tells whether the decimal separator is set by the user or guessed by the analyzer (or still at its default).

Returns:
true, if the user explicitly set the decimal separator, false, if the separators are still at their default, or the analyser guessed it.

setDecimalSeparatorUserSet

public void setDecimalSeparatorUserSet(boolean value)
Sets a new value to the flag that indicates that the decimal value is explictly set by the user.

Parameters:
value - the new value of the flag.

ignoreDelimsAtEORUserValue

public boolean ignoreDelimsAtEORUserValue()
Returns:
the value the user chose for this flag.

analyzeUsedAllRows

boolean analyzeUsedAllRows()
Returns:
the value of the analyze flag previously set. Or false by default.

setAnalyzeUsedAllRows

void setAnalyzeUsedAllRows(boolean val)
Sets the value of the flag which is used to indicate if the FileAnalyzer looked at all rows when it extracts the default settings. The value of the flag is not stored when the settings are saved into a config, and is not recovered from a config object.

Parameters:
val - the new value of the flag

getStatusOfSettings

public SettingsStatus getStatusOfSettings()
Method to check consistency and completeness of the current settings. It will return a SettingsStatus object which contains info, warning and error messages, if something is fishy with the settings.

Overrides:
getStatusOfSettings in class FileReaderSettings
Returns:
a SettingsStatus object containing info, warning and error messages - or not if all settings are good.

getStatusOfSettings

public SettingsStatus getStatusOfSettings(boolean openDataFile,
                                          DataTableSpec tableSpec)
Method to check consistency and completeness of the current settings. It will return a SettingsStatus object which contains info, warning and error messages, if something is fishy with the settings. Method to check consistency and completeness of the current settings. It will return a SettingsStatus object which contains info, warning and error messages. Or if the settings are alright it will return null.

Overrides:
getStatusOfSettings in class FileReaderSettings
Parameters:
openDataFile - tells whether or not this method should try to access the data file. This will - if set true - verify the accessibility of the data.
tableSpec - the spec of the DataTable these settings are for. If set null only a few checks will be performed - the ones that are possible without the knowledge of the structure of the table
Returns:
a SettingsStatus object containing info, warning and error messages, or null if no messages were generated (i.e. all settings are just fine).

addStatusOfSettings

protected void addStatusOfSettings(SettingsStatus status,
                                   boolean openDataFile,
                                   DataTableSpec tableSpec)
Call this from derived classes to add the status of all super classes. For parameters: Adds its status messages to a passed status object.

Overrides:
addStatusOfSettings in class FileReaderSettings
Parameters:
status - the object to add messages to - if any
openDataFile - specifies if we should check the accessability of the data file
tableSpec - the spec of the DataTable these settings are for. If set null only a few checks will be performed - the ones that are possible without the knowledge of the structure of the table

toString

public String toString()

Overrides:
toString in class FileReaderSettings

getPreserveSettings

boolean getPreserveSettings()
Checks the flag that indicates if settings will be reset at location change.

Returns:
true if settings are not reset on file location change.

setPreserveSettings

void setPreserveSettings(boolean preserveSettings)
Sets the flag that determines if settings are reset if a new data location is entered in the dialog.

Parameters:
preserveSettings - set true to reset all dialog settings if the data location changes, or false to preserve the current settings.


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.