Package csv.util
Class ObjectReader<T>
java.lang.Object
csv.util.ObjectReader<T>
Reads objects from a table.
This class is different to BeanReader
as it asks a converter to convert the row.
// Create an instance of your table reader TableReader tableReader = ...; // Get an instance of your row converter RowConverter<MyClass> converter = new MyClassConverter(); // Now read from the table stream ObjectReader<MyClass> reader = new ObjectReader(tableReader, converter, true); Object tableHeader[] = reader.getTableHeader(); while (reader.hasNext()) { MyClass myObject = reader.next(); // do something... } // Close the reader reader.close();
- Author:
- ralph
-
Field Summary
Modifier and TypeFieldDescriptionprotected RowConverter<T>
protected TableReader
protected Object[]
-
Constructor Summary
ConstructorDescriptionObjectReader
(TableReader reader, RowConverter<T> converter, boolean hasHeaderRow) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the stream.Returns the row converter.Object[]
Returns the header row that was read.boolean
hasNext()
iterator()
next()
void
setConverter
(RowConverter<T> converter) Sets the row converter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Field Details
-
reader
-
iterator
-
converter
-
tableHeader
-
-
Constructor Details
-
ObjectReader
Constructor.- Parameters:
reader
- the underlying table readerconverter
- the converter to be usedhasHeaderRow
- whether the table has a table header to read
-
-
Method Details
-
getTableHeader
Returns the header row that was read.- Returns:
- the header row or null if no such row was read.
-
getConverter
Returns the row converter.- Returns:
- the row converter
-
setConverter
Sets the row converter.- Parameters:
converter
- the row converter to be used
-
iterator
-
hasNext
public boolean hasNext() -
next
-
close
public void close()Closes the stream.
-