org.jurvis.util
Class JvDataTransferModel

java.lang.Object
  extended by org.jurvis.util.JvDataTransferModel

public class JvDataTransferModel
extends Object

A model class that contains information about a data transfer taking place between the client and server or vice versa.

Author:
Neil W. Weber

Field Summary
static int CANCELLED
          Enumerated value indicating the transfer was cancelled by the user.
static int COMPLETED
          Enumerated value indicating the transfer has completed successfully.
static int COPY
          Enumerated value indicating the transfer is a copy.
static int DOWNLOAD
          Enumerated value indicating the transfer is a download.
static int FAILED
          Enumerated value indicating the transfer failed.
static int INPROGRESS
          Enumerated value indicating the transfer is in progress.
protected  EventListenerList listenerList
          List of listeners
static int PENDING
          Enumerated value indicating the transfer is pending (i.e.
static int UPLOAD
          Enumerated value indicating the transfer is an upload.
 
Constructor Summary
JvDataTransferModel(int direction)
          Construct a new JvDataTransferModel.
 
Method Summary
 void addBytesTransferred(int amount)
          Adjust the number of bytes transferred so far.
 void addDataTransferModelListener(JvDataTransferModelListener l)
          Adds a listener to the list that is notified each time a change to the data model occurs.
 void addSecondsElapsed(int amount)
          Adjust the number of seconds elapsed so far.
 boolean cancelRequested()
          Determine if a request has been made to cancel the transfer.
 void fireModelChanged()
          Notify all listeners that this model has changed.
 void fireModelChanged(EventObject e)
          Notify all listeners that this model has changed.
 int getBytesRemaining()
          Return the number of bytes remaining to transfer.
 int getBytesTransferred()
          Return the number of bytes transferred so far.
 String getDestination()
          Return the destination of the file being transferred.
 int getDirection()
          Return the direction of the transfer.
 Exception getException()
          Return the Exception of the downloaded exception.
 File getFile()
          Return the File of the downloaded file.
 String getName()
          Return the name of the file being transferred.
 int getSecondsElapsed()
          Return the number of seconds elapsed so far.
 int getSecondsRemaining()
          Return the estimated number of seconds remaining until completion.
 String getSource()
          Return the source of the file being transferred.
 int getState()
          Return the current state of the transfer.
 int getTotalBytes()
          Return the total number of bytes that will be transferred.
 int getTransferRate()
          Return the latest transfer rate expressed as bytes per second.
 void removeDataTransferModelListener(JvDataTransferModelListener l)
          Removes a listener from the list that is notified each time a change to the data model occurs.
 void requestCancellation()
          Request the cancellation of the transfer.
 void setBytesTransferred(int bytesTransferred)
          Set the number of bytes transferred so far.
 void setDestination(String destination)
          Set the destination of the file being transferred.
 void setDirection(int direction)
          Set the current direction of the transfer.
 void setException(Exception exception)
          Set the Exception of the downloaded exception.
 void setFile(File file)
          Set the File of the downloaded file.
 void setName(String name)
          Set the name of the file being transferred.
 void setSecondsElapsed(int secondsElapsed)
          Set the number of seconds elapsed so far.
 void setSecondsRemaining(int secondsRemaining)
          Set the estimated number of seconds remaining until completion.
 void setSource(String source)
          Set the source of the file being transferred.
 void setState(int state)
          Set the current state of the transfer.
 void setTotalBytes(int totalBytes)
          Set the total number of bytes that will be transferred.
 void setTransferRate(int transferRate)
          Set the transfer rate expressed as bytes per second.
 String toString()
          Return a string representation of this class suitable for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PENDING

public static final int PENDING
Enumerated value indicating the transfer is pending (i.e. not started yet).

See Also:
Constant Field Values

INPROGRESS

public static final int INPROGRESS
Enumerated value indicating the transfer is in progress.

See Also:
Constant Field Values

COMPLETED

public static final int COMPLETED
Enumerated value indicating the transfer has completed successfully.

See Also:
Constant Field Values

CANCELLED

public static final int CANCELLED
Enumerated value indicating the transfer was cancelled by the user.

See Also:
Constant Field Values

FAILED

public static final int FAILED
Enumerated value indicating the transfer failed.

See Also:
Constant Field Values

UPLOAD

public static final int UPLOAD
Enumerated value indicating the transfer is an upload.

See Also:
Constant Field Values

DOWNLOAD

public static final int DOWNLOAD
Enumerated value indicating the transfer is a download.

See Also:
Constant Field Values

COPY

public static final int COPY
Enumerated value indicating the transfer is a copy.

See Also:
Constant Field Values

listenerList

protected EventListenerList listenerList
List of listeners

Constructor Detail

JvDataTransferModel

public JvDataTransferModel(int direction)
Construct a new JvDataTransferModel.

Parameters:
direction - of the transfer (one of UPLOAD, DOWNLOAD, or COPY)
Method Detail

getDirection

public int getDirection()
Return the direction of the transfer.

Returns:
the direction of the transfer

setDirection

public void setDirection(int direction)
Set the current direction of the transfer.

Parameters:
direction - the current direction of the transfer

getState

public int getState()
Return the current state of the transfer.

Returns:
the current state of the transfer

setState

public void setState(int state)
Set the current state of the transfer.

Parameters:
state - the current state of the transfer

getName

public String getName()
Return the name of the file being transferred.

Returns:
the name of the file being transferred

setName

public void setName(String name)
Set the name of the file being transferred.

Parameters:
name - the name of the file being transferred

getDestination

public String getDestination()
Return the destination of the file being transferred.

Returns:
the destination of the file being transferred

setDestination

public void setDestination(String destination)
Set the destination of the file being transferred.

Parameters:
destination - the destination of the file being transferred

getFile

public File getFile()
Return the File of the downloaded file.

Returns:
the File of the downloaded file

setFile

public void setFile(File file)
Set the File of the downloaded file.

Parameters:
file - the File of the downloaded file

getException

public Exception getException()
Return the Exception of the downloaded exception.

Returns:
the Exception of the downloaded exception

setException

public void setException(Exception exception)
Set the Exception of the downloaded exception.

Parameters:
exception - the Exception of the downloaded exception

getSource

public String getSource()
Return the source of the file being transferred.

Returns:
the source of the file being transferred

setSource

public void setSource(String source)
Set the source of the file being transferred.

Parameters:
source - the source of the file being transferred

getTotalBytes

public int getTotalBytes()
Return the total number of bytes that will be transferred.

Returns:
the total number of bytes that will be transferred; -1 if unknown

setTotalBytes

public void setTotalBytes(int totalBytes)
Set the total number of bytes that will be transferred.

Parameters:
totalBytes - total number of bytes that will be transferred

getBytesTransferred

public int getBytesTransferred()
Return the number of bytes transferred so far.

Returns:
the number of bytes transferred so far; -1 if unknown

setBytesTransferred

public void setBytesTransferred(int bytesTransferred)
Set the number of bytes transferred so far.

Parameters:
bytesTransferred - the number of bytes transferred so far

addBytesTransferred

public void addBytesTransferred(int amount)
Adjust the number of bytes transferred so far.

Parameters:
amount - the amount to adjust

getBytesRemaining

public int getBytesRemaining()
Return the number of bytes remaining to transfer.

Returns:
the number of bytes remaining to transfer

getSecondsElapsed

public int getSecondsElapsed()
Return the number of seconds elapsed so far.

Returns:
the number of seconds elapsed so far; -1 if unknown

setSecondsElapsed

public void setSecondsElapsed(int secondsElapsed)
Set the number of seconds elapsed so far.

Parameters:
secondsElapsed - the number of seconds elapsed so far

addSecondsElapsed

public void addSecondsElapsed(int amount)
Adjust the number of seconds elapsed so far.

Parameters:
amount - the amount to adjust

getSecondsRemaining

public int getSecondsRemaining()
Return the estimated number of seconds remaining until completion.

Returns:
the estimated number of seconds remaining until completion; -1 if unknown

setSecondsRemaining

public void setSecondsRemaining(int secondsRemaining)
Set the estimated number of seconds remaining until completion.

Parameters:
secondsRemaining - the number of seconds remaining until completion

getTransferRate

public int getTransferRate()
Return the latest transfer rate expressed as bytes per second.

Returns:
the latest transfer rate expressed as bytes per second; -1 if unknown

setTransferRate

public void setTransferRate(int transferRate)
Set the transfer rate expressed as bytes per second.

Parameters:
transferRate - the transfer rate expressed as bytes per second

requestCancellation

public final void requestCancellation()
Request the cancellation of the transfer.


cancelRequested

public final boolean cancelRequested()
Determine if a request has been made to cancel the transfer.


fireModelChanged

public void fireModelChanged()
Notify all listeners that this model has changed.


fireModelChanged

public void fireModelChanged(EventObject e)
Notify all listeners that this model has changed.


addDataTransferModelListener

public void addDataTransferModelListener(JvDataTransferModelListener l)
Adds a listener to the list that is notified each time a change to the data model occurs.

Parameters:
l - the JvDataTransferModelListener

removeDataTransferModelListener

public void removeDataTransferModelListener(JvDataTransferModelListener l)
Removes a listener from the list that is notified each time a change to the data model occurs.

Parameters:
l - the DataTransferModelListener

toString

public String toString()
Return a string representation of this class suitable for debugging.

Overrides:
toString in class Object


Copyright © 1999-2004 Neil W. Weber. All Rights Reserved.