Package net.sf.basedb.util.bfs
Class SequenceFilenameGenerator
java.lang.Object
net.sf.basedb.util.bfs.SequenceFilenameGenerator
- All Implemented Interfaces:
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
-
Constructor Summary
ConstructorDescriptionCreate a new sequence file name generator.SequenceFilenameGenerator
(String prefix, String suffix, int firstFileNum) Create a new sequence file name generator. -
Method Summary
Modifier and TypeMethodDescriptiongetNextFilename
(Object owner, String suggestedFilename) Get the next file name.int
Get the next file number.Get the prefix that is used for file name generation.Get the suffix that is used for file name generation.void
Set the prefix that is used for file name generation.void
Set the suffix that is used for file name generation.
-
Field Details
-
prefix
-
suffix
-
nextFileNum
private int nextFileNum
-
-
Constructor Details
-
SequenceFilenameGenerator
public SequenceFilenameGenerator()Create a new sequence file name generator. No prefix or suffix are used and the sequence starts at 1. -
SequenceFilenameGenerator
Create a new sequence file name generator.- Parameters:
prefix
- The prefix to usesuffix
- The suffix to usefirstFileNum
- The sequence number of the first file
-
-
Method Details
-
getNextFilename
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
Get the prefix that is used for file name generation.- Returns:
- The prefix or null if no prefix was given
-
setPrefix
Set the prefix that is used for file name generation.- Parameters:
prefix
- The prefix or null to not use a prefix
-
getSuffix
Get the suffix that is used for file name generation.- Returns:
- The suffix or null if no suffix was given
-
setSuffix
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.
-