ru.sstu.tables
Class XlsTableReader

java.lang.Object
  extended by ru.sstu.tables.XlsTableReader
All Implemented Interfaces:
TableReader

public class XlsTableReader
extends Object

XlsTableReader class provides data read from old Excel 2003 file.

Since:
Tables 1.0
Author:
Dmitry_Petrov, Denis_Murashev

Constructor Summary
XlsTableReader()
           
 
Method Summary
 void addConverter(Class<?> fromClass, Class<?> toClass, Converter converter)
          Adds support for converting values from fromClass to toClass.
 Converter getConverter(Class<?> fromClass, Class<?> toClass)
          Provides converter for given types.
protected  boolean hasNextLine()
          
protected  void init(InputStream input, int index)
          Data reader initialization.
protected  void nextLine()
          Moves reader to next line of data.
protected  Object nextValue(int index)
          Reads next value.
<T> List<T>
read(Mapping<T> mapping, InputStream input)
          Reads table data from given input stream.
<T> List<T>
read(Mapping<T> mapping, InputStream input, int tableIndex)
          Reads table data from given input stream.
 void setDateFormat(String dateFormat)
          Sets used date format.
protected  void setRows(Iterator<org.apache.poi.ss.usermodel.Row> rows)
          Sets rows data.
 void skip(int count)
          Skips data of size count.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XlsTableReader

public XlsTableReader()
Method Detail

init

protected void init(InputStream input,
                    int index)
             throws TableException
Data reader initialization.

Parameters:
input - input stream
index - table index
Throws:
TableException - if cannot initialize data reader

nextLine

protected void nextLine()
                 throws TableException
Moves reader to next line of data.

Throws:
TableException - if cannot move reader

hasNextLine

protected boolean hasNextLine()

Returns:
true if next line of data can be read

nextValue

protected Object nextValue(int index)
                    throws TableException
Reads next value.

Parameters:
index - value index
Returns:
next value
Throws:
TableException - if cannot read value

setRows

protected void setRows(Iterator<org.apache.poi.ss.usermodel.Row> rows)
Sets rows data.

Parameters:
rows - the rows to set

read

public <T> List<T> read(Mapping<T> mapping,
                        InputStream input)
             throws TableException
Reads table data from given input stream.

Specified by:
read in interface TableReader
Type Parameters:
T - type of table row
Parameters:
mapping - mapping for class and table
input - input stream for table data
Returns:
list of object read from input stream
Throws:
TableException - if cannot read data

read

public <T> List<T> read(Mapping<T> mapping,
                        InputStream input,
                        int tableIndex)
             throws TableException
Reads table data from given input stream.

Specified by:
read in interface TableReader
Type Parameters:
T - type of table row
Parameters:
mapping - mapping for class and table
input - input stream for table data
tableIndex - index of table to be read (if input stream has more then 1 table)
Returns:
list of objects read from input stream
Throws:
TableException - if cannot read data

skip

public void skip(int count)
Skips data of size count.

Specified by:
skip in interface TableReader
Parameters:
count - data to be skipped

addConverter

public void addConverter(Class<?> fromClass,
                         Class<?> toClass,
                         Converter converter)
Adds support for converting values from fromClass to toClass.

Specified by:
addConverter in interface TableReader
Parameters:
fromClass - from class
toClass - to class
converter - converter

getConverter

public Converter getConverter(Class<?> fromClass,
                              Class<?> toClass)
                       throws TableException
Provides converter for given types.

Specified by:
getConverter in interface TableReader
Parameters:
fromClass - from class
toClass - to class
Returns:
converter
Throws:
TableException - if desired converter does not exist
See Also:
TableReader.addConverter(Class, Class, Converter)

setDateFormat

public void setDateFormat(String dateFormat)
Sets used date format.

Specified by:
setDateFormat in interface TableReader
Parameters:
dateFormat - date format
See Also:
SimpleDateFormat


Copyright © 2012 TFI branch of Engels Instutute of Technology. All Rights Reserved.