|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knime.core.util.tokenizer.TokenizerSettings
org.knime.base.node.io.filereader.FileReaderSettings
public class FileReaderSettings
Contains all settings needed to read in a ASCII data file. This includes the
location of the data file, the settings for the tokenizer (like column
delimiter, comment patterns etc.) as well as the row headers and more. This
object combined with a DataTableSpec
can be used
to create a FileTable
from. A FileTable
will represent
then the data of the file in a DataTable
.
Field Summary | |
---|---|
static String |
CFGKEY_DATAURL
Key used to store data file location in a config object. |
static String |
DEF_ROWPREFIX
This will be used if the file has not row headers and no row prefix is set. |
Constructor Summary | |
---|---|
FileReaderSettings()
Creates a new object holding all settings needed to read the specified file. |
|
FileReaderSettings(FileReaderSettings clonee)
Creates a new object holding the same settings values as the one passed in. |
|
FileReaderSettings(NodeSettingsRO cfg)
Creates a new FileReaderSettings object initializing its settings from the passed config object. |
Method Summary | |
---|---|
void |
addRowDelimiter(String rowDelimPattern,
boolean skipEmptyRows)
Will add a delimiter pattern that will terminate a row. |
protected void |
addStatusOfSettings(SettingsStatus status,
boolean openDataFile,
DataTableSpec tableSpec)
Adds its status messages to a passed status object. |
boolean |
combinesMultipleRowDelimiters(String pattern)
Returns true if the file reader combines multiple
consecutive row delimiters with this pattern (i.e. |
BufferedFileReader |
createNewInputReader()
|
String |
getCharsetName()
|
int |
getColumnNumDeterminingLineNumber()
|
URL |
getDataFileLocation()
|
char |
getDecimalSeparator()
|
boolean |
getFileHasColumnHeaders()
|
boolean |
getFileHasRowHeaders()
|
boolean |
getIgnoreEmtpyLines()
|
long |
getMaximumNumberOfRowsToRead()
|
String |
getMissingValueOfColumn(int colIdx)
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. |
String |
getMissValuePatternStrCols()
Returns the pattern that, if read in, will be translated into a missing value (in string columns only). |
String |
getRowHeaderPrefix()
|
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 |
getSupportShortLines()
|
String |
getTableName()
|
char |
getThousandsSeparator()
|
boolean |
ignoreEmptyTokensAtEndOfRow()
|
boolean |
isRowDelimiter(String pattern)
|
void |
removeAllDelimiters()
Removes all (!) delimiters from the file reader settings. |
void |
removeAllRowDelimiters()
Blows away all defined row delimiters! After a call to this function no row delimiter will be defined (except null ). |
Delimiter |
removeDelimiterPattern(String pattern)
Removes the Delimiter object with the specified pattern from the list of defined delimiters. |
Delimiter |
removeRowDelimiter(String pattern)
Removes the row delimiter with the specified pattern. |
void |
saveToConfiguration(NodeSettingsWO cfg)
Saves all settings into a NodeSettingsWO
object. |
void |
setCharsetName(String name)
Set the new character set name that will be used the next time a new input reader is created (see createNewInputReader() ). |
void |
setColumnNumDeterminingLineNumber(int lineNumber)
Sets the line number in the file that determined the number of columns. |
void |
setDataFileLocationAndUpdateTableName(URL dataFileLocation)
Sets the location of the file to read data from. |
void |
setDecimalSeparator(char sep)
Sets the character that will be considered decimal separator in the data (token) read for double type columns. |
void |
setFileHasColumnHeaders(boolean flag)
Tells whether the first line in the file should be considered column headers, or not. |
void |
setFileHasRowHeaders(boolean flag)
Tells whether the first token in each line in the file should be considered row header, or not. |
void |
setIgnoreEmptyLines(boolean ignoreEm)
|
void |
setIgnoreEmptyTokensAtEndOfRow(boolean ignoreThem)
Sets this flag. |
void |
setMaximumNumberOfRowsToRead(long maxNum)
Sets a new maximum for the number of rows to read. |
void |
setMissingValueForColumn(int colIdx,
String pattern)
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. |
void |
setMissValuePatternStrCols(String pattern)
Sets a new pattern which is translated into a missing value if read from the data file in a string column. |
void |
setRowHeaderPrefix(String rowPrefix)
Set a string that will be used as a prefix for each row header. |
void |
setSupportShortLines(boolean supportShortLines)
|
void |
setTableName(String newName)
Sets a new name for the table created by this node. |
void |
setThousandsSeparator(char thousandsSeparator)
|
void |
setUniquifyRowIDs(boolean uniquify)
|
String |
toString()
|
boolean |
uniquifyRowIDs()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String DEF_ROWPREFIX
public static final String CFGKEY_DATAURL
Constructor Detail |
---|
public FileReaderSettings()
public FileReaderSettings(FileReaderSettings clonee)
clonee
- the object to read the settings values frompublic FileReaderSettings(NodeSettingsRO cfg) throws InvalidSettingsException
cfg
- the config object containing all settings this object will be
initialized with
InvalidSettingsException
- if the passed config object contains
invalid or insufficient settingsMethod Detail |
---|
public void saveToConfiguration(NodeSettingsWO cfg)
NodeSettingsWO
object. Using the cfg object to construct a new FileReaderSettings object
should lead to an object identical to this.
saveToConfiguration
in class TokenizerSettings
cfg
- the config object the settings are stored intopublic void setDataFileLocationAndUpdateTableName(URL dataFileLocation)
dataFileLocation
- the URL of the data file these settings are forpublic URL getDataFileLocation()
public void setCharsetName(String name)
createNewInputReader()
).
name
- any character set supported by Java, or null to use the VM
default char set.
IllegalArgumentException
- if the specified name is not supported.
IllegalCharsetNameException
- if the specified
name is not supported.public String getCharsetName()
public BufferedFileReader createNewInputReader() throws IOException
NullPointerException
- if the data location is not set
IOException
- if an IO Error occurred when opening the streampublic void setTableName(String newName)
newName
- the new name to set.
Valid names are not null
.public String getTableName()
null
, but the method could return
null, if no name was set yet.public void setFileHasColumnHeaders(boolean flag)
flag
- if true
the first line in the file will not be
considered data, but either ignored or used as column headers,
depending on the column headers set (or not) in this object.public boolean getFileHasColumnHeaders()
public void setFileHasRowHeaders(boolean flag)
flag
- if true
the first item in each line in the
file will not be considered data, but either ignored or used
as row header, depending on the row header prefix set (or not)
in this object.public boolean getFileHasRowHeaders()
public void setRowHeaderPrefix(String rowPrefix)
rowPrefix
- the string that will be used to construct the header for
each row. The actual row header will have the row number
added. Specify null
to clear the prefix.public String getRowHeaderPrefix()
null
, the row header from the file
will be used - if any, otherwise the DEF_ROWPREFIX
.public boolean uniquifyRowIDs()
public void setUniquifyRowIDs(boolean uniquify)
uniquify
- the new value of the "uniquify row IDs from file" flag.public void addRowDelimiter(String rowDelimPattern, boolean skipEmptyRows)
IllegalArgumentException
.
rowDelimPattern
- the row delimiter pattern. Row delimiters will
always be token delimiters and will always be returned as
separate token.skipEmptyRows
- if set true
, multiple consecutive
row delimiters will be combined and returned as onepublic Delimiter removeRowDelimiter(String pattern)
pattern
- the row delimiter to delete must not be null.
null
is always a row delimiter.
null
if no row delimiter with the pattern existedpublic void removeAllRowDelimiters()
null
).
public boolean isRowDelimiter(String pattern)
pattern
- the pattern to test
true
if the pattern is a row delimiter.
null
is always a row delimiter.public void removeAllDelimiters()
removeAllDelimiters
in class TokenizerSettings
public Delimiter removeDelimiterPattern(String pattern)
removeDelimiterPattern
in class TokenizerSettings
pattern
- the delimiter to remove
public boolean getIgnoreEmtpyLines()
true
if the file reader ignores empty linespublic void setIgnoreEmptyLines(boolean ignoreEm)
ignoreEm
- pass true
to have the file reader not
return empty lines from the data filepublic boolean combinesMultipleRowDelimiters(String pattern)
true
if the file reader combines multiple
consecutive row delimiters with this pattern (i.e. it skips empty rows if
it finds multiple if these (and only these) row delimiters). The method
throws an IllegalArgumentException
at you if the specified
pattern is not a row delimiter.
pattern
- the pattern to test for
public void setMissingValueForColumn(int colIdx, String pattern)
colIdx
- the index of the column this missing value is set forpattern
- the pattern specifying the missing value in the data file
for the specified column. Can be null
to delete
a previously set pattern.public String getMissingValueOfColumn(int colIdx)
colIdx
- the index of the column the missing value is asked for
null
if no
patern is set for that column.public char getDecimalSeparator()
public void setDecimalSeparator(char sep)
sep
- the new decimal character to set for doubles. Can't be the
same character as the thousands separator.public char getThousandsSeparator()
public void setThousandsSeparator(char thousandsSeparator)
thousandsSeparator
- the thousandsSeparator to set. If set to '\0'
it will not be applied. Can't be the same as the decimal
separator.public boolean ignoreEmptyTokensAtEndOfRow()
true
if additional empty tokens should be ignored
at the end of a row (if they are not needed to build the row)public void setIgnoreEmptyTokensAtEndOfRow(boolean ignoreThem)
ignoreThem
- if true
, additional empty tokens will
be ignored at the end of a row (if they are not needed to
build the row)public void setSupportShortLines(boolean supportShortLines)
supportShortLines
- if set true lines with too few data elements
will be accepted and filled with missing values.public boolean getSupportShortLines()
public void setMissValuePatternStrCols(String pattern)
pattern
- the new pattern to recognize missing values in string
columns. Set to null
to clear it.public String getMissValuePatternStrCols()
public int getColumnNumDeterminingLineNumber()
public void setColumnNumDeterminingLineNumber(int lineNumber)
lineNumber
- the line number in the file that determined the number
of columns.public long getMaximumNumberOfRowsToRead()
public void setMaximumNumberOfRowsToRead(long maxNum)
maxNum
- the new maximum. If set to -1 all rows of the source will
be read, otherwise no more than the specified number.public SettingsStatus getStatusOfSettings(boolean openDataFile, DataTableSpec tableSpec)
SettingsStatus
object which contains info, warning
and error messages. Or if the settings are alright it will return null.
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
null
if no messages were generated
(i.e. all settings are just fine).public SettingsStatus getStatusOfSettings()
SettingsStatus
object which contains info,
warning and error messages, if something is fishy with the settings.
getStatusOfSettings
in class TokenizerSettings
protected void addStatusOfSettings(SettingsStatus status, boolean openDataFile, DataTableSpec tableSpec)
status
- the object to add messages to - if anyopenDataFile
- specifies if we should check the accessability of the
data filetableSpec
- 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 tablepublic String toString()
toString
in class TokenizerSettings
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |