Package org.apache.commons.vfs.impl
Class DefaultFileReplicator
- java.lang.Object
-
- org.apache.commons.vfs.provider.AbstractVfsComponent
-
- org.apache.commons.vfs.impl.DefaultFileReplicator
-
- All Implemented Interfaces:
FileReplicator
,TemporaryFileStore
,VfsComponent
public class DefaultFileReplicator extends AbstractVfsComponent implements FileReplicator, TemporaryFileStore
A simple file replicator and temporary file store.- Version:
- $Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Wed, 29 Nov 2006) $
- Author:
- Adam Murdoch
-
-
Constructor Summary
Constructors Constructor Description DefaultFileReplicator()
DefaultFileReplicator(java.io.File tempDir)
constructor to set the location of the temporary directory
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addFile(java.lang.Object file)
java.io.File
allocateFile(java.lang.String baseName)
Allocates a new temporary file.void
close()
Closes the replicator, deleting all temporary files.protected java.io.File
createAndAddFile(java.io.File parent, java.lang.String basename)
protected java.io.File
createFile(java.io.File parent, java.lang.String name)
create the temporary fileprotected java.lang.String
createFilename(java.lang.String baseName)
create the temporary file nameprotected void
deleteFile(java.io.File file)
physically deletes the file from the filesystemprotected long
getFilecount()
void
init()
Initialises this component.protected java.lang.Object
removeFile()
removes a file from the copies list.protected void
removeFile(java.lang.Object file)
removes a instance from the list of copiesjava.io.File
replicateFile(FileObject srcFile, FileSelector selector)
Creates a local copy of the file, and all its descendents.-
Methods inherited from class org.apache.commons.vfs.provider.AbstractVfsComponent
getContext, getLogger, setContext, setLogger
-
-
-
-
Method Detail
-
init
public void init() throws FileSystemException
Initialises this component.- Specified by:
init
in interfaceVfsComponent
- Overrides:
init
in classAbstractVfsComponent
- Throws:
FileSystemException
-
close
public void close()
Closes the replicator, deleting all temporary files.- Specified by:
close
in interfaceVfsComponent
- Overrides:
close
in classAbstractVfsComponent
-
deleteFile
protected void deleteFile(java.io.File file)
physically deletes the file from the filesystem
-
removeFile
protected java.lang.Object removeFile()
removes a file from the copies list. Will be used for cleanup.
Notice: The system awaits that the returning object can be cast to a java.io.File
-
removeFile
protected void removeFile(java.lang.Object file)
removes a instance from the list of copies
-
allocateFile
public java.io.File allocateFile(java.lang.String baseName) throws FileSystemException
Allocates a new temporary file.- Specified by:
allocateFile
in interfaceTemporaryFileStore
- Parameters:
baseName
- The name of the file.- Throws:
FileSystemException
-
createAndAddFile
protected java.io.File createAndAddFile(java.io.File parent, java.lang.String basename) throws FileSystemException
- Throws:
FileSystemException
-
addFile
protected void addFile(java.lang.Object file)
-
getFilecount
protected long getFilecount()
-
createFilename
protected java.lang.String createFilename(java.lang.String baseName)
create the temporary file name
-
createFile
protected java.io.File createFile(java.io.File parent, java.lang.String name) throws FileSystemException
create the temporary file- Throws:
FileSystemException
-
replicateFile
public java.io.File replicateFile(FileObject srcFile, FileSelector selector) throws FileSystemException
Creates a local copy of the file, and all its descendents.- Specified by:
replicateFile
in interfaceFileReplicator
- Parameters:
srcFile
- The file to copy.selector
- Selects the files to copy.- Returns:
- The local copy of the source file.
- Throws:
FileSystemException
- If the source files does not exist, or on error copying.
-
-