com.univocity.api.entity.text
Class TextDataStoreConfiguration<T extends TextEntityConfiguration<?>>

java.lang.Object
  extended by com.univocity.api.entity.custom.DataStoreConfiguration
      extended by com.univocity.api.entity.text.TextDataStoreConfiguration<T>
Type Parameters:
T - the configuration class that manages a specific text-based data entity.
Direct Known Subclasses:
CsvDataStoreConfiguration, FixedWidthDataStoreConfiguration, TsvDataStoreConfiguration

public abstract class TextDataStoreConfiguration<T extends TextEntityConfiguration<?>>
extends DataStoreConfiguration

This is the parent class for all configuration classes used by uniVocity text-based data stores. It provides essential configuration settings for managing inputs and outputs of text-based data entities.

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

Constructor Summary
TextDataStoreConfiguration(String dataStoreName, T defaultEntityConfiguration)
          Initializes the configuration object of a text-based data store.
 
Method Summary
 void addEntities(Collection<File> files)
          Adds a collection of files to this data store.
 void addEntities(Collection<File> files, Charset encoding)
          Adds a collection of files to this data store.
 void addEntities(Collection<File> files, String encoding)
          Adds a collection of files to this data store.
 void addEntities(File directory)
          Adds all files under the given directory to this data store.
 void addEntities(File directory, Charset encoding)
          Adds all files under the given directory to this data store.
 void addEntities(File directory, String encoding)
          Adds all files under the given directory to this data store.
 void addEntities(String directoryPath)
          Adds all files under the given directory path to this data store.
 void addEntities(String directoryPath, Charset encoding)
          Adds all files under the given directory path to this data store.
 void addEntities(String directoryPath, String encoding)
          Adds all files under the given directory path to this data store.
 void addEntity(File file)
          Adds a file to this data store.
 void addEntity(File file, Charset encoding)
          Adds a file to this data store.
 void addEntity(File file, String encoding)
          Adds a file to this data store.
 void addEntity(String entityName, File file)
          Adds a file to this data store.
 void addEntity(String entityName, File file, Charset encoding)
          Adds a file to this data store.
 void addEntity(String entityName, File file, String encoding)
          Adds a file to this data store.
 void addEntity(String entityName, ReaderProvider reader)
          Adds a read-only data entity to this data store.
 void addEntity(String entityName, String resource)
          Adds a resource to this data store.
 void addEntity(String entityName, String resource, Charset encoding)
          Adds a resource to this data store.
 void addEntity(String entityName, String resource, String encoding)
          Adds a resource to this data store.
 void addEntity(String entityName, WriterProvider writer)
          Adds a write-only data entity to this data store.
 T getDefaultEntityConfiguration()
          Returns the default configuration object.
 T getEntityConfiguration(String entityName)
          Returns the configuration of a given data entity.
 Map<String,T> getEntityConfigurations()
          Returns an unmodifiable map containing the configurations of all entities in this data store
 Map<String,ReaderProvider> getEntityReaders()
          Returns an unmodifiable map of reader providers for read only entities
 Map<String,WriterProvider> getEntityWriters()
          Returns an unmodifiable map of writer providers for write-only entities.
 Set<FileProvider> getFileDirectories()
          Returns an unmodifiable set of file providers for directories.
 int getLimitOfRowsLoadedInMemory()
          Returns the maximum number of rows loaded in memory from data entities of this data store at any given time.
 Map<String,FileProvider> getNamedEntityFiles()
          Returns an unmodifiable map of file providers for entities that were created with an explicit name.
 FileProvider getOutputDirectory()
          Returns the output directory onto which files that serve as "clones" of source entities should be created.
 Set<FileProvider> getUnnamedEntityFiles()
          Returns an unmodifiable set of file providers for entities that were created without an explicit name.
abstract  T newEntityConfiguration()
          Creates a new configuration object for an entity of this data store.
 T newEntityConfigurationWithDefaults()
          Creates a new configuration object for an entity of this data store using the default values provided in the object returned by getDefaultEntityConfiguration().
 void setLimitOfRowsLoadedInMemory(int maxRowsInMemory)
          Defines the maximum number of rows loaded in memory from data entities of this data store at any given time.
 void setOutputDirectory(File directory)
          Defines an output directory onto which files that serve as "clones" of source entities should be created.
 void setOutputDirectory(File directory, Charset encoding)
          Defines an output directory onto which files that serve as "clones" of source entities should be created.
 void setOutputDirectory(File directory, String encoding)
          Defines an output directory onto which files that serve as "clones" of source entities should be created.
 void setOutputDirectory(String directoryPath)
          Defines an output directory onto which files that serve as "clones" of source entities should be created.
 void setOutputDirectory(String directoryPath, Charset encoding)
          Defines an output directory onto which files that serve as "clones" of source entities should be created.
 void setOutputDirectory(String directoryPath, String encoding)
          Defines an output directory onto which files that serve as "clones" of source entities should be created.
 
Methods inherited from class com.univocity.api.entity.custom.DataStoreConfiguration
enableDatabaseOperationsIn, enableDatabaseOperationsIn, getDatabaseEnabledEntities, getDataStoreName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextDataStoreConfiguration

public TextDataStoreConfiguration(String dataStoreName,
                                  T defaultEntityConfiguration)
Initializes the configuration object of a text-based data store.

Parameters:
dataStoreName - the name of the data store.
defaultEntityConfiguration - an object with default configurations for data entities associated with this data store.
Method Detail

addEntities

public final void addEntities(Collection<File> files)
Adds a collection of files to this data store. Each file will be used as an individual data entity for reading/writing.

The file names will be used as entity names.

Note: As the encoding of these files is not provided, the default system encoding will be used.

Parameters:
files - the collection of files to use as data entities of this data store.

addEntities

public final void addEntities(Collection<File> files,
                              Charset encoding)
Adds a collection of files to this data store. Each file will be used as an individual data entity for reading/writing.

The file names will be used as entity names.

Parameters:
files - the collection of files to use as data entities of this data store.
encoding - the encoding to be used when handling the provided files.

addEntities

public final void addEntities(Collection<File> files,
                              String encoding)
Adds a collection of files to this data store. Each file will be used as an individual data entity for reading/writing.

The file names will be used as entity names.

Parameters:
files - the collection of files to use as data entities of this data store.
encoding - the encoding to be used when handling the provided files.

addEntities

public final void addEntities(String directoryPath)
Adds all files under the given directory path to this data store. Each file will be used as an individual data entity for reading/writing.

The file names will be used as entity names.

Note: As the encoding of these files is not provided, the default system encoding will be used.

Parameters:
directoryPath - the path to directory in the file system that contains files to be used as data entities.

addEntities

public final void addEntities(String directoryPath,
                              String encoding)
Adds all files under the given directory path to this data store. Each file will be used as an individual data entity for reading/writing.

The file names will be used as entity names.

Parameters:
directoryPath - the path to directory in the file system that contains files to be used as data entities.
encoding - the encoding to be used when handling the provided files.

addEntities

public final void addEntities(String directoryPath,
                              Charset encoding)
Adds all files under the given directory path to this data store. Each file will be used as an individual data entity for reading/writing.

The file names will be used as entity names.

Parameters:
directoryPath - the path to directory in the file system that contains files to be used as data entities.
encoding - the encoding to be used when handling the provided files.

addEntities

public final void addEntities(File directory)
Adds all files under the given directory to this data store. Each file will be used as an individual data entity for reading/writing.

The file names will be used as entity names.

Note: As the encoding of these files is not provided, the default system encoding will be used.

Parameters:
directory - the directory in the file system that contains files to be used as data entities.

addEntities

public final void addEntities(File directory,
                              String encoding)
Adds all files under the given directory to this data store. Each file will be used as an individual data entity for reading/writing.

The file names will be used as entity names.

Parameters:
directory - the directory in the file system that contains files to be used as data entities.
encoding - the encoding to be used when handling the provided files.

addEntities

public final void addEntities(File directory,
                              Charset encoding)
Adds all files under the given directory to this data store. Each file will be used as an individual data entity for reading/writing.

The file names will be used as entity names.

Parameters:
directory - the directory in the file system that contains files to be used as data entities.
encoding - the encoding to be used when handling the provided files.

addEntity

public final void addEntity(String entityName,
                            ReaderProvider reader)
Adds a read-only data entity to this data store.

Parameters:
entityName - the entity name
reader - the handle to obtain input readers (Reader) for this data entity.

addEntity

public final void addEntity(String entityName,
                            WriterProvider writer)
Adds a write-only data entity to this data store.

Parameters:
entityName - the entity name
writer - the handle to obtain output writers (Writer) for this data entity.

addEntity

public final void addEntity(File file)
Adds a file to this data store. It will be used as an individual data entity for reading/writing.

Note: As the file encoding is not provided, the default system encoding will be used.

Parameters:
file - the file to use as a data entity of this data store.

addEntity

public final void addEntity(File file,
                            String encoding)
Adds a file to this data store. It will be used as an individual data entity for reading/writing.

The file name will be used as the entity name.

Parameters:
file - the file to use as a data entity of this data store.
encoding - the encoding to be used when handling the provided file.

addEntity

public final void addEntity(File file,
                            Charset encoding)
Adds a file to this data store. It will be used as an individual data entity for reading/writing.

The file name will be used as the entity name.

Parameters:
file - the file to use as a data entity of this data store.
encoding - the encoding to be used when handling the provided file.

addEntity

public final void addEntity(String entityName,
                            String resource)
Adds a resource to this data store. The resource path can be a file in the class path or in the file system. It will be used as an individual data entity for reading/writing.

Note: As the resource encoding is not provided, the default system encoding will be used.

Parameters:
entityName - the name of the given data entity in this data store.
resource - the path to a resource to be used as a data entity of this data store

addEntity

public final void addEntity(String entityName,
                            String resource,
                            String encoding)
Adds a resource to this data store. The resource path can be a file in the class path or in the file system. It will be used as an individual data entity for reading/writing.

Parameters:
entityName - the name of the given data entity in this data store.
resource - the path to a resource to be used as a data entity of this data store
encoding - the encoding to be used when handling the provided resource.

addEntity

public final void addEntity(String entityName,
                            String resource,
                            Charset encoding)
Adds a resource to this data store. The resource path can be a file in the class path or in the file system. It will be used as an individual data entity for reading/writing.

Parameters:
entityName - the name of the given data entity in this data store.
resource - the path to a resource to be used as a data entity of this data store
encoding - the encoding to be used when handling the provided resource.

addEntity

public final void addEntity(String entityName,
                            File file)
Adds a file to this data store. It will be used as an individual data entity for reading/writing.

Note: As the file encoding is not provided, the default system encoding will be used.

Parameters:
entityName - the name of the data entity in this data store.
file - the file to use as a data entity of this data store.

addEntity

public final void addEntity(String entityName,
                            File file,
                            String encoding)
Adds a file to this data store. It will be used as an individual data entity for reading/writing.

Parameters:
entityName - the name of the data entity in this data store.
file - the file to use as a data entity of this data store.
encoding - the encoding to be used when handling the provided file.

addEntity

public final void addEntity(String entityName,
                            File file,
                            Charset encoding)
Adds a file to this data store. It will be used as an individual data entity for reading/writing.

Parameters:
entityName - the name of the data entity in this data store.
file - the file to use as a data entity of this data store.
encoding - the encoding to be used when handling the provided file.

getEntityConfiguration

public final T getEntityConfiguration(String entityName)
Returns the configuration of a given data entity. The returned configuration object will contain default values provided in the object returned by getDefaultEntityConfiguration().
If the entity was not explicitly configured before, a new configuration object will be created and associated with the entity.

You can change the default configuration at any time by calling getDefaultEntityConfiguration() and altering the settings you need. Subsequent calls to getEntityConfiguration(String) will return a configuration object with the new defaults. Existing configurations will retain their original values, including the default settings previously used.

Parameters:
entityName - the name of the entity to be configured
Returns:
a configuration object for the given data entity.

getEntityConfigurations

public final Map<String,T> getEntityConfigurations()
Returns an unmodifiable map containing the configurations of all entities in this data store

Returns:
an unmodifiable map containing the configurations of all entities in this data store

getDefaultEntityConfiguration

public final T getDefaultEntityConfiguration()
Returns the default configuration object. This object returns all default values used for creating new configuration objects for data entities.

Returns:
the defaultEntityConfiguration object which was provided in the constructor of this data store.

getLimitOfRowsLoadedInMemory

public final int getLimitOfRowsLoadedInMemory()
Returns the maximum number of rows loaded in memory from data entities of this data store at any given time.
This is required to avoid getting an OutOfMemoryError when reading from large inputs.
uniVocity will block the input reading thread until there is room for more rows.

defaults to 10,000.

Specified by:
getLimitOfRowsLoadedInMemory in class DataStoreConfiguration
Returns:
the maximum number of rows loaded in memory from any data entity at any given time.

setLimitOfRowsLoadedInMemory

public final void setLimitOfRowsLoadedInMemory(int maxRowsInMemory)
Defines the maximum number of rows loaded in memory from data entities of this data store at any given time.
This is required to avoid getting an OutOfMemoryError when reading from large inputs.
uniVocity will block the input reading thread until there is room for more rows.

Parameters:
maxRowsInMemory - the maximum number of rows loaded in memory from any data entity at any given time. This value must be greater than 0.

getFileDirectories

public final Set<FileProvider> getFileDirectories()
Returns an unmodifiable set of file providers for directories.

Returns:
an unmodifiable set of file providers for directories

getEntityReaders

public final Map<String,ReaderProvider> getEntityReaders()
Returns an unmodifiable map of reader providers for read only entities

Returns:
an unmodifiable map of reader providers for read only entities

getEntityWriters

public final Map<String,WriterProvider> getEntityWriters()
Returns an unmodifiable map of writer providers for write-only entities.

Returns:
an unmodifiable map of writer providers for write-only entities

getNamedEntityFiles

public final Map<String,FileProvider> getNamedEntityFiles()
Returns an unmodifiable map of file providers for entities that were created with an explicit name.

Returns:
an unmodifiable map of file providers for entities that were created with an explicit name

getUnnamedEntityFiles

public final Set<FileProvider> getUnnamedEntityFiles()
Returns an unmodifiable set of file providers for entities that were created without an explicit name.

Returns:
an unmodifiable set of file providers for entities that were created without an explicit name

newEntityConfiguration

public abstract T newEntityConfiguration()
Creates a new configuration object for an entity of this data store.

Returns:
new configuration object for an entity of this data store

newEntityConfigurationWithDefaults

public T newEntityConfigurationWithDefaults()
Creates a new configuration object for an entity of this data store using the default values provided in the object returned by getDefaultEntityConfiguration().

Returns:
new configuration object for an entity of this data store, using the default values provided in the object returned by getDefaultEntityConfiguration().

setOutputDirectory

public final void setOutputDirectory(String directoryPath,
                                     Charset encoding)
Defines an output directory onto which files that serve as "clones" of source entities should be created. If required, new entities will be created with the exact same name of the source entity, and with the same fields.

Parameters:
directoryPath - the path to directory in the file system that stores files that may be created automatically to store data dumped from a source entity. Once the file is created its data can be accessed normally.
encoding - encoding the encoding that must be used to read from/write to each file in this directory.

setOutputDirectory

public final void setOutputDirectory(String directoryPath,
                                     String encoding)
Defines an output directory onto which files that serve as "clones" of source entities should be created. If required, new entities will be created with the exact same name of the source entity, and with the same fields.

Parameters:
directoryPath - the path to directory in the file system that stores files that may be created automatically to store data dumped from a source entity. Once the file is created its data can be accessed normally.
encoding - encoding the encoding that must be used to read from/write to each file in this directory.

setOutputDirectory

public final void setOutputDirectory(File directory,
                                     Charset encoding)
Defines an output directory onto which files that serve as "clones" of source entities should be created. If required, new entities will be created with the exact same name of the source entity, and with the same fields.

Parameters:
directory - a directory in the file system that stores files that may be created automatically to store data dumped from a source entity. Once the file is created its data can be accessed normally.
encoding - encoding the encoding that must be used to read from/write to each file in this directory.

setOutputDirectory

public final void setOutputDirectory(File directory,
                                     String encoding)
Defines an output directory onto which files that serve as "clones" of source entities should be created. If required, new entities will be created with the exact same name of the source entity, and with the same fields.

Parameters:
directory - a directory in the file system that stores files that may be created automatically to store data dumped from a source entity. Once the file is created its data can be accessed normally.
encoding - encoding the encoding that must be used to read from/write to each file in this directory.

setOutputDirectory

public final void setOutputDirectory(File directory)
Defines an output directory onto which files that serve as "clones" of source entities should be created. If required, new entities will be created with the exact same name of the source entity, and with the same fields.

Note: As no encoding is provided in this method, the default system encoding will be used.

Parameters:
directory - a directory in the file system that stores files that may be created automatically to store data dumped from a source entity. Once the file is created its data can be accessed normally.

setOutputDirectory

public final void setOutputDirectory(String directoryPath)
Defines an output directory onto which files that serve as "clones" of source entities should be created. If required, new entities will be created with the exact same name of the source entity, and with the same fields.

Note: As no encoding is provided in this method, the default system encoding will be used.

Parameters:
directoryPath - the path to directory in the file system that stores files that may be created automatically to store data dumped from a source entity. Once the file is created its data can be accessed normally.

getOutputDirectory

public final FileProvider getOutputDirectory()
Returns the output directory onto which files that serve as "clones" of source entities should be created. If required, new entities will be created with the exact same name of the source entity, and with the same fields.

Returns:
the output directory where files of dynamically created entities will be stored.


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