uk.ac.ebi.adfconverter.common.tools.file.reader
Class DataFileReader

java.lang.Object
  extended byuk.ac.ebi.adfconverter.common.tools.file.reader.DataFileReaderIntf
      extended byuk.ac.ebi.adfconverter.common.tools.file.reader.DataFileReader

public class DataFileReader
extends DataFileReaderIntf

This class converts data from a file in a DataTable in Java, for manipulation

Version:
1
Author:
Pierre MARGUERITE
See Also:
DataTable

Constructor Summary
DataFileReader(java.io.File aFile)
          constructor for converting a data file in data table in memory
DataFileReader(java.io.File aFile, boolean hasHeader)
          constructor for converting a data file in data table in memory
 
Method Summary
 void close()
          Closes file access/ reading
 DataTable getData()
          Retrieves data from file
 DataTable getData(int fileFormat)
          Retrieves data from file in a given file format, specifying file format type
 DataTable getData(java.lang.String enc, java.lang.String delimiter, java.lang.String escape, int orientation, int type)
          Retrieves data from file with a specific character encoding
 DataRow getHorizontalDataRow()
          Retrieves the next datarow in the horizontal datable.
 DataTable getHorizontalDataTable(java.lang.String enc, java.lang.String delimiter, java.lang.String escape)
          Retrieves data from file with a specific character encoding in a vertical orientation of data
 DataTable getHorizontalDataTable(java.lang.String enc, java.lang.String delimiter, java.lang.String escape, int type)
          Retrieves data from file with a specific character encoding in a horizontal orientation of data
 DataTableHeader getHorizontalHeader()
          Retrieves the header of a horizontal data table contained in a file
 DataTable getVerticalDataTable(java.lang.String enc, java.lang.String delimiter, java.lang.String escape)
          Retrieves data from file with a specific character encoding in a vertical orientation of data
 DataTable getVerticalDataTable(java.lang.String enc, java.lang.String delimiter, java.lang.String escape, int type)
          Retrieves data from file with a specific character encoding in a vertical orientation of data
 DataTable horizontalToVerticalTable(DataTable table)
          ConvertTable from table obtained from a file in the correct data orientation
 boolean open(java.lang.String enc, java.lang.String delimiter, java.lang.String escape, int type)
          Open a data file with a given character encoding , delimiter and escape strings , file orientation and file type
 
Methods inherited from class uk.ac.ebi.adfconverter.common.tools.file.reader.DataFileReaderIntf
containsHeader, containsHeader, getFile, setSheet, setSheet
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataFileReader

public DataFileReader(java.io.File aFile)
constructor for converting a data file in data table in memory

Parameters:
aFile - a file object of a file containing data

DataFileReader

public DataFileReader(java.io.File aFile,
                      boolean hasHeader)
constructor for converting a data file in data table in memory

Parameters:
aFile - a file object of a file containing data
hasHeader - a boolean indicating if the first row is considered as the table header
Method Detail

close

public void close()
Closes file access/ reading

Specified by:
close in class DataFileReaderIntf

getData

public DataTable getData()
                  throws java.io.IOException,
                         IncorrectFile,
                         IncorrectDataFile
Retrieves data from file

Specified by:
getData in class DataFileReaderIntf
Returns:
the data contained in the data file as DataTable
Throws:
java.io.IOException - if an error occurs during file access
IncorrectFile - if the opened file is incorrect (not as expected)
IncorrectDataFile - if the opened data file is incorrect.(incorrect data type, incorrect file structure)

getData

public DataTable getData(int fileFormat)
                  throws java.io.IOException,
                         IncorrectFile,
                         IncorrectDataFile
Retrieves data from file in a given file format, specifying file format type

Specified by:
getData in class DataFileReaderIntf
Parameters:
fileFormat - the file format
Returns:
the data contained in the data file as DataTable
Throws:
java.io.IOException - if an error occurs during file access
IncorrectFile - if the opened file is incorrect (not as expected)
IncorrectDataFile - if the opened data file is incorrect.(incorrect data type, incorrect file structure)

getData

public DataTable getData(java.lang.String enc,
                         java.lang.String delimiter,
                         java.lang.String escape,
                         int orientation,
                         int type)
                  throws java.io.IOException,
                         IncorrectFile,
                         IncorrectDataFile
Retrieves data from file with a specific character encoding

Specified by:
getData in class DataFileReaderIntf
Parameters:
enc - a character encoding
delimiter - the delimiter string in a row (line)
escape - the escape string of a row in the file
type - the type of the data file
Returns:
the retrieved data table from the data file
Throws:
java.io.IOException
IncorrectFile
IncorrectDataFile
See Also:

authorizes file format
Description of Data Content Typical Filename Extensions MIME type/subtype Text and Text-Related Types HTML text data (RFC 1866) html htm text/html Plain text: documents; program listings txt c c++ pl cc h text/plain Excel spreadsheet (Microsoft) xls, xlc, xll, xlm, xlw application/vnd.ms-excel application/x-msexcel application/ms-excel application/msexcel application/x-excel *


getHorizontalDataRow

public DataRow getHorizontalDataRow()
                             throws java.io.IOException,
                                    IncorrectDataFile
Retrieves the next datarow in the horizontal datable. Must be call after calling once open method

Specified by:
getHorizontalDataRow in class DataFileReaderIntf
Returns:
the next retrieved DataRow, if existing. null, otherwise.
Throws:
java.io.IOException
IncorrectDataFile

getHorizontalDataTable

public DataTable getHorizontalDataTable(java.lang.String enc,
                                        java.lang.String delimiter,
                                        java.lang.String escape)
                                 throws java.io.IOException,
                                        IncorrectFile,
                                        IncorrectDataFile
Retrieves data from file with a specific character encoding in a vertical orientation of data

Specified by:
getHorizontalDataTable in class DataFileReaderIntf
Parameters:
enc - a character encoding
delimiter - the delimiter string in a row (line)
escape - the escape string of a row in the file
Returns:
contained data as DataTable (each table is in correct composition - accessible as horizontal table)
Throws:
java.io.IOException - if an error occurs during file access
IncorrectFile - if the opened file is incorrect (not as expected)
IncorrectDataFile - if the opened data file is incorrect.(incorrect data type,

getHorizontalDataTable

public DataTable getHorizontalDataTable(java.lang.String enc,
                                        java.lang.String delimiter,
                                        java.lang.String escape,
                                        int type)
                                 throws java.io.IOException,
                                        IncorrectFile,
                                        IncorrectDataFile
Retrieves data from file with a specific character encoding in a horizontal orientation of data

Specified by:
getHorizontalDataTable in class DataFileReaderIntf
Parameters:
enc - a character encoding
delimiter - the delimiter string in a row (line)
escape - the escape string of a row in the file
type - the type of the data file
Returns:
contained data as DataTable (each table is in correct composition - accessible as horizontal table)
Throws:
java.io.IOException - if an error occurs during file access
IncorrectFile - if the opened file is incorrect (not as expected)
IncorrectDataFile - if the opened data file is incorrect.(incorrect data type,
See Also:
DataTable

getHorizontalHeader

public DataTableHeader getHorizontalHeader()
                                    throws java.io.IOException,
                                           IncorrectDataFile
Retrieves the header of a horizontal data table contained in a file

Specified by:
getHorizontalHeader in class DataFileReaderIntf
Returns:
the retrieved DataTableHeader, if the table contains an header. null, otherwise.
Throws:
java.io.IOException
IncorrectDataFile

getVerticalDataTable

public DataTable getVerticalDataTable(java.lang.String enc,
                                      java.lang.String delimiter,
                                      java.lang.String escape)
                               throws java.io.IOException,
                                      IncorrectFile,
                                      IncorrectDataFile
Retrieves data from file with a specific character encoding in a vertical orientation of data

Specified by:
getVerticalDataTable in class DataFileReaderIntf
Parameters:
enc - a character encoding
delimiter - the delimiter string in a row (line)
escape - the escape string of a row in the file
Returns:
contained data as DataTable (each table is in correct composition - accessible as horizontal table)
Throws:
java.io.IOException - if an error occurs during file access
IncorrectFile - if the opened file is incorrect (not as expected)
IncorrectDataFile - if the opened data file is incorrect.(incorrect data type,

getVerticalDataTable

public DataTable getVerticalDataTable(java.lang.String enc,
                                      java.lang.String delimiter,
                                      java.lang.String escape,
                                      int type)
                               throws java.io.IOException,
                                      IncorrectFile,
                                      IncorrectDataFile
Retrieves data from file with a specific character encoding in a vertical orientation of data

Specified by:
getVerticalDataTable in class DataFileReaderIntf
Parameters:
enc - a character encoding
delimiter - the delimiter string in a row (line)
escape - the escape string of a row in the file
type - the type of the data file
Returns:
contained data as DataTable (each table is in correct composition - accessible as horizontal table)
Throws:
java.io.IOException - if an error occurs during file access
IncorrectFile - if the opened file is incorrect (not as expected)
IncorrectDataFile - if the opened data file is incorrect.(incorrect data type,
See Also:
DataTable

horizontalToVerticalTable

public DataTable horizontalToVerticalTable(DataTable table)
ConvertTable from table obtained from a file in the correct data orientation

Parameters:
table - the table to change orientation
Returns:
the table in the correct orientation TODO conversion for table without header

open

public boolean open(java.lang.String enc,
                    java.lang.String delimiter,
                    java.lang.String escape,
                    int type)
Open a data file with a given character encoding , delimiter and escape strings , file orientation and file type

Specified by:
open in class DataFileReaderIntf
Parameters:
enc -
delimiter -
escape -
type -
Returns:
true, if the file is opened correctly.
See Also:
DataTable


European Bioinformatics InstituteMicroarray Informatics Team