com.gubutech.xload
Class XloadIncrementalFileRename

java.lang.Object
  extended bycom.gubutech.xload.XloadIncrementalFileRename
All Implemented Interfaces:
XloadFileRename

public class XloadIncrementalFileRename
extends java.lang.Object
implements XloadFileRename

The default file renaming policy for Xload. Implements a renaming policy whereby an attempt to create a file is made without any renaming and if a name collision occurs then renaming is implemented by appending a numeral that increments sequentially by 1 in parenthesis to the body of the file name (file extensions are preserved).

Since:
1.0

Constructor Summary
XloadIncrementalFileRename()
           
 
Method Summary
 java.io.File rename(java.io.File file)
          Performs the actual rename of the file if required.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XloadIncrementalFileRename

public XloadIncrementalFileRename()
Method Detail

rename

public java.io.File rename(java.io.File file)
Performs the actual rename of the file if required. This method will initially attempt to create an empty file on disk safely as a marker using the file argument. The file name will be the remoteName of the file before the upload(see XloadFile for a more detailed explanation of remote name) and some target directory. This is then used to write the actual bytes of data to. If Xload cannot create the empty marker file due to a file name collision then a renamed file name is used by appending a numeral that increments sequentially by 1 in parenthesis to the body of the file name (file extensions are preserved). The process is repeated until a marker file is created. e.g.

original file name - filename.txt
renamed to - filename(1).txt

Specified by:
rename in interface XloadFileRename
Parameters:
file - Initial file object that will be created and renamed if required.
Returns:
Returns the actual created file on the file system after potential renaming has taken place.
Throws:
java.lang.SecurityException - Thrown if there is a problem accessing files on the file system with regard to permissions set by the SecurityManager.
Since:
1.0