|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.bfs.AbstractDataWriterFactory<T>
public abstract class AbstractDataWriterFactory<T>
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.
Field Summary | |
---|---|
private FilenameGenerator<T> |
filenameGenerator
|
private Set<String> |
usedFiles
|
Constructor Summary | |
---|---|
protected |
AbstractDataWriterFactory(FilenameGenerator<T> filenameGenerator)
Create a new factory that uses the given file name generator. |
Method Summary | |
---|---|
DataWriter |
createDataWriter(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 |
isUnique(String filename)
Checks if the suggested file name has already been used by this data writer factory or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Set<String> usedFiles
private FilenameGenerator<T> filenameGenerator
Constructor Detail |
---|
protected AbstractDataWriterFactory(FilenameGenerator<T> filenameGenerator)
Method Detail |
---|
public DataWriter createDataWriter(T owner, String suggestedFilename) throws IOException
DataWriterFactory
DataWriter.getFilename()
) and
number of columns (DataWriter.getColumnCount()
) set, since this
is needed for the metadata generation.
createDataWriter
in interface DataWriterFactory<T>
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
IOException
protected abstract OutputStream getOutputStream(String filename) throws IOException
IOException
- If there is a problem creating the fileprotected boolean isUnique(String filename)
filename
- The filename to check
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |