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 Details

    • 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 by DateTimeFormatter.
      prefix - The prefix to prefix to the archived files.
  • Method Details

    • getInitialName

      public File getInitialName()
      Gets the initial file.
      Specified by:
      getInitialName in interface FileNamingPolicy
      Returns:
      The initial file.
    • getNextName

      public File getNextName()
      Gets the next name for this FileNamingPolicy. The next name will be formatted with prefix first, then the initial filename and finally the timestamp will be appended.
      Specified by:
      getNextName in interface FileNamingPolicy
      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 interface FileNamingPolicy
      Returns:
      Not-null, All the archived files.