com.univocity.api.data
Interface DatasetFactory


public interface DatasetFactory

A factory for creating Dataset instances backed by collections. To get a DatasetFactory from uniVocity, use Univocity.datasetFactory().

Author:
uniVocity Software Pty Ltd - dev@univocity.com

Method Summary
 ModifiableDataset newDataset(Collection<Object[]> rows, String[] identifiers, String... fieldNames)
          Creates a new modifiable dataset backed by a collection of rows.
 ModifiableDataset newDataset(Collection<Object[]> rows, String identifier, String... fieldNames)
          Creates a new modifiable dataset backed by a collection of rows.
 ModifiableDataset newDataset(Map<?,?> map, String identifier, String fieldName)
          Creates a new modifiable dataset, with 2 columns, backed by a map.
 ModifiableDataset newDataset(Map<?,Object[]> map, String identifier, String... fieldNames)
          Creates a new modifiable dataset, backed by a map.
<K> ModifiableDataset
newDataset(Map<K,Object[]> map, String[] identifiers, String[] fieldNames, FunctionCall<K,Object[]> keyBuilder)
          Creates a new modifiable dataset, backed by a map.
 ModifiableDataset newDataset(Map<String,Object[]> map, String[] identifiers, String... fieldNames)
          Creates a new modifiable dataset, backed by a map.
<T extends Collection<?>>
ModifiableDataset
newDataset(T rows, String fieldName)
          Creates a new modifiable dataset, where records have a single column.
 ModifiableDataset newDummyDataset(String[] identifiers, String... fieldNames)
          Creates dummy dataset that does not store nor retrieve any data.
 ModifiableDataset newDummyDataset(String identifier, String... fieldNames)
          Creates dummy dataset that does not store nor retrieve any data.
 

Method Detail

newDataset

ModifiableDataset newDataset(Collection<Object[]> rows,
                             String identifier,
                             String... fieldNames)
Creates a new modifiable dataset backed by a collection of rows.

Parameters:
rows - the rows in the dataset
identifier - the name of the field that identifies rows in this dataset
fieldNames - the sequence of field names of each record in this data set.
Returns:
a new modifiable dataset.

newDataset

ModifiableDataset newDataset(Collection<Object[]> rows,
                             String[] identifiers,
                             String... fieldNames)
Creates a new modifiable dataset backed by a collection of rows.

Parameters:
rows - the rows in the dataset
identifiers - the names of the fields that identify rows in this dataset
fieldNames - the sequence of field names of each record in this data set.
Returns:
a new modifiable dataset.

newDataset

<T extends Collection<?>> ModifiableDataset newDataset(T rows,
                                                       String fieldName)
Creates a new modifiable dataset, where records have a single column.
This dataset is backed by a collection of objects and contains only one field. This field is also the identifier.

Type Parameters:
T - the row type
Parameters:
rows - the rows in the dataset
fieldName - the name of the single field all records in this dataset have.
Returns:
a new single-column, modifiable, dataset.

newDataset

ModifiableDataset newDataset(Map<?,Object[]> map,
                             String identifier,
                             String... fieldNames)
Creates a new modifiable dataset, backed by a map.

Note new records with duplicate identifier values will replace existing records.

Parameters:
map - the map used to hold all records of the data set.
identifier - the field name used as identifier. The values in the identifier column will be used as keys in the map.
fieldNames - the sequence of field names of each record in this data set.
Returns:
a new modifiable dataset.

newDataset

ModifiableDataset newDataset(Map<?,?> map,
                             String identifier,
                             String fieldName)
Creates a new modifiable dataset, with 2 columns, backed by a map.

Note new records with duplicate identifier values will replace existing records.

Parameters:
map - the map used to hold all records of the data set.
identifier - the field name used as identifier. Values in the identifier column will be used as keys in the map.
fieldName - field name of each value associated with an identifier of this data set.
Returns:
a new modifiable dataset.

newDataset

ModifiableDataset newDataset(Map<String,Object[]> map,
                             String[] identifiers,
                             String... fieldNames)
Creates a new modifiable dataset, backed by a map.
The values in the identifier columns will be concatenated into Strings which will be used as the keys in the map.

Note new records with duplicate identifier values will replace existing records.

Parameters:
map - the map used to hold all records of the data set.
identifiers - the field names used to compose the identifier.
fieldNames - the sequence of field names of each record in this data set.
Returns:
a new modifiable dataset.

newDataset

<K> ModifiableDataset newDataset(Map<K,Object[]> map,
                                 String[] identifiers,
                                 String[] fieldNames,
                                 FunctionCall<K,Object[]> keyBuilder)
Creates a new modifiable dataset, backed by a map.
The values in the identifier columns will be submitted to the FunctionCall to be converted into a key to be used in the map.

Note new records with duplicate identifier values will replace existing records.

Type Parameters:
K - the key type
Parameters:
map - the map used to hold all records of the data set.
identifiers - the field names used to compose the identifier.
fieldNames - the sequence of field names of each record in this data set.
keyBuilder - the function that iterates over identifier values to produce keys for the given map.
Returns:
a new modifiable dataset.

newDummyDataset

ModifiableDataset newDummyDataset(String identifier,
                                  String... fieldNames)
Creates dummy dataset that does not store nor retrieve any data.

Parameters:
identifier - the name of the field used as an identifier among the fields in this dataset
fieldNames - the sequence of field names for this data set.
Returns:
a new dummy dataset.

newDummyDataset

ModifiableDataset newDummyDataset(String[] identifiers,
                                  String... fieldNames)
Creates dummy dataset that does not store nor retrieve any data.

Parameters:
identifiers - the names of the fields used as identifiers among the fields in this dataset
fieldNames - the sequence of field names for this data set.
Returns:
a new dummy dataset.


Copyright © 2015 uniVocity Software Pty Ltd. All rights reserved.