org.cip4.jdflib.util
Class BackupDirectory

java.lang.Object
  extended by java.io.File
      extended by org.cip4.jdflib.util.BackupDirectory
All Implemented Interfaces:
Serializable, Comparable<File>, IPersistable
Direct Known Subclasses:
RollingBackupDirectory

public class BackupDirectory
extends File
implements IPersistable

Author:
Dr. Rainer Prosi, Heidelberger Druckmaschinen AG class to manage a directory by removing the oldest files whenever a new file is created The oldest file dies when the maximum number is reached 08.12.2008
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
BackupDirectory(File file, int nBackupp)
           
BackupDirectory(String pathname, int nBackupp)
           
 
Method Summary
 File getNewFile(File localFile)
          creates a new file in this and assures than no more than nBackup files remain
 File getNewFile(String fileName)
           
 boolean persist()
          physically persist the whatever stuff
 String toString()
           
 
Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BackupDirectory

public BackupDirectory(String pathname,
                       int nBackupp)
Parameters:
pathname - the Directory
nBackupp - the number of backups to retain
Throws:
IllegalArgumentException - if file exists and is not a directory

BackupDirectory

public BackupDirectory(File file,
                       int nBackupp)
                throws IllegalArgumentException
Parameters:
file - the base file
nBackupp - the number of backups to retain
Throws:
IllegalArgumentException - if file exists and is not a directory
Method Detail

getNewFile

public File getNewFile(File localFile)
creates a new file in this and assures than no more than nBackup files remain

Parameters:
localFile - the local file to place in this directory
Returns:
the file to write, null if an io exception occurred when creating it

getNewFile

public File getNewFile(String fileName)
Parameters:
fileName -
Returns:

toString

public String toString()
Overrides:
toString in class File
See Also:
File.toString()

persist

public boolean persist()
Description copied from interface: IPersistable
physically persist the whatever stuff

Specified by:
persist in interface IPersistable
Returns:
true if persist was successful
See Also:
IPersistable.persist()


Copyright © 2013. All Rights Reserved.