maspack.fileutil
Class FileTransferEvent

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

public class FileTransferEvent
extends java.lang.Object

Transfer event containing information useful for monitoring file transfer progress.

Author:
"Antonio Sanchez" Creation date: 17 Nov 2012

Nested Class Summary
static class FileTransferEvent.Type
          Event types
 
Constructor Summary
FileTransferEvent(org.apache.commons.vfs2.FileObject source, org.apache.commons.vfs2.FileObject dest, FileTransferEvent.Type type, long sourceSize, long destSize, long destTime, java.lang.String displayName)
          Constructor, sets properties of event and automatically computes the event's time from the system clock.
 
Method Summary
 org.apache.commons.vfs2.FileObject getDestinationFile()
           
 long getDestinationSize()
           
 java.lang.String getDisplayName()
          Returns the display name.
 long getEventTime()
          Returns the system time in milliseconds that the event was created.
 double getProgress()
          Fractional progress, -1 if cannot be determined
 org.apache.commons.vfs2.FileObject getSourceFile()
           
 long getSourceSize()
           
 long getTransferTime()
           
 FileTransferEvent.Type getType()
           
 void notify(FileTransferListener listener)
          Fires the event to all listeners
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTransferEvent

public FileTransferEvent(org.apache.commons.vfs2.FileObject source,
                         org.apache.commons.vfs2.FileObject dest,
                         FileTransferEvent.Type type,
                         long sourceSize,
                         long destSize,
                         long destTime,
                         java.lang.String displayName)
Constructor, sets properties of event and automatically computes the event's time from the system clock.

Parameters:
source - The source file
dest - Transfer destination
type - Type of event
sourceSize - Size of file to transfer
destSize - Current size of the destination file
destTime - Current timestamp on the destination file
displayName - Can be used to display file, for example in case an intermediary file is used such as file.txt.part, you may want to display file.txt instead.
Method Detail

notify

public void notify(FileTransferListener listener)
Fires the event to all listeners

Parameters:
listener -

getSourceFile

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

getDestinationFile

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

getType

public FileTransferEvent.Type getType()
Returns:
the event type

getDestinationSize

public long getDestinationSize()
Returns:
the current size of the transfer

getSourceSize

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

getTransferTime

public long getTransferTime()
Returns:
the time of the event

getProgress

public double getProgress()
Fractional progress, -1 if cannot be determined

Returns:
size(dest)/size(source)

getEventTime

public long getEventTime()
Returns the system time in milliseconds that the event was created. Useful for determining transfer speed.

Returns:
time event was created

getDisplayName

public java.lang.String getDisplayName()
Returns the display name. This can be useful for specifying the final destination when an intermediate file is used. The transfer destination may be file.ext.part, but the final destination file.ext

Returns:
the display name