Class AbstractBackupStrategy
- java.lang.Object
-
- com.elvishew.xlog.printer.file.backup.AbstractBackupStrategy
-
- All Implemented Interfaces:
BackupStrategy,BackupStrategy2
- Direct Known Subclasses:
FileSizeBackupStrategy2
public abstract class AbstractBackupStrategy extends java.lang.Object implements BackupStrategy2
An abstractBackupStrategy2, simply append '.bak.n' to the end of normal file name when naming a backup with index n.Developers can simply extend this class when defining their own
BackupStrategy2.- Since:
- 1.9.0
-
-
Field Summary
-
Fields inherited from interface com.elvishew.xlog.printer.file.backup.BackupStrategy2
NO_LIMIT
-
-
Constructor Summary
Constructors Constructor Description AbstractBackupStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetBackupFileName(java.lang.String fileName, int backupIndex)Get the backup file name for specific index.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.elvishew.xlog.printer.file.backup.BackupStrategy
shouldBackup
-
Methods inherited from interface com.elvishew.xlog.printer.file.backup.BackupStrategy2
getMaxBackupIndex
-
-
-
-
Method Detail
-
getBackupFileName
public java.lang.String getBackupFileName(java.lang.String fileName, int backupIndex)Description copied from interface:BackupStrategy2Get the backup file name for specific index.Generally, a backup file with normal file name 'log' and index 'n' could simply be 'log.bak.n', you can specify your own naming rules, by overriding this method.
Make sure to return different backup file name with different backup index, and same backup file name with same index. Otherwise, it will lead to unexpected behavior.
- Specified by:
getBackupFileNamein interfaceBackupStrategy2- Parameters:
fileName- the normal file name, generated byFileNameGenerator.generateFileName(int, long)backupIndex- the backup index, which will increase from 1 toBackupStrategy2.getMaxBackupIndex()- Returns:
- the backup file name
-
-