org.mockftpserver.core.session
Interface Session

All Superinterfaces:
Runnable
All Known Implementing Classes:
DefaultSession

public interface Session
extends Runnable

Represents an FTP session state and behavior

Version:
$Revision: 254 $ - $Date: 2011-06-05 08:15:56 -0400 (Sun, 05 Jun 2011) $
Author:
Chris Mair

Method Summary
 void close()
          Close the session, closing the underlying sockets
 void closeDataConnection()
          Close the data connection
 Object getAttribute(String name)
          Return the attribute value for the specified name.
 Set getAttributeNames()
          Return the Set of names under which attributes have been stored on this session.
 InetAddress getClientHost()
          Return the InetAddress representing the client host for this session
 InetAddress getServerHost()
          Return the InetAddress representing the server host for this session
 void openDataConnection()
          Open the data connection, attaching to the predefined port number on the client
 byte[] readData()
          Read data from the client across the data connection
 byte[] readData(int numBytes)
          Read and return (up to) numBytes of data from the client across the data connection
 void removeAttribute(String name)
          Remove the attribute value for the specified name.
 void sendData(byte[] data, int numBytes)
          Write the specified data using the data connection
 void sendReply(int replyCode, String replyText)
          Send the specified reply code and text across the control connection.
 void setAttribute(String name, Object value)
          Store the value under the specified attribute name.
 void setClientDataHost(InetAddress clientHost)
           
 void setClientDataPort(int clientDataPort)
           
 int switchToPassiveMode()
          Switch to passive mode
 
Methods inherited from interface java.lang.Runnable
run
 

Method Detail

close

void close()
Close the session, closing the underlying sockets


sendReply

void sendReply(int replyCode,
               String replyText)
Send the specified reply code and text across the control connection.

Parameters:
replyCode - - the reply code
replyText - - the reply text to send; may be null

openDataConnection

void openDataConnection()
Open the data connection, attaching to the predefined port number on the client


closeDataConnection

void closeDataConnection()
Close the data connection


switchToPassiveMode

int switchToPassiveMode()
Switch to passive mode

Returns:
the local port to be connected to by clients for data transfers

sendData

void sendData(byte[] data,
              int numBytes)
Write the specified data using the data connection

Parameters:
data - - the data to write
numBytes - - the number of bytes from data to send

readData

byte[] readData()
Read data from the client across the data connection

Returns:
the data that was read

readData

byte[] readData(int numBytes)
Read and return (up to) numBytes of data from the client across the data connection

Returns:
the data that was read; the byte[] will be up to numBytes bytes long

getClientHost

InetAddress getClientHost()
Return the InetAddress representing the client host for this session

Returns:
the client host

getServerHost

InetAddress getServerHost()
Return the InetAddress representing the server host for this session

Returns:
the server host

setClientDataHost

void setClientDataHost(InetAddress clientHost)
Parameters:
clientHost - - the client host for the data connection

setClientDataPort

void setClientDataPort(int clientDataPort)
Parameters:
clientDataPort - - the port number on the client side for the data connection

getAttribute

Object getAttribute(String name)
Return the attribute value for the specified name. Return null if no attribute value exists for that name or if the attribute value is null.

Parameters:
name - - the attribute name; may not be null
Returns:
the value of the attribute stored under name; may be null
Throws:
AssertFailedException - - if name is null

setAttribute

void setAttribute(String name,
                  Object value)
Store the value under the specified attribute name.

Parameters:
name - - the attribute name; may not be null
value - - the attribute value; may be null
Throws:
AssertFailedException - - if name is null

removeAttribute

void removeAttribute(String name)
Remove the attribute value for the specified name. Do nothing if no attribute value is stored for the specified name.

Parameters:
name - - the attribute name; may not be null
Throws:
AssertFailedException - - if name is null

getAttributeNames

Set getAttributeNames()
Return the Set of names under which attributes have been stored on this session. Returns an empty Set if no attribute values are stored.

Returns:
the Set of attribute names


Copyright © 2014. All rights reserved.