All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.univocity.api.data.DatasetFactory Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
/*******************************************************************************
 * Copyright (c) 2014 uniVocity Software Pty Ltd. All rights reserved.
 * This file is subject to the terms and conditions defined in file
 * 'LICENSE.txt', which is part of this source code package.
 ******************************************************************************/
package com.univocity.api.data;

import java.util.*;

import com.univocity.api.*;
import com.univocity.api.engine.*;

/**
 * A factory for creating {@link Dataset} instances backed by collections.
 * To get a DatasetFactory from uniVocity, use {@link Univocity#datasetFactory()}.
 *
 * @author uniVocity Software Pty Ltd - [email protected]
 *
 */
public interface DatasetFactory {

	/**
	 * Creates a new modifiable dataset backed by a collection of rows.
	 * @param rows the rows in the dataset
	 * @param identifier the name of the field that identifies rows in this dataset
	 * @param fieldNames the sequence of field names of each record in this data set.
	 * @return a new modifiable dataset.
	 */
	public ModifiableDataset newDataset(Collection rows, String identifier, String... fieldNames);

	/**
	 * Creates a new modifiable dataset backed by a collection of rows.
	 * @param rows the rows in the dataset
	 * @param identifiers the names of the fields that identify rows in this dataset
	 * @param fieldNames the sequence of field names of each record in this data set.
	 * @return a new modifiable dataset.
	 */
	public ModifiableDataset newDataset(Collection rows, String[] identifiers, String... fieldNames);

	/**
	 * 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. * @param the row type * @param rows the rows in the dataset * @param fieldName the name of the single field all records in this dataset have. * @return a new single-column, modifiable, dataset. */ public > ModifiableDataset newDataset(T rows, String fieldName); /** * Creates a new modifiable dataset, backed by a map. *

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

* * @param map the map used to hold all records of the data set. * @param identifier the field name used as identifier. The values in the identifier column will be used as keys in the map. * @param fieldNames the sequence of field names of each record in this data set. * @return a new modifiable dataset. */ public ModifiableDataset newDataset(Map map, String identifier, String... fieldNames); /** * Creates a new modifiable dataset, with 2 columns, backed by a map. *

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

* * @param map the map used to hold all records of the data set. * @param identifier the field name used as identifier. Values in the identifier column will be used as keys in the map. * @param fieldName field name of each value associated with an identifier of this data set. * @return a new modifiable dataset. */ public ModifiableDataset newDataset(Map map, String identifier, String fieldName); /** * 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. * * @param map the map used to hold all records of the data set. * @param identifiers the field names used to compose the identifier. * @param fieldNames the sequence of field names of each record in this data set. * @return a new modifiable dataset. */ public ModifiableDataset newDataset(Map map, String[] identifiers, String... fieldNames); /** * Creates a new modifiable dataset, backed by a map. *
The values in the identifier columns will be submitted to the {@link FunctionCall} to be converted into a key to be used in the map. *

Note new records with duplicate identifier values will replace existing records. * * @param the key type * @param map the map used to hold all records of the data set. * @param identifiers the field names used to compose the identifier. * @param fieldNames the sequence of field names of each record in this data set. * @param keyBuilder the function that iterates over identifier values to produce keys for the given map. * @return a new modifiable dataset. */ public ModifiableDataset newDataset(Map map, String[] identifiers, String[] fieldNames, FunctionCall keyBuilder); /** * Creates dummy dataset that does not store nor retrieve any data. * * @param identifier the name of the field used as an identifier among the fields in this dataset * @param fieldNames the sequence of field names for this data set. * @return a new dummy dataset. */ public ModifiableDataset newDummyDataset(String identifier, String... fieldNames); /** * Creates dummy dataset that does not store nor retrieve any data. * * @param identifiers the names of the fields used as identifiers among the fields in this dataset * @param fieldNames the sequence of field names for this data set. * @return a new dummy dataset. */ public ModifiableDataset newDummyDataset(String[] identifiers, String... fieldNames); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy