Package de.bmiag.tapir.datasource.csv
Class AbstractCsvDataSource<DataType>
- java.lang.Object
-
- de.bmiag.tapir.datasource.api.AbstractDataSource<org.springframework.core.io.Resource,org.apache.commons.csv.CSVRecord,DataType>
-
- de.bmiag.tapir.datasource.csv.AbstractCsvDataSource<DataType>
-
- Type Parameters:
DataType
- The type provided by this data source
- All Implemented Interfaces:
DataSource<org.springframework.core.io.Resource,DataType>
public abstract class AbstractCsvDataSource<DataType> extends AbstractDataSource<org.springframework.core.io.Resource,org.apache.commons.csv.CSVRecord,DataType>
AbstractCsvDataSource
acts as base class for csv file data sources. It is based onResource
as selector type. TheDataSource.canHandle(Object)
methods checks for "csv" as file extension.This class uses
CSVFormat
for parsing the csv file.- Since:
- 3.0.0
- Author:
- Oliver Libutzki <[email protected]>
-
-
Constructor Summary
Constructors Constructor Description AbstractCsvDataSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canHandle(org.springframework.core.io.Resource resource)
This method is called by the framework in order to determine if the DataSource is able to provide data based on the given selector.protected java.util.Iterator<org.apache.commons.csv.CSVRecord>
getIterator(org.springframework.core.io.Resource resource)
Returns an iterator which traverses the source data types.java.lang.Class<org.springframework.core.io.Resource>
getSelectorType()
This method is called when a suitable DataSource is determined.-
Methods inherited from class de.bmiag.tapir.datasource.api.AbstractDataSource
getData, mapDataSet
-
-
-
-
Method Detail
-
canHandle
public boolean canHandle(org.springframework.core.io.Resource resource)
Description copied from interface:DataSource
This method is called by the framework in order to determine if the DataSource is able to provide data based on the given selector. If the method returns true,DataSource.getData(Object)
is called in order to obtain the data.canHandle is only called if the the selector is compatible with the Class returned by
DataSource.getSelectorType()
.Concrete data sources should rather extend
AbstractDataSource
than implementing this interface directly.- Parameters:
resource
- the selector which is used to determine the data to be provided- Returns:
- true, if the DataSource can provide data fpr the given selector, otherweise false.
-
getSelectorType
public java.lang.Class<org.springframework.core.io.Resource> getSelectorType()
Description copied from interface:DataSource
This method is called when a suitable DataSource is determined. DataSources can specify which selector types are supported.- Returns:
- the supported selector type.
-
getIterator
protected java.util.Iterator<org.apache.commons.csv.CSVRecord> getIterator(org.springframework.core.io.Resource resource)
Description copied from class:AbstractDataSource
Returns an iterator which traverses the source data types. Each entry is processed byAbstractDataSource.mapDataSet(Object)
.- Specified by:
getIterator
in classAbstractDataSource<org.springframework.core.io.Resource,org.apache.commons.csv.CSVRecord,DataType>
- Parameters:
resource
- the selector which is used to determine the data to be provided- Returns:
- an iterator which reflects the provided data sets
-
-