gnu.inet.ftp
Class Putter

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--gnu.inet.ftp.Putter
All Implemented Interfaces:
ConnectionEventSource, java.lang.Runnable, TransferEventSource
Direct Known Subclasses:
ActivePutter, PassivePutter

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

implements a FTP-style data connection server thread for PUTing files/data.

This class mainly serves as a superclass to ActivePutter and PassivePutter.


Field Summary
static int BUFFER_SIZE
           
protected  boolean cancelled
           
protected  java.util.Vector connectionListeners
           
protected  java.io.InputStream istream
           
protected  char mode
           
protected  java.util.Vector transferListeners
           
protected  char type
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Putter()
          default constructor
 
Method Summary
 void addConnectionListener(ConnectionListener listener)
          add a ConnectionListener to the list of connectionListeners
 void addConnectionListeners(java.util.Vector listeners)
          add a set of ConnectionListeners to the list of connectionListeners
 void addTransferListener(TransferListener listener)
          register a TransferListener to the list of transfer listeners.
 void addTransferListeners(java.util.Vector listeners)
          add a set of TransferListeners 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 with the event source
 void removeTransferListener(TransferListener listener)
          De-register a TransferListener with the event source.
 void setDebug(boolean value)
          Sets the ConsoleLogger's debug output.
 void setInputStream(java.io.InputStream istream)
          set the InputStream to use for data input
 void setMode(char mode)
          set the mode value.
 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 started
 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

istream

protected java.io.InputStream istream

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

Putter

public Putter()
default constructor
Method Detail

start

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

setInputStream

public void setInputStream(java.io.InputStream istream)
set the InputStream to use for data input
Parameters:
istream - the InputStream to read data from

setMode

public void setMode(char mode)
set the mode value. valid mode settings (MODE_*) can be found in the FtpClientProtocol class.
Parameters:
mode - the new mode setting

setType

public void setType(char type)
set the type value. valid type settings (TYPE_*) can be found in the FtpClientProtocol class.
Parameters:
type - the new type setting

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

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 ConnectionListeners 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 with the event source
Specified by:
removeConnectionListener in interface ConnectionEventSource
Parameters:
listener - the ConnectionListener to remove from the list of listeners

addTransferListener

public void addTransferListener(TransferListener listener)
register a TransferListener to the list of transfer listeners. Each transfer listener registered with the event source will be notified when a transfer event occurs.
Specified by:
addTransferListener in interface TransferEventSource
Parameters:
listener - the TransferListener to register with the event source

addTransferListeners

public void addTransferListeners(java.util.Vector listeners)
add a set of TransferListeners 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 with the event source.
Specified by:
removeTransferListener in interface TransferEventSource
Parameters:
listener - the TransferListener to de-register with the event source

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 started

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) that has been transfered