public class MultiFileTransferMonitor extends java.lang.Object implements java.lang.Runnable, FileTransferMonitor
Constructor and Description |
---|
MultiFileTransferMonitor() |
Modifier and Type | Method and Description |
---|---|
boolean |
addFile(org.apache.commons.vfs2.FileObject dest,
org.apache.commons.vfs2.FileObject source)
Adds a file to be monitored.
|
boolean |
addFile(org.apache.commons.vfs2.FileObject dest,
org.apache.commons.vfs2.FileObject source,
long size,
java.lang.String displayName)
Adds a file to be monitored.
|
boolean |
addFile(org.apache.commons.vfs2.FileObject dest,
long size)
Adds a file to be monitored.
|
void |
addListener(FileTransferListener listener)
Adds a listener object to respond to transfer events
|
void |
fireCompleteEvent(org.apache.commons.vfs2.FileObject dest)
Convenience function for firing a "complete" event for the transfer
|
void |
fireEvent(FileTransferEvent event)
Fires an event to all listeners
|
void |
fireStartEvent(org.apache.commons.vfs2.FileObject dest)
Convenience function for firing a "start" event for the transfer
|
int |
getChecksPerRun()
get the number of files to check per run.
|
FileTransferListener[] |
getListeners()
Access method to get the current FileListener object notified when there
are changes with the files added.
|
long |
getPollSleep()
Get the delay between runs.
|
void |
monitor(org.apache.commons.vfs2.FileObject destFile,
org.apache.commons.vfs2.FileObject srcFile)
Informs this monitor object to monitor a file transfer.
|
void |
monitor(org.apache.commons.vfs2.FileObject destFile,
org.apache.commons.vfs2.FileObject srcFile,
long size) |
void |
monitor(org.apache.commons.vfs2.FileObject destFile,
org.apache.commons.vfs2.FileObject srcFile,
long size,
java.lang.String displayName)
Informs this monitor object to monitor a file transfer.
|
void |
monitor(org.apache.commons.vfs2.FileObject destFile,
long size)
Informs this monitor object to monitor a file transfer.
|
void |
release(org.apache.commons.vfs2.FileObject file)
Removes a file from being monitored.
|
void |
removeListener(FileTransferListener listener)
Removes a listener object
|
void |
run()
Asks the agent for each file being monitored to check its file for
changes.
|
void |
setChecksPerRun(int checksPerRun)
set the number of files to check per run.
|
void |
setPollSleep(long delay)
Set the delay between runs.
|
void |
start()
Starts monitoring the files that have been added.
|
void |
stop()
Stops monitoring the files that have been added.
|
public FileTransferListener[] getListeners()
getListeners
in interface FileTransferMonitor
public boolean addFile(org.apache.commons.vfs2.FileObject dest, org.apache.commons.vfs2.FileObject source)
dest
- The destination file to monitorsource
- The source, from which transfer size is computedpublic boolean addFile(org.apache.commons.vfs2.FileObject dest, long size)
dest
- The destination file to monitorsize
- The total transfer size (size of source)public boolean addFile(org.apache.commons.vfs2.FileObject dest, org.apache.commons.vfs2.FileObject source, long size, java.lang.String displayName)
dest
- The destination file to monitorsource
- The sourcesize
- The total transfer size (size of source)displayName
- The name of the file associated with this file transfer (may be different from destination)public void release(org.apache.commons.vfs2.FileObject file)
release
in interface FileTransferMonitor
file
- The FileObject to remove from monitoring.public long getPollSleep()
getPollSleep
in interface FileTransferMonitor
public void setPollSleep(long delay)
setPollSleep
in interface FileTransferMonitor
delay
- The delay period.public int getChecksPerRun()
public void setChecksPerRun(int checksPerRun)
checksPerRun
- a value less than 1 will disable this featurepublic void start()
start
in interface FileTransferMonitor
public void stop()
stop
in interface FileTransferMonitor
public void run()
run
in interface java.lang.Runnable
public void fireEvent(FileTransferEvent event)
fireEvent
in interface FileTransferMonitor
public void fireStartEvent(org.apache.commons.vfs2.FileObject dest)
fireStartEvent
in interface FileTransferMonitor
dest
- The destination file for the transfer to uniquely
identify the FileTransferMonitorAgent responsible for firing eventspublic void fireCompleteEvent(org.apache.commons.vfs2.FileObject dest)
fireCompleteEvent
in interface FileTransferMonitor
dest
- The destination file for the transfer to uniquely
identify the FileTransferMonitorAgent responsible for firing eventspublic void monitor(org.apache.commons.vfs2.FileObject destFile, org.apache.commons.vfs2.FileObject srcFile)
FileTransferMonitor
monitor
in interface FileTransferMonitor
destFile
- transfer destinationsrcFile
- transfer sourceaddFile(FileObject, FileObject)
public void monitor(org.apache.commons.vfs2.FileObject destFile, org.apache.commons.vfs2.FileObject srcFile, long size)
public void monitor(org.apache.commons.vfs2.FileObject destFile, long size)
FileTransferMonitor
monitor
in interface FileTransferMonitor
destFile
- transfer destinationsize
- Total transfer sizeaddFile(FileObject, long)
public void monitor(org.apache.commons.vfs2.FileObject destFile, org.apache.commons.vfs2.FileObject srcFile, long size, java.lang.String displayName)
monitor
in interface FileTransferMonitor
destFile
- transfer destinationsrcFile
- transfer sourcesize
- the size of the source file (total transfer size). If < 0, then we determine
the transfer size from srcFiledisplayName
- the name associated with the transfer (may be different than
destFile if .part is used)public void addListener(FileTransferListener listener)
addListener
in interface FileTransferMonitor
listener
- listener to addpublic void removeListener(FileTransferListener listener)
removeListener
in interface FileTransferMonitor
listener
- listener to remove