net.sourceforge.squirrel_sql.plugins.dataimport.importer
Interface IFileImporter

All Known Implementing Classes:
CSVFileImporter, ExcelFileImporter

public interface IFileImporter

This interface describes an importer for a file type.

Author:
Thorsten Mürell

Method Summary
 boolean close()
          Closes the file.
 JComponent getConfigurationPanel()
          This method returns the panel that is used to configure the importer.
 Date getDate(int column)
          Returns the given column as a date
 Integer getInt(int column)
          Returns the given column as an integer
 Long getLong(int column)
          Returns the given column as a long
 String[][] getPreview(int noOfLines)
          Returns a preview of the importer's data in string format
 int getRows()
          Returns the number of rows in the file.
 String getString(int column)
          Returns the given column as a string
 boolean next()
          Moves the file pointer to the next row.
 boolean open()
          Opens the file.
 boolean reset()
          Resets the file pointer to the first row.
 

Method Detail

open

boolean open()
             throws IOException
Opens the file. This method has to used in order to read the file.

Returns:
true on success, false otherwise
Throws:
IOException - If an I/O error occurs, this exception is thrown

close

boolean close()
              throws IOException
Closes the file. This method has to be called after you finished reading the file.

Returns:
true on success, false otherwise
Throws:
IOException - If an I/O error occurs, this exception is thrown

getPreview

String[][] getPreview(int noOfLines)
                      throws IOException
Returns a preview of the importer's data in string format

Parameters:
noOfLines - The lines to return
Returns:
A table with noOfLines rows
Throws:
IOException - If an error reading the import file occurred.

getRows

int getRows()
            throws IOException
Returns the number of rows in the file.

Returns:
The number of rows in the file or -1 if the value is unknown.
Throws:
IOException - If an I/O error occurs, this exception is thrown

reset

boolean reset()
              throws IOException
Resets the file pointer to the first row.

Returns:
true on success, false otherwise
Throws:
IOException - If an I/O error occurs, this exception is thrown

next

boolean next()
             throws IOException
Moves the file pointer to the next row.

Returns:
true on success, false otherwise
Throws:
IOException - If an I/O error occurs, this exception is thrown

getString

String getString(int column)
                 throws IOException
Returns the given column as a string

Parameters:
column - The column number to retrieve
Returns:
The string value of the column
Throws:
IOException - If an I/O error occurs, this exception is thrown

getLong

Long getLong(int column)
             throws IOException,
                    UnsupportedFormatException
Returns the given column as a long

Parameters:
column - The column number to retrieve
Returns:
The long value of the column
Throws:
IOException - If an I/O error occurs, this exception is thrown
UnsupportedFormatException - If the column cannot be converted to a long

getInt

Integer getInt(int column)
               throws IOException,
                      UnsupportedFormatException
Returns the given column as an integer

Parameters:
column - The column number to retrieve
Returns:
The integer value of the column
Throws:
IOException - If an I/O error occurs, this exception is thrown
UnsupportedFormatException - If the column cannot be converted to an integer

getDate

Date getDate(int column)
             throws IOException,
                    UnsupportedFormatException
Returns the given column as a date

Parameters:
column - The column number to retrieve
Returns:
The date value of the column
Throws:
IOException - If an I/O error occurs, this exception is thrown
UnsupportedFormatException - If the column cannot be converted to a date

getConfigurationPanel

JComponent getConfigurationPanel()
This method returns the panel that is used to configure the importer. The importer is not required to show this panel. So you should provide reasonable defaults for the setting values. E.g. the importer can ask for columns seperators.

Returns:
The panel to include in the question dialog. Return null to signal, that no configuration is possible and no dialog should be shown.


Copyright © 2001-2011. All Rights Reserved.