Package org.apache.commons.vfs2.impl
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.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a new instance.DefaultFileReplicator(File tempDir) Constructor to set the location of the temporary directory.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidAdds a file.allocateFile(String baseName) Allocates a new temporary file.voidclose()Closes the replicator, deleting all temporary files.protected FilecreateAndAddFile(File parent, String baseName) Adds a file.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 longGets the file count.voidinit()Initializes this component.protected ObjectRemoves a file from the copies list.protected voidremoveFile(Object file) Removes an 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 org.apache.commons.vfs2.provider.AbstractVfsComponentgetContext, getLogger, setContext, setLogger
- 
Constructor Details- 
DefaultFileReplicatorpublic DefaultFileReplicator()Constructs a new instance.
- 
DefaultFileReplicatorConstructor to set the location of the temporary directory.- Parameters:
- tempDir- The temporary directory.
 
 
- 
- 
Method Details- 
addFileAdds a file.- Parameters:
- file- the file to add.
 
- 
allocateFileAllocates a new temporary file.- Specified by:
- allocateFilein interface- TemporaryFileStore
- Parameters:
- baseName- the base file name.
- Returns:
- The created File.
- Throws:
- FileSystemException- if an error occurs.
 
- 
closeCloses the replicator, deleting all temporary files.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- VfsComponent
- Overrides:
- closein class- AbstractVfsComponent
 
- 
createAndAddFileAdds a file.- Parameters:
- parent- ignored.
- baseName- the base file name.
- Returns:
- a File.
- Throws:
- FileSystemException- if a file system error occurs.
 
- 
createFileCreate 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.
 
- 
createFilenameCreate the temporary file name.- Parameters:
- baseName- The base to prepend to the file name being created.
- Returns:
- the name of the File.
 
- 
deleteFilePhysically deletes the file from the file system.- Parameters:
- file- The File to delete.
 
- 
getFilecountGets the file count.- Returns:
- the file count.
 
- 
initInitializes this component.- Specified by:
- initin interface- VfsComponent
- Overrides:
- initin class- AbstractVfsComponent
- Throws:
- FileSystemException- if an error occurs.
 
- 
removeFileRemoves a file from the copies list. Will be used for cleanup.Notice: The system awaits that the returning object can be cast to a File.- Returns:
- the File that was removed.
 
- 
removeFileRemoves an instance from the list of copies.- Parameters:
- file- The File to remove.
 
- 
replicateFileCreates a local copy of the file, and all its descendants.- Specified by:
- replicateFilein interface- FileReplicator
- Parameters:
- srcFile- The file to copy.
- selector- The FileSelector.
- Returns:
- the created File.
- Throws:
- FileSystemException- if an error occurs copying the file.
 
 
-