gnu.inet.ftp
Class Getter

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--gnu.inet.ftp.Getter
All Implemented Interfaces:
ConnectionEventSource, java.lang.Runnable, TransferEventSource
Direct Known Subclasses:
ActiveGetter, PassiveGetter

public class Getter
extends java.lang.Thread
implements ConnectionEventSource, TransferEventSource

This class serves as a superclass to the ActiveGetter and PassiveGetter classes, providing a common interface and data members.

This class is used internally to the FtpClient class.


Field Summary
static int BUFFER_SIZE
           
protected  boolean cancelled
           
protected  java.util.Vector connectionListeners
           
protected  char mode
           
protected  java.io.OutputStream ostream
           
protected  java.util.Vector transferListeners
           
protected  char type
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Getter()
          set the Getter initial state with debugging disabled.
 
Method Summary
 void addConnectionListener(ConnectionListener listener)
          add a ConnectionListener to the list of connectionListeners
 void addConnectionListeners(java.util.Vector listeners)
          add a set of ConnectionListener to the list of connectionListeners
 void addTransferListener(TransferListener listener)
          add a TransferListener to the list of transfer listeners.
 void addTransferListeners(java.util.Vector listeners)
          add a set of TransferListener to the list of transfer listeners
 void cancel()
          cancel a running transfer sets a flag and calls interrupt() can only be called once
 void removeConnectionListener(ConnectionListener listener)
          De-register a ConnectionListener from the event source.
 void removeTransferListener(TransferListener listener)
          De-register a TransferListener from the event source.
 void setDebug(boolean value)
          Sets the ConsoleLogger's debug output.
 void setMode(char mode)
          set the mode value
 void setOutputStream(java.io.OutputStream ostream)
          set the OutputStream to be used for data storage
 void setType(char type)
          set the type value
protected  void signalConnectionClosed(ConnectionEvent event)
          signal that a connection has been closed
protected  void signalConnectionFailed(java.lang.Exception exception)
          signal that a connection has encountered an error
protected  void signalConnectionOpened(ConnectionEvent event)
          signal that a connection has been opened
protected  void signalTransferCompleted()
          signal that a transfer has completed
protected  void signalTransfered(long amount)
          signal that a transfer has completed
protected  void signalTransferStarted()
          signal that a transfer has begun
 void start()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE

ostream

protected java.io.OutputStream ostream

cancelled

protected boolean cancelled

connectionListeners

protected java.util.Vector connectionListeners

transferListeners

protected java.util.Vector transferListeners

mode

protected char mode

type

protected char type
Constructor Detail

Getter

public Getter()
set the Getter initial state with debugging disabled.
Method Detail

setOutputStream

public void setOutputStream(java.io.OutputStream ostream)
set the OutputStream to be used for data storage
Parameters:
ostream - the OutputStream to write data to

setMode

public void setMode(char mode)
set the mode value
Parameters:
mode - the new mode value. Valid values (MODE_*) can be found in the FtpClientProtocol class.
See Also:
FtpClientProtocol

setType

public void setType(char type)
set the type value
Parameters:
type - the new type value. Valid values (TYPE_*) can be found in the FtpClientProtocol class.
See Also:
FtpClientProtocol

setDebug

public void setDebug(boolean value)
Sets the ConsoleLogger's debug output. Does nothing for log4j. Log4j needs to be configured using log4j.properties
Parameters:
value - new debug flag value

cancel

public void cancel()
cancel a running transfer sets a flag and calls interrupt() can only be called once

start

public void start()
Overrides:
start in class java.lang.Thread

addConnectionListener

public void addConnectionListener(ConnectionListener listener)
add a ConnectionListener to the list of connectionListeners
Specified by:
addConnectionListener in interface ConnectionEventSource
Parameters:
listener - the ConnectionListener to add to the list

addConnectionListeners

public void addConnectionListeners(java.util.Vector listeners)
add a set of ConnectionListener to the list of connectionListeners
Specified by:
addConnectionListeners in interface ConnectionEventSource
Parameters:
listeners - the ConnectionListeners to add to the list

removeConnectionListener

public void removeConnectionListener(ConnectionListener listener)
De-register a ConnectionListener from the event source. The listener should not receive any more events.
Specified by:
removeConnectionListener in interface ConnectionEventSource
Parameters:
listener - the ConnectionListener to de-register

addTransferListener

public void addTransferListener(TransferListener listener)
add a TransferListener to the list of transfer listeners. All TransferListeners registered with this Getter will be notified when a transfer event occurs.
Specified by:
addTransferListener in interface TransferEventSource
Parameters:
listener - the TransferListener to add to the list

addTransferListeners

public void addTransferListeners(java.util.Vector listeners)
add a set of TransferListener to the list of transfer listeners
Specified by:
addTransferListeners in interface TransferEventSource
Parameters:
listeners - the TransferListeners to add to the list

removeTransferListener

public void removeTransferListener(TransferListener listener)
De-register a TransferListener from the event source. The listener should not receive any more events.
Specified by:
removeTransferListener in interface TransferEventSource
Parameters:
listener - the TransferListener to de-register

signalConnectionOpened

protected void signalConnectionOpened(ConnectionEvent event)
signal that a connection has been opened
Parameters:
event - the event to distribute to each ConnectionListener

signalConnectionClosed

protected void signalConnectionClosed(ConnectionEvent event)
signal that a connection has been closed
Parameters:
event - the event to distribute to each ConnectionListener

signalConnectionFailed

protected void signalConnectionFailed(java.lang.Exception exception)
signal that a connection has encountered an error
Parameters:
exception - the exception that was thrown

signalTransferStarted

protected void signalTransferStarted()
signal that a transfer has begun

signalTransferCompleted

protected void signalTransferCompleted()
signal that a transfer has completed

signalTransfered

protected void signalTransfered(long amount)
signal that a transfer has completed
Parameters:
amount - the amount of data (in octets) transfered