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

java.lang.Object
  extended by org.knime.base.node.io.filereader.FileAnalyzer

public final class FileAnalyzer
extends Object

Provides functionality for analyzing an ASCII data file to create default settings. It tries to figure out what kind of delimiters and comments the file contains - honoring fixed pre-settings passed in.

Author:
Peter Ohl, University of Konstanz

Nested Class Summary
(package private) static class FileAnalyzer.HeaderHelper
          Little helper class for the check header method.
 
Field Summary
(package private) static int NUMOFLINES
          If the analysis is cut short, we look only at the first couple of lines.
 
Method Summary
static FileReaderNodeSettings analyze(FileReaderNodeSettings userSettings, ExecutionMonitor exec)
          Tries to guess FileReader settings for the passed data file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUMOFLINES

static final int NUMOFLINES
If the analysis is cut short, we look only at the first couple of lines. We look at as many lines as the preview table will read in as its first chunk.

See Also:
Constant Field Values
Method Detail

analyze

public static FileReaderNodeSettings analyze(FileReaderNodeSettings userSettings,
                                             ExecutionMonitor exec)
                                      throws IOException
Tries to guess FileReader settings for the passed data file. It will use the settings in the settings object (if any - but the file location is required), and will read in the first lines from the file. It will first detect comment characters (if the first lines start with '#' or '%'), and then guess the delimiter (',', ';', or space) depending on which cuts a line into (more than one) tokens.

Parameters:
userSettings - containing the URL of the file to examine and settings that should be used and considered fixed.
exec - used to check for cancellations and to report progress. Could be null. If a FileReaderExecutionMonitor is provided it is distinguished between user cancellations cutting the analysis short, and interrupts that return immediately and return null as result.
Returns:
settings that supposably provide more or less useful results. It will always be a non-null object - but may not contain any settings if guessing was just too hard.
Throws:
IOException - if there was an error reading from the URL


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.