edtFTPj/Free - Open-source FTP library for Java | Download


com.enterprisedt.net.ftp
Class ConnectionContext

java.lang.Object
  extended by com.enterprisedt.net.ftp.ConnectionContext
All Implemented Interfaces:
java.lang.Cloneable

public class ConnectionContext
extends java.lang.Object
implements java.lang.Cloneable

Holds various parameters pertaining to the context of the connection. Used internally.

Version:
$Revision: 1.2 $
Author:
Bruce Blackshaw

Field Summary
protected  int transferBufferSize
          Size of transfer buffers
 
Constructor Summary
ConnectionContext()
           
 
Method Summary
 java.lang.Object clone()
           
 int getActiveHighPort()
          Get the upper limit of the port range for active mode.
 java.lang.String getActiveIPAddress()
          The active IP address being used, or null if not used
 int getActiveLowPort()
          Get the lower limit of the port range for active mode.
 FTPConnectMode getConnectMode()
           
 FTPTransferType getContentType()
           
 java.lang.String getControlEncoding()
          Get the encoding used for the control connection
 boolean getDetectContentType()
          Get the detect content type flag
 DirectoryEmptyStrings getDirectoryEmptyMessages()
          Get class that holds fragments of server messages that indicate a directory is empty.
 FileNotFoundStrings getFileNotFoundMessages()
          Get class that holds fragments of server messages that indicate a file was not found.
 boolean getListenOnAllInterfaces()
          Are we listening on all interfaces in active mode, which is the default?
 java.util.Locale[] getParserLocales()
           
 java.lang.String getPassword()
           
 java.lang.String getRemoteHost()
           
 int getRemotePort()
           
 int getTimeout()
           
 int getTransferBufferSize()
          Get the size of the buffers used in writing to and reading from the data sockets
 TransferCompleteStrings getTransferCompleteMessages()
          Get class that holds fragments of server messages that indicate a transfer completed.
 int getTransferNotifyInterval()
          Get the interval used for progress notification of transfers.
 java.lang.String getUserName()
           
 boolean isAutoLogin()
          Determine if auto login is switched on
 boolean isAutoPassiveIPSubstitution()
          Is automatic substitution of the remote host IP set to be on for passive mode connections?
 boolean isDeleteOnFailure()
          If true, delete partially written files when exceptions are thrown during a download
 boolean isStrictReturnCodes()
          Determine if strict checking of return codes is switched on.
 void setActiveIPAddress(java.lang.String activeIP)
          We can force PORT to send a fixed IP address, which can be useful with certain NAT configurations.
 void setActivePortRange(int lowest, int highest)
          Force a certain range of ports to be used in active mode.
 void setAutoLogin(boolean autoLogin)
          Set the autoLogin flag
 void setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution)
          Set automatic substitution of the remote host IP on if in passive mode
 void setConnectMode(FTPConnectMode connectMode)
           
 void setContentType(FTPTransferType transferType)
           
 void setControlEncoding(java.lang.String controlEncoding)
          Set the encoding used for control channel messages
 void setDeleteOnFailure(boolean deleteOnFailure)
          Switch on or off the automatic deletion of partially written files that are left when an exception is thrown during a download
 void setDetectContentType(boolean detectContentType)
          Set autodetect of filetypes on or off.
 void setListenOnAllInterfaces(boolean listenOnAll)
          Listen on all interfaces for active mode transfers (the default).
 void setParserLocales(java.util.Locale[] locales)
          Set the list of locales to be tried for date parsing of dir listings
 void setPassword(java.lang.String password)
           
 void setRemoteHost(java.lang.String remoteHost)
           
 void setRemotePort(int remotePort)
           
 void setStrictReturnCodes(boolean strict)
          Set strict checking of FTP return codes.
 void setTimeout(int timeout)
           
 void setTransferBufferSize(int size)
          Set the size of the buffers used in writing to and reading from the data sockets
 void setTransferNotifyInterval(int notifyInterval)
          Set the interval used for progress notification of transfers.
 void setUserName(java.lang.String username)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transferBufferSize

protected int transferBufferSize
Size of transfer buffers

Constructor Detail

ConnectionContext

public ConnectionContext()
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

isAutoLogin

public boolean isAutoLogin()
Determine if auto login is switched on

Returns:
true if auto login

setAutoLogin

public void setAutoLogin(boolean autoLogin)
Set the autoLogin flag

Parameters:
autoLogin - true if logging in automatically

setDetectContentType

public void setDetectContentType(boolean detectContentType)
Set autodetect of filetypes on or off. If on, the transfer mode is switched from ASCII to binary and vice versa depending on the extension of the file. After the transfer, the mode is always returned to what it was before the transfer was performed. The default is off. If the filetype is unknown, the transfer mode is unchanged

Parameters:
detectContentType - true if detecting transfer mode, false if not

getDetectContentType

public boolean getDetectContentType()
Get the detect content type flag

Returns:
true if we are detecting binary and ASCII transfers from the file type

setActiveIPAddress

public void setActiveIPAddress(java.lang.String activeIP)
We can force PORT to send a fixed IP address, which can be useful with certain NAT configurations.

Parameters:
activeIP - IP address to force, in 192.168.1.0 form or in IPV6 form, e.g. 1080::8:800:200C:417A

getActiveIPAddress

public java.lang.String getActiveIPAddress()
The active IP address being used, or null if not used

Returns:
IP address as a string or null

setActivePortRange

public void setActivePortRange(int lowest,
                               int highest)
Force a certain range of ports to be used in active mode. This is generally so that a port range can be configured in a firewall. Note that if lowest == highest, a single port will be used. This works well for uploads, but downloads generally require multiple ports, as most servers fail to create a connection repeatedly for the same port.

Parameters:
lowest - Lower limit of range.
highest - Upper limit of range.

getActiveLowPort

public int getActiveLowPort()
Get the lower limit of the port range for active mode.

Returns:
lower limit, or -1 if not set

getActiveHighPort

public int getActiveHighPort()
Get the upper limit of the port range for active mode.

Returns:
upper limit, or -1 if not set

setStrictReturnCodes

public void setStrictReturnCodes(boolean strict)
Set strict checking of FTP return codes. If strict checking is on (the default) code must exactly match the expected code. If strict checking is off, only the first digit must match.

Parameters:
strict - true for strict checking, false for loose checking

isStrictReturnCodes

public boolean isStrictReturnCodes()
Determine if strict checking of return codes is switched on. If it is (the default), all return codes must exactly match the expected code. If strict checking is off, only the first digit must match.

Returns:
true if strict return code checking, false if non-strict.

isAutoPassiveIPSubstitution

public boolean isAutoPassiveIPSubstitution()
Is automatic substitution of the remote host IP set to be on for passive mode connections?

Returns:
true if set on, false otherwise

setAutoPassiveIPSubstitution

public void setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution)
Set automatic substitution of the remote host IP on if in passive mode

Parameters:
autoPassiveIPSubstitution - true if set to on, false otherwise

setListenOnAllInterfaces

public void setListenOnAllInterfaces(boolean listenOnAll)
Listen on all interfaces for active mode transfers (the default).

Parameters:
listenOnAll - true if listen on all interfaces, false to listen on the control interface

getListenOnAllInterfaces

public boolean getListenOnAllInterfaces()
Are we listening on all interfaces in active mode, which is the default?

Returns:
true if listening on all interfaces, false if listening just on the control interface

isDeleteOnFailure

public boolean isDeleteOnFailure()
If true, delete partially written files when exceptions are thrown during a download

Returns:
true if delete local file on error

setDeleteOnFailure

public void setDeleteOnFailure(boolean deleteOnFailure)
Switch on or off the automatic deletion of partially written files that are left when an exception is thrown during a download

Parameters:
deleteOnFailure - true if delete when a failure occurs

getConnectMode

public FTPConnectMode getConnectMode()

setConnectMode

public void setConnectMode(FTPConnectMode connectMode)

setPassword

public void setPassword(java.lang.String password)

setRemoteHost

public void setRemoteHost(java.lang.String remoteHost)

setRemotePort

public void setRemotePort(int remotePort)

setUserName

public void setUserName(java.lang.String username)

setContentType

public void setContentType(FTPTransferType transferType)

getContentType

public FTPTransferType getContentType()

getPassword

public java.lang.String getPassword()

getRemoteHost

public java.lang.String getRemoteHost()

getRemotePort

public int getRemotePort()

setParserLocales

public void setParserLocales(java.util.Locale[] locales)
Set the list of locales to be tried for date parsing of dir listings

Parameters:
locales - locales to use

getTimeout

public int getTimeout()

setTimeout

public void setTimeout(int timeout)

getUserName

public java.lang.String getUserName()

getParserLocales

public java.util.Locale[] getParserLocales()

getControlEncoding

public java.lang.String getControlEncoding()
Get the encoding used for the control connection

Returns:
Returns the current controlEncoding.

setControlEncoding

public void setControlEncoding(java.lang.String controlEncoding)
Set the encoding used for control channel messages

Parameters:
controlEncoding - The controlEncoding to set, which is the name of a Charset

setTransferBufferSize

public void setTransferBufferSize(int size)
Set the size of the buffers used in writing to and reading from the data sockets

Parameters:
size - new size of buffer in bytes

getTransferBufferSize

public int getTransferBufferSize()
Get the size of the buffers used in writing to and reading from the data sockets

Returns:
transfer buffer size

getTransferNotifyInterval

public int getTransferNotifyInterval()
Get the interval used for progress notification of transfers.

Returns:
number of bytes between each notification.

setTransferNotifyInterval

public void setTransferNotifyInterval(int notifyInterval)
Set the interval used for progress notification of transfers.

Parameters:
notifyInterval - number of bytes between each notification

getFileNotFoundMessages

public FileNotFoundStrings getFileNotFoundMessages()
Get class that holds fragments of server messages that indicate a file was not found. New messages can be added.

The fragments are used when it is necessary to examine the message returned by a server to see if it is saying a file was not found. If an FTP server is returning a different message that still clearly indicates a file was not found, use this property to add a new server fragment to the repository via the add method. It would be helpful to email support at enterprisedt dot com to inform us of the message so it can be added to the next build.

Returns:
messages class

getTransferCompleteMessages

public TransferCompleteStrings getTransferCompleteMessages()
Get class that holds fragments of server messages that indicate a transfer completed. New messages can be added.

The fragments are used when it is necessary to examine the message returned by a server to see if it is saying a transfer completed. If an FTP server is returning a different message that still clearly indicates a transfer failed, use this property to add a new server fragment to the repository via the add method. It would be helpful to email support at enterprisedt dot com to inform us of the message so it can be added to the next build.

Returns:
messages class

getDirectoryEmptyMessages

public DirectoryEmptyStrings getDirectoryEmptyMessages()
Get class that holds fragments of server messages that indicate a directory is empty. New messages can be added.

The fragments are used when it is necessary to examine the message returned by a server to see if it is saying a directory is empty. If an FTP server is returning a different message that still clearly indicates a directory is empty, use this property to add a new server fragment to the repository via the add method. It would be helpful to email support at enterprisedt dot com to inform us of the message so it can be added to the next build.

Returns:
messages class


Copyright (c) 2001-2007 Enterprise Distributed Technologies Ltd. All Rights Reserved.