org.apache.commons.vfs.impl
Class DefaultFileReplicator

java.lang.Object
  extended byorg.apache.commons.vfs.provider.AbstractVfsComponent
      extended byorg.apache.commons.vfs.impl.DefaultFileReplicator
All Implemented Interfaces:
FileReplicator, TemporaryFileStore, VfsComponent

public final class DefaultFileReplicator
extends AbstractVfsComponent
implements FileReplicator, TemporaryFileStore

A simple file replicator and temporary file store.

Version:
$Revision: 192990 $ $Date: 2005-06-22 21:59:43 +0200 (Wed, 22 Jun 2005) $
Author:
Adam Murdoch

Constructor Summary
DefaultFileReplicator()
           
DefaultFileReplicator(File tempDir)
          constructor to set the location of the temporary directory
 
Method Summary
 File allocateFile(String baseName)
          Allocates a new temporary file.
 void close()
          Closes the replicator, deleting all temporary files.
protected  File createFile(File parent, String name)
          create the temporary file
protected  String createFilename(String baseName)
          create the temporary file name
protected  long getFilecount()
           
 void init()
          Initialises this component.
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFileReplicator

public DefaultFileReplicator(File tempDir)
constructor to set the location of the temporary directory

Parameters:
tempDir -

DefaultFileReplicator

public DefaultFileReplicator()
Method Detail

init

public void init()
          throws FileSystemException
Initialises this component.

Specified by:
init in interface VfsComponent
Overrides:
init in class AbstractVfsComponent
Throws:
FileSystemException

close

public void close()
Closes the replicator, deleting all temporary files.

Specified by:
close in interface VfsComponent
Overrides:
close in class AbstractVfsComponent

allocateFile

public File allocateFile(String baseName)
                  throws FileSystemException
Allocates a new temporary file.

Specified by:
allocateFile in interface TemporaryFileStore
Parameters:
baseName - The name of the file.
Throws:
FileSystemException

getFilecount

protected long getFilecount()

createFilename

protected String createFilename(String baseName)
create the temporary file name


createFile

protected File createFile(File parent,
                          String name)
                   throws FileSystemException
create the temporary file

Throws:
FileSystemException

replicateFile

public File replicateFile(FileObject srcFile,
                          FileSelector selector)
                   throws FileSystemException
Creates a local copy of the file, and all its descendents.

Specified by:
replicateFile in interface FileReplicator
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.


Copyright © 2002-2005 The Apache Software Foundation. All Rights Reserved.