maspack.fileutil
Class FileTransferMonitorAgent

java.lang.Object
  extended by maspack.fileutil.FileTransferMonitorAgent

public class FileTransferMonitorAgent
extends java.lang.Object

Monitors a particular file transfer

Author:
"Antonio Sanchez" Creation date: 17 Nov 2012 Modified from org.apache.commons.vfs2.impl.DefaultFileMonitor.FileMonitorAgent Detects changes to a single file, triggering events when the destination file has either changed size or modification time. This is always associated with a single FileTransferMonitor.

Constructor Summary
FileTransferMonitorAgent(FileTransferMonitor fm, org.apache.commons.vfs2.FileObject dest)
           
FileTransferMonitorAgent(FileTransferMonitor fm, org.apache.commons.vfs2.FileObject dest, org.apache.commons.vfs2.FileObject source, long sourceSize, java.lang.String displayName)
          Main constructor
FileTransferMonitorAgent(FileTransferMonitor fm, org.apache.commons.vfs2.FileObject dest, org.apache.commons.vfs2.FileObject source, java.lang.String displayName)
           
FileTransferMonitorAgent(FileTransferMonitor fm, org.apache.commons.vfs2.FileObject dest, long sourceSize)
           
FileTransferMonitorAgent(FileTransferMonitor fm, org.apache.commons.vfs2.FileObject dest, long sourceSize, java.lang.String displayName)
           
 
Method Summary
 void check()
          Refreshes the destination file, checking if the file has changed and fires an event if either the size or modification time is different.
 void fireComplete()
          Fires a transfer complete event
 void fireStart()
          Fires a "start" event for this transfer to all listeners in the associated FileTransferMonitor.
 void fireUpdate()
          Fires on update event
 org.apache.commons.vfs2.FileObject getDestinationFile()
           
 long getLastTimestamp()
           
 FileTransferMonitor getMonitor()
           
 org.apache.commons.vfs2.FileObject getSourceFile()
           
 long getSourceSize()
           
 long getTransferedSize()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTransferMonitorAgent

public FileTransferMonitorAgent(FileTransferMonitor fm,
                                org.apache.commons.vfs2.FileObject dest,
                                org.apache.commons.vfs2.FileObject source,
                                long sourceSize,
                                java.lang.String displayName)
Main constructor

Parameters:
fm - associated FileTransferMonitor
dest - transfer destination
source - transfer source
sourceSize - total size of transfer (size of source). Provided for cases when source size cannot be determined due to the file system type
displayName - the file name associated with the transfer (may be different from dest.fileName)

FileTransferMonitorAgent

public FileTransferMonitorAgent(FileTransferMonitor fm,
                                org.apache.commons.vfs2.FileObject dest,
                                org.apache.commons.vfs2.FileObject source,
                                java.lang.String displayName)
Parameters:
fm - FileTransferMonitor associated with this agent
dest - Transfer destination
source - Transfer source
displayName - Name associated with file transfer

FileTransferMonitorAgent

public FileTransferMonitorAgent(FileTransferMonitor fm,
                                org.apache.commons.vfs2.FileObject dest,
                                long sourceSize,
                                java.lang.String displayName)
Parameters:
fm - Associated FileTransferMonitor
dest - transfer destination
sourceSize - transfer size
displayName - name associated with transfer

FileTransferMonitorAgent

public FileTransferMonitorAgent(FileTransferMonitor fm,
                                org.apache.commons.vfs2.FileObject dest,
                                long sourceSize)
Parameters:
fm - Associated FileTransferMonitor
dest - transfer destination
sourceSize - transfer size

FileTransferMonitorAgent

public FileTransferMonitorAgent(FileTransferMonitor fm,
                                org.apache.commons.vfs2.FileObject dest)
Parameters:
fm - Associated FileTransferMonitor
dest - transfer destination
Method Detail

check

public void check()
Refreshes the destination file, checking if the file has changed and fires an event if either the size or modification time is different.


fireStart

public void fireStart()
Fires a "start" event for this transfer to all listeners in the associated FileTransferMonitor.


fireUpdate

public void fireUpdate()
Fires on update event


fireComplete

public void fireComplete()
Fires a transfer complete event


getDestinationFile

public org.apache.commons.vfs2.FileObject getDestinationFile()
Returns:
the transfer destination file

getSourceFile

public org.apache.commons.vfs2.FileObject getSourceFile()
Returns:
the transfer source file

getMonitor

public FileTransferMonitor getMonitor()
Returns:
the associated FileTransferMonitor

getLastTimestamp

public long getLastTimestamp()
Returns:
the timestamp of the destination file at last check

getTransferedSize

public long getTransferedSize()
Returns:
the size of the destination file at last check

getSourceSize

public long getSourceSize()
Returns:
the total size of the source file