Package net.sf.basedb.util.bfs
Class AbstractDataWriterFactory<T>
java.lang.Object
net.sf.basedb.util.bfs.AbstractDataWriterFactory<T>
- All Implemented Interfaces:
DataWriterFactory<T>
- Direct Known Subclasses:
GenericBaseDataWriterFactory
,GenericDiskDataWriterFactory
Abstract implementation of a data writer factory. This class contains
a filename generation algorithm that simply generates a sequence of
filenames using a numeric counter and prefix/suffix strings.
Subclasses may override the filename generation. Subclasses must also provide an implementation that, given a filename, creates an output stream for it.
- Version:
- 2.15
- Author:
- Nicklas
- Last modified
- $Date: 2019-05-21 13:37:09 +0200 (tis, 21 maj 2019) $
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractDataWriterFactory
(FilenameGenerator<T> filenameGenerator) Create a new factory that uses the given file name generator. -
Method Summary
Modifier and TypeMethodDescriptioncreateDataWriter
(T owner, String suggestedFilename) Create a data writer for writing data that belongs to the given owner.protected abstract OutputStream
getOutputStream
(String filename) Create an output stream for writing to a file with the given filename.protected boolean
Checks if the suggested file name has already been used by this data writer factory or not.
-
Field Details
-
usedFiles
-
filenameGenerator
-
-
Constructor Details
-
AbstractDataWriterFactory
Create a new factory that uses the given file name generator.
-
-
Method Details
-
createDataWriter
Description copied from interface:DataWriterFactory
Create a data writer for writing data that belongs to the given owner. The owner is typically a bioassay (serial bfs format) or a spot data field (matrix bfs format). The returned writer should usually have it's filename (DataWriter.getFilename()
) and number of columns (DataWriter.getColumnCount()
) set, since this is needed for the metadata generation.- Specified by:
createDataWriter
in interfaceDataWriterFactory<T>
- Parameters:
owner
- The object that "owns" the data that is written to the filesuggestedFilename
- An optional suggested filename, the factory may use this string or generate a different filename- Returns:
- A data writer object with the filename and number of colums set (unless otherwise specified)
- Throws:
IOException
-
getOutputStream
Create an output stream for writing to a file with the given filename. The returned output stream will be wrapped in a writer that uses the UTF-8 character set.- Throws:
IOException
- If there is a problem creating the file
-
isUnique
Checks if the suggested file name has already been used by this data writer factory or not.- Parameters:
filename
- The filename to check- Returns:
- TRUE if the name is unique or FALSE if it has already been used
-