Package net.sf.basedb.util.bfs
Class SequenceFilenameGenerator
- java.lang.Object
-
- net.sf.basedb.util.bfs.SequenceFilenameGenerator
-
- All Implemented Interfaces:
FilenameGenerator<Object>
public class SequenceFilenameGenerator extends Object implements FilenameGenerator<Object>
File name generator implementation that generates file names using a simple numerical counter. It is possible to give a prexix and/or suffix. For example, with prefix="file-" and suffix=".txt", the following file sequence is generated: file-1.txt, file-2.txt, file-3.txt This generator completely ignores the owner and suggested file names.- Version:
- 2.15
- Author:
- Nicklas
- Last modified
- $Date: 2010-01-12 14:21:49 +0100 (ti, 12 jan 2010) $
-
-
Field Summary
Fields Modifier and Type Field Description private int
nextFileNum
private String
prefix
private String
suffix
-
Constructor Summary
Constructors Constructor Description SequenceFilenameGenerator()
Create a new sequence file name generator.SequenceFilenameGenerator(String prefix, String suffix, int firstFileNum)
Create a new sequence file name generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getNextFilename(Object owner, String suggestedFilename)
Get the next file name.int
getNextFileNumber()
Get the next file number.String
getPrefix()
Get the prefix that is used for file name generation.String
getSuffix()
Get the suffix that is used for file name generation.void
setPrefix(String prefix)
Set the prefix that is used for file name generation.void
setSuffix(String suffix)
Set the suffix that is used for file name generation.
-
-
-
Method Detail
-
getNextFilename
public String getNextFilename(Object owner, String suggestedFilename)
Description copied from interface:FilenameGenerator
Get the next file name. This method should never return the same file name more than one time (given a single implementor instance). The generator implementation should not concern itself with the underlying file system or if the file already exists or not (this is a task for theDataWriterFactory
implementation).- Specified by:
getNextFilename
in interfaceFilenameGenerator<Object>
- Parameters:
owner
- The owner of the data in the filesuggestedFilename
- A default suggested file name (can be null)- Returns:
- A unique file name
-
getPrefix
public String getPrefix()
Get the prefix that is used for file name generation.- Returns:
- The prefix or null if no prefix was given
-
setPrefix
public void setPrefix(String prefix)
Set the prefix that is used for file name generation.- Parameters:
prefix
- The prefix or null to not use a prefix
-
getSuffix
public String getSuffix()
Get the suffix that is used for file name generation.- Returns:
- The suffix or null if no suffix was given
-
setSuffix
public void setSuffix(String suffix)
Set the suffix that is used for file name generation.- Parameters:
suffix
- The suffix or null to not use a suffix
-
getNextFileNumber
public int getNextFileNumber()
Get the next file number. This counter is increased for each file that is generated (eg. each timegetNextFilename(Object, String)
is called.
-
-