Package org.forgerock.audit.retention
Class TimeStampFileNamingPolicy
- java.lang.Object
-
- org.forgerock.audit.retention.TimeStampFileNamingPolicy
-
- All Implemented Interfaces:
FileNamingPolicy
public class TimeStampFileNamingPolicy extends Object implements FileNamingPolicy
Creates a time stamp based file naming policy. Rotated files are renamed with a given prefix and a timestamp suffix.
-
-
Constructor Summary
Constructors Constructor Description TimeStampFileNamingPolicy(File initialFile, String timeStampFormat, String prefix)
Constructs a TimeStampFileNaming policy with a given initial file, a timestamp format, and a prefix string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description File
getInitialName()
Gets the initial file.File
getNextName()
Gets the next name for thisFileNamingPolicy
.List<File>
listFiles()
List the files in the initial file directory that match the prefix, name and suffix format.
-
-
-
Constructor Detail
-
TimeStampFileNamingPolicy
public TimeStampFileNamingPolicy(File initialFile, String timeStampFormat, String prefix)
Constructs a TimeStampFileNaming policy with a given initial file, a timestamp format, and a prefix string.- Parameters:
initialFile
- The initial file that will be archived.timeStampFormat
- The timestamp format to append to the archived files. Should be a format that is understood byDateTimeFormatter
.prefix
- The prefix to prefix to the archived files.
-
-
Method Detail
-
getInitialName
public File getInitialName()
Gets the initial file.- Specified by:
getInitialName
in interfaceFileNamingPolicy
- Returns:
- The initial file.
-
getNextName
public File getNextName()
Gets the next name for thisFileNamingPolicy
. The next name will be formatted with prefix first, then the initial filename and finally the timestamp will be appended.- Specified by:
getNextName
in interfaceFileNamingPolicy
- Returns:
- The next archived file according to this
FileNamingPolicy
.
-
listFiles
public List<File> listFiles()
List the files in the initial file directory that match the prefix, name and suffix format. Lists all the archived files, from oldest to newest.- Specified by:
listFiles
in interfaceFileNamingPolicy
- Returns:
- Not-null, All the archived files.
-
-