|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.javatest.util.BackupPolicy
public abstract class BackupPolicy
An abstract base class to provide a way of opening files subject to a policy of what to do if a file of the same name already exists.
Constructor Summary | |
---|---|
BackupPolicy()
|
Method Summary | |
---|---|
void |
backup(java.io.File file)
Backup a file by renaming it to have have a new name of old-name~n where n is chosen to be higher than any other for which a candidate new filename exists. |
java.io.OutputStream |
backupAndOpenStream(java.io.File file)
Backup a file and open a new output stream to the file. |
java.io.Writer |
backupAndOpenWriter(java.io.File file)
Backup a file and open a new Writer to the file. |
java.io.Writer |
backupAndOpenWriter(java.io.File file,
java.lang.String charsetName)
Backup a file and open a new Writer to the file with specified charset. |
void |
backupAndRename(java.io.File source,
java.io.File target)
Rename (or move) the source file to the target name. |
abstract int |
getNumBackupsToKeep(java.io.File file)
Get the number of backup files to keep for a particular file. |
abstract boolean |
isBackupRequired(java.io.File file)
Determine if backups are enabled for this file. |
static BackupPolicy |
noBackups()
Get a BackupPolicy object which does no backups for any files. |
static BackupPolicy |
simpleBackups(int n)
Get a BackupPolicy object which does a set number of backups for all files. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BackupPolicy()
Method Detail |
---|
public void backup(java.io.File file) throws java.io.IOException, java.lang.SecurityException
file
- the file to be backed up
java.io.IOException
- if there is a problem renaming the file
java.lang.SecurityException
- if the file could not be backed up because
permission was not given by the security managergetNumBackupsToKeep(java.io.File)
,
isBackupRequired(java.io.File)
public void backupAndRename(java.io.File source, java.io.File target) throws java.io.IOException, java.lang.SecurityException
source
- The file to be backed up.
It must be a file (not a directory) which is deleteable.target
- The new name for the file. It must be a file (not a directory)
which is will be at a writable location.
java.io.IOException
- if there is a problem renaming the file.
This may happen if the source is a
directory, the source file is not writable, or the rename operation
fails. In all cases, the rename operation was not successful.
java.lang.SecurityException
- if the backup operation fails because of a security
constraint.backup(File)
public java.io.Writer backupAndOpenWriter(java.io.File file) throws java.io.IOException, java.lang.SecurityException
file
- the file to be backed up, and for which a new Writer will be opened
java.io.IOException
- if there is a problem backing up the file or creating
the new writer object
java.lang.SecurityException
- if the operation could not be completed because
of a security constraintpublic java.io.Writer backupAndOpenWriter(java.io.File file, java.lang.String charsetName) throws java.io.IOException, java.lang.SecurityException
file
- the file to be backed up, and for which a new Writer will be openedcharsetName
- Create an OutputStreamWriter that uses the named charset
java.io.IOException
- if there is a problem backing up the file or creating
the new writer object
java.lang.SecurityException
- if the operation could not be completed because
of a security constraintpublic java.io.OutputStream backupAndOpenStream(java.io.File file) throws java.io.IOException, java.lang.SecurityException
file
- the file to be backed up, and for which a new output stream will be opened
java.io.IOException
- if there is a problem backing up the file or creating
the new output stream
java.lang.SecurityException
- if the operation could not be completed because
of a security constraintpublic abstract int getNumBackupsToKeep(java.io.File file)
file
- the file for which to check how many backups are required
backup(java.io.File)
public abstract boolean isBackupRequired(java.io.File file)
file
- the file for which to check if backups are enabled
public static BackupPolicy noBackups()
public static BackupPolicy simpleBackups(int n)
n
- The number of backups to kept for each file
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |