it.sauronsoftware.ftp4j
Class FTPCommunicationChannel

java.lang.Object
  extended by it.sauronsoftware.ftp4j.FTPCommunicationChannel

public class FTPCommunicationChannel
extends java.lang.Object

This class is used to represent a communication channel with a FTP server.

Version:
1.1
Author:
Carlo Pelliccia

Constructor Summary
FTPCommunicationChannel(java.net.Socket connection, java.lang.String charsetName)
          It builds a FTP communication channel.
 
Method Summary
 void addCommunicationListener(FTPCommunicationListener listener)
          This method adds a FTPCommunicationListener to the object.
 void changeCharset(java.lang.String charsetName)
          Changes the current charset.
 void close()
          Closes the channel.
 FTPCommunicationListener[] getCommunicationListeners()
          This method returns a list with all the FTPCommunicationListener used by the client.
 FTPReply readFTPReply()
          This method reads and parses a FTP reply statement from the server.
 void removeCommunicationListener(FTPCommunicationListener listener)
          This method removes a FTPCommunicationListener previously added to the object.
 void sendFTPCommand(java.lang.String command)
          This method sends a command line to the server.
 void ssl(javax.net.ssl.SSLSocketFactory sslSocketFactory)
          Applies SSL encryption to the communication channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FTPCommunicationChannel

public FTPCommunicationChannel(java.net.Socket connection,
                               java.lang.String charsetName)
                        throws java.io.IOException
It builds a FTP communication channel.

Parameters:
connection - The underlying connection.
charsetName - The name of the charset that has to be used to encode and decode the communication.
Throws:
java.io.IOException - If a I/O error occurs.
Method Detail

addCommunicationListener

public void addCommunicationListener(FTPCommunicationListener listener)
This method adds a FTPCommunicationListener to the object.

Parameters:
listener - The listener.

removeCommunicationListener

public void removeCommunicationListener(FTPCommunicationListener listener)
This method removes a FTPCommunicationListener previously added to the object.

Parameters:
listener - The listener to be removed.

close

public void close()
Closes the channel.


getCommunicationListeners

public FTPCommunicationListener[] getCommunicationListeners()
This method returns a list with all the FTPCommunicationListener used by the client.

Returns:
A list with all the FTPCommunicationListener used by the client.

sendFTPCommand

public void sendFTPCommand(java.lang.String command)
                    throws java.io.IOException
This method sends a command line to the server.

Parameters:
command - The command to be sent.
Throws:
java.io.IOException - If an I/O error occurs.

readFTPReply

public FTPReply readFTPReply()
                      throws java.io.IOException,
                             FTPIllegalReplyException
This method reads and parses a FTP reply statement from the server.

Returns:
The reply from the server.
Throws:
java.io.IOException - If an I/O error occurs.
FTPIllegalReplyException - If the server doesn't reply in a FTP-compliant way.

changeCharset

public void changeCharset(java.lang.String charsetName)
                   throws java.io.IOException
Changes the current charset.

Parameters:
charsetName - The new charset.
Throws:
java.io.IOException - If I/O error occurs.
Since:
1.1

ssl

public void ssl(javax.net.ssl.SSLSocketFactory sslSocketFactory)
         throws java.io.IOException
Applies SSL encryption to the communication channel.

Parameters:
sslSocketFactory - The SSLSocketFactory used to produce the SSL connection.
Throws:
java.io.IOException - If a I/O error occurs.
Since:
1.4