Class DefaultFileReplicator
java.lang.Object
org.apache.commons.vfs2.provider.AbstractVfsComponent
org.apache.commons.vfs2.impl.DefaultFileReplicator
- All Implemented Interfaces:
Closeable, AutoCloseable, FileReplicator, TemporaryFileStore, VfsComponent
public class DefaultFileReplicator
extends AbstractVfsComponent
implements FileReplicator, TemporaryFileStore
A simple file replicator and temporary file store.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultFileReplicator(File tempDir) Constructor to set the location of the temporary directory. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidallocateFile(String baseName) Allocates a new temporary file.voidclose()Closes the replicator, deleting all temporary files.protected FilecreateAndAddFile(File parent, String basename) protected FilecreateFile(File parent, String name) Create the temporary file.protected StringcreateFilename(String baseName) Create the temporary file name.protected voiddeleteFile(File file) Physically deletes the file from the file system.protected longvoidinit()Initializes this component.protected ObjectRemoves a file from the copies list.protected voidremoveFile(Object file) Removes a instance from the list of copies.replicateFile(FileObject srcFile, FileSelector selector) Creates a local copy of the file, and all its descendants.Methods inherited from class AbstractVfsComponent
getContext, getLogger, setContext, setLogger
-
Field Details
-
log
private static final org.apache.commons.logging.Log log -
MASK
private static final int MASK- See Also:
-
random
-
TMP_RESERVED_CHARS
private static final char[] TMP_RESERVED_CHARS -
copies
-
filecount
private long filecount -
tempDir
-
tempDirMessageLogged
private boolean tempDirMessageLogged
-
-
Constructor Details
-
DefaultFileReplicator
public DefaultFileReplicator() -
DefaultFileReplicator
Constructor to set the location of the temporary directory.- Parameters:
tempDir- The temporary directory.
-
-
Method Details
-
addFile
-
allocateFile
Allocates a new temporary file.- Specified by:
allocateFilein interfaceTemporaryFileStore- Parameters:
baseName- the base file name.- Returns:
- The created File.
- Throws:
FileSystemException- if an error occurs.
-
close
public void close()Closes the replicator, deleting all temporary files.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceVfsComponent- Overrides:
closein classAbstractVfsComponent
-
createAndAddFile
- Throws:
FileSystemException
-
createFile
Create the temporary file.- Parameters:
parent- The file to use as the parent of the file being created.name- The name of the file to create.- Returns:
- The File that was created.
- Throws:
FileSystemException- if an error occurs creating the file.
-
createFilename
-
deleteFile
Physically deletes the file from the file system.- Parameters:
file- The File to delete.
-
getFilecount
protected long getFilecount() -
init
Initializes this component.- Specified by:
initin interfaceVfsComponent- Overrides:
initin classAbstractVfsComponent- Throws:
FileSystemException- if an error occurs.
-
removeFile
-
removeFile
Removes a instance from the list of copies.- Parameters:
file- The File to remove.
-
replicateFile
Creates a local copy of the file, and all its descendants.- Specified by:
replicateFilein interfaceFileReplicator- Parameters:
srcFile- The file to copy.selector- The FileSelector.- Returns:
- the created File.
- Throws:
FileSystemException- if an error occurs copying the file.
-