public class FTPEnvironment extends Object implements Map<String,Object>
FileSystemProvider.newFileSystem(URI, Map)
and
FileSystemProvider.newFileSystem(Path, Map)
methods of FTPFileSystemProvider
.Modifier and Type | Class and Description |
---|---|
static interface |
FTPEnvironment.QueryParam
Indicates which query parameters can be used to define environment values.
|
static interface |
FTPEnvironment.QueryParams
A container for
FTPEnvironment.QueryParam annotations. |
Constructor and Description |
---|
FTPEnvironment()
Creates a new FTP environment.
|
FTPEnvironment(Map<String,Object> map)
Creates a new FTP environment.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
static FTPEnvironment |
copy(Map<String,?> env)
Copies a map to create a new
FTPEnvironment instance. |
Set<Map.Entry<String,Object>> |
entrySet() |
boolean |
equals(Object o) |
Object |
get(Object key) |
int |
hashCode() |
boolean |
isEmpty() |
Set<String> |
keySet() |
Object |
put(String key,
Object value) |
void |
putAll(Map<? extends String,? extends Object> m) |
Object |
remove(Object key) |
static void |
setDefault(FTPEnvironment defaultEnvironment)
Sets the default FTP environment.
|
int |
size() |
String |
toString() |
Collection<Object> |
values() |
FTPEnvironment |
withActiveExternalIPAddress(String ipAddress)
Stores the external IP address in active mode.
|
FTPEnvironment |
withActivePortRange(int minPort,
int maxPort)
Stores the client side port range in active mode.
|
FTPEnvironment |
withAutodetectEncoding(boolean autodetect)
Stores whether or not automatic server encoding detection should be enabled.
|
FTPEnvironment |
withBufferSize(int bufferSize)
Stores the buffer size to use.
|
FTPEnvironment |
withCharset(Charset charset)
Stores the charset to use.
|
FTPEnvironment |
withClientConfig(FTPClientConfig clientConfig)
Stores the FTP client config to use.
|
FTPEnvironment |
withConnectionMode(ConnectionMode connectionMode)
Stores the connection mode to use.
|
FTPEnvironment |
withConnectTimeout(int timeout)
Stores the connection timeout to use.
|
FTPEnvironment |
withControlEncoding(String encoding)
Stores the character encoding to be used by the FTP control connection.
|
FTPEnvironment |
withControlKeepAliveReplyTimeout(Duration timeout)
Stores how long to wait for control keep-alive message replies.
|
FTPEnvironment |
withControlKeepAliveReplyTimeout(int timeout)
Deprecated.
Use
withControlKeepAliveReplyTimeout(Duration) instead. |
FTPEnvironment |
withControlKeepAliveTimeout(Duration timeout)
Stores the time to wait between sending control connection keep-alive messages when processing file upload or download.
|
FTPEnvironment |
withControlKeepAliveTimeout(long timeout)
Deprecated.
Use
withControlKeepAliveTimeout(Duration) instead. |
FTPEnvironment |
withCredentials(String username,
char[] password)
Stores the credentials to use.
|
FTPEnvironment |
withCredentials(String username,
char[] password,
String account)
Stores the credentials to use.
|
FTPEnvironment |
withDataTimeout(Duration timeout)
Stores the timeout to use when reading from data connections.
|
FTPEnvironment |
withDataTimeout(int timeout)
Deprecated.
Use
withDataTimeout(Duration) instead. |
FTPEnvironment |
withDefaultDirectory(String pathname)
Stores the default directory to use.
|
FTPEnvironment |
withFileSystemExceptionFactory(FileSystemExceptionFactory factory)
Stores the file system exception factory to use.
|
FTPEnvironment |
withFTPFileStrategyFactory(FTPFileStrategyFactory factory)
Stores the FTP file strategy factory to use.
|
FTPEnvironment |
withIpAddressFromPasvResponse(boolean usingIpAddressFromPasvResponse)
Sets whether or not the IP address from the server's response should be used.
|
FTPEnvironment |
withKeepAlive(boolean keepAlive)
Stores whether or not
SO_KEEPALIVE should be enabled. |
FTPEnvironment |
withListHiddenFiles(boolean listHiddenFiles)
Stores whether or not to list hidden files.
|
FTPEnvironment |
withLocalAddress(InetAddress localAddr,
int localPort)
Stores the local address to use.
|
FTPEnvironment |
withParserFactory(FTPFileEntryParserFactory parserFactory)
Stores the factory used for parser creation.
|
FTPEnvironment |
withPassiveLocalIPAddress(String ipAddress)
Stores the local IP address to use in passive mode.
|
FTPEnvironment |
withPassiveNatWorkaroundStrategy(FTPClient.HostnameResolver resolver)
Stores the workaround strategy to replace the PASV mode reply addresses.
|
FTPEnvironment |
withPoolConfig(FTPPoolConfig poolConfig)
Stores the pool config to use.
|
FTPEnvironment |
withProxy(Proxy proxy)
Stores the proxy to use.
|
FTPEnvironment |
withReceiveBufferSize(int size)
Stores the socket receive buffer size to use.
|
FTPEnvironment |
withReceiveDataSocketBufferSize(int bufferSize)
Stores the value to use for the data socket
SO_RCVBUF option. |
FTPEnvironment |
withRemoteVerificationEnabled(boolean enabled)
Stores whether or not verification that the remote host taking part of a data connection is the same as the host to which the control
connection is attached should be enabled.
|
FTPEnvironment |
withReportActiveExternalIPAddress(String ipAddress)
Stores the external IP address to report in EPRT/PORT commands in active mode.
|
FTPEnvironment |
withSendBufferSize(int size)
Stores the socket send buffer size to use.
|
FTPEnvironment |
withSendDataSocketBufferSize(int bufferSizr)
Stores the value to use for the data socket
SO_SNDBUF option. |
FTPEnvironment |
withServerSocketFactory(ServerSocketFactory factory)
Stores the server socket factory to use.
|
FTPEnvironment |
withSocketFactory(SocketFactory factory)
Stores the socket factory to use.
|
FTPEnvironment |
withSoLinger(boolean on,
int linger)
Stores whether or not
SO_LINGER should be enabled, and if so, the linger time. |
FTPEnvironment |
withSoTimeout(int timeout)
Stores the socket timeout.
|
FTPEnvironment |
withStrictMultilineParsing(boolean strictMultilineParsing)
Stores whether or not strict multiline parsing should be enabled, as per RFC 959, section 4.2.
|
FTPEnvironment |
withTcpNoDelay(boolean on)
Stores whether or not the Nagle's algorithm (
TCP_NODELAY ) should be enabled. |
FTPEnvironment |
withUseEPSVwithIPv4(boolean selected)
Stores whether or not to use EPSV with IPv4.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
@FTPEnvironment.QueryParam(value="localAddr") @FTPEnvironment.QueryParam(value="localPort") public FTPEnvironment withLocalAddress(InetAddress localAddr, int localPort)
localAddr
- The local address to use.localPort
- The local port to use.Socket.bind(SocketAddress)
,
InetSocketAddress(InetAddress, int)
public FTPEnvironment withCredentials(String username, char[] password)
username
- The username to use.password
- The password to use.@FTPEnvironment.QueryParam(value="account") public FTPEnvironment withCredentials(String username, char[] password, String account)
username
- The username to use.password
- The password to use.account
- The account to use.@FTPEnvironment.QueryParam(value="soTimeout") public FTPEnvironment withSoTimeout(int timeout)
timeout
- The socket timeout in milliseconds.Socket.setSoTimeout(int)
@FTPEnvironment.QueryParam(value="sendBufferSize") public FTPEnvironment withSendBufferSize(int size)
size
- The size of the buffer in bytes.Socket.setSendBufferSize(int)
@FTPEnvironment.QueryParam(value="receiveBufferSize") public FTPEnvironment withReceiveBufferSize(int size)
size
- The size of the buffer in bytes.Socket.setReceiveBufferSize(int)
@FTPEnvironment.QueryParam(value="tcpNoDelay") public FTPEnvironment withTcpNoDelay(boolean on)
TCP_NODELAY
) should be enabled.on
- true
if Nagle's algorithm should be enabled, or false
otherwise.Socket.setTcpNoDelay(boolean)
@FTPEnvironment.QueryParam(value="keepAlive") public FTPEnvironment withKeepAlive(boolean keepAlive)
SO_KEEPALIVE
should be enabled.keepAlive
- true
if keep-alive should be enabled, or false
otherwise.Socket.setKeepAlive(boolean)
@FTPEnvironment.QueryParam(value="soLinger.on") @FTPEnvironment.QueryParam(value="soLinger.val") public FTPEnvironment withSoLinger(boolean on, int linger)
SO_LINGER
should be enabled, and if so, the linger time.on
- true
if SO_LINGER
should be enabled, or false
otherwise.linger
- The linger time in seconds, if on
is true
.Socket.setSoLinger(boolean, int)
public FTPEnvironment withSocketFactory(SocketFactory factory)
factory
- The socket factory to use.public FTPEnvironment withServerSocketFactory(ServerSocketFactory factory)
factory
- The server socket factory to use.@FTPEnvironment.QueryParam(value="connectTimeout") public FTPEnvironment withConnectTimeout(int timeout)
timeout
- The connection timeout in milliseconds.Socket.connect(SocketAddress, int)
public FTPEnvironment withProxy(Proxy proxy)
proxy
- The proxy to use.@FTPEnvironment.QueryParam(value="charset") public FTPEnvironment withCharset(Charset charset)
charset
- The charset to use.@FTPEnvironment.QueryParam(value="controlEncoding") public FTPEnvironment withControlEncoding(String encoding)
encoding
- The character encoding to use.@FTPEnvironment.QueryParam(value="strictMultilineParsing") public FTPEnvironment withStrictMultilineParsing(boolean strictMultilineParsing)
strictMultilineParsing
- true
to enable strict multiline parsing, or false
to disable it.@Deprecated public FTPEnvironment withDataTimeout(int timeout)
withDataTimeout(Duration)
instead.timeout
- The timeout in milliseconds that is used when opening data connection sockets.@FTPEnvironment.QueryParam(value="dataTimeout") public FTPEnvironment withDataTimeout(Duration timeout)
timeout
- The timeout in milliseconds that is used when opening data connection sockets.public FTPEnvironment withParserFactory(FTPFileEntryParserFactory parserFactory)
parserFactory
- The factory object used to create FTPFileEntryParser
s@FTPEnvironment.QueryParam(value="ipAddressFromPasvResponse") public FTPEnvironment withIpAddressFromPasvResponse(boolean usingIpAddressFromPasvResponse)
FTPClient.FTP_IP_ADDRESS_FROM_PASV_RESPONSE
.usingIpAddressFromPasvResponse
- true
if the IP address from the server's response should be used,
or false
to ignore that IP address.@FTPEnvironment.QueryParam(value="remoteVerificationEnabled") public FTPEnvironment withRemoteVerificationEnabled(boolean enabled)
enabled
- true
to enable verification, or false
to disable verification.@FTPEnvironment.QueryParam(value="defaultDir") public FTPEnvironment withDefaultDirectory(String pathname)
pathname
- The default directory to use.@FTPEnvironment.QueryParam(value="connectionMode") public FTPEnvironment withConnectionMode(ConnectionMode connectionMode)
ConnectionMode.ACTIVE
.connectionMode
- The connection mode to use.@FTPEnvironment.QueryParam(value="activePortRange.min") @FTPEnvironment.QueryParam(value="activePortRange.max") public FTPEnvironment withActivePortRange(int minPort, int maxPort)
minPort
- The lowest available port (inclusive).maxPort
- The highest available port (inclusive).@FTPEnvironment.QueryParam(value="activeExternalIPAddress") public FTPEnvironment withActiveExternalIPAddress(String ipAddress)
ipAddress
- The external IP address of this machine.@FTPEnvironment.QueryParam(value="passiveLocalIPAddress") public FTPEnvironment withPassiveLocalIPAddress(String ipAddress)
ipAddress
- The local IP address of this machine.@FTPEnvironment.QueryParam(value="reportActiveExternalIPAddress") public FTPEnvironment withReportActiveExternalIPAddress(String ipAddress)
ipAddress
- The external IP address of this machine.@FTPEnvironment.QueryParam(value="bufferSize") public FTPEnvironment withBufferSize(int bufferSize)
bufferSize
- The buffer size to use.@FTPEnvironment.QueryParam(value="sendDataSocketBufferSize") public FTPEnvironment withSendDataSocketBufferSize(int bufferSizr)
SO_SNDBUF
option.bufferSizr
- The size of the buffer.@FTPEnvironment.QueryParam(value="receiveDataSocketBufferSize") public FTPEnvironment withReceiveDataSocketBufferSize(int bufferSize)
SO_RCVBUF
option.bufferSize
- The size of the buffer.public FTPEnvironment withClientConfig(FTPClientConfig clientConfig)
clientConfig
- The client config to use.@FTPEnvironment.QueryParam(value="useEPSVwithIPv4") public FTPEnvironment withUseEPSVwithIPv4(boolean selected)
For example, when using IPv4 with NAT it may work with some rare configurations. E.g. if FTP server has a static PASV address (external network) and the client is coming from another internal network. In that case the data connection after PASV command would fail, while EPSV would make the client succeed by taking just the port.
selected
- The flag to use.@Deprecated public FTPEnvironment withControlKeepAliveTimeout(long timeout)
withControlKeepAliveTimeout(Duration)
instead.timeout
- The keep-alive timeout to use, in milliseconds.@FTPEnvironment.QueryParam(value="controlKeepAliveTimeout") public FTPEnvironment withControlKeepAliveTimeout(Duration timeout)
timeout
- The keep-alive timeout to use.@Deprecated public FTPEnvironment withControlKeepAliveReplyTimeout(int timeout)
withControlKeepAliveReplyTimeout(Duration)
instead.timeout
- The keep-alive reply timeout to use, in milliseconds.@FTPEnvironment.QueryParam(value="controlKeepAliveReplyTimeout") public FTPEnvironment withControlKeepAliveReplyTimeout(Duration timeout)
timeout
- The keep-alive reply timeout to use.public FTPEnvironment withPassiveNatWorkaroundStrategy(FTPClient.HostnameResolver resolver)
FTPClient.NatServerResolverImpl
, i.e. site-local replies are replaced.resolver
- The workaround strategy to replace internal IP's in passive mode, or null
to disable the workaround
(i.e. use PASV mode reply address.)@FTPEnvironment.QueryParam(value="autodetectEncoding") public FTPEnvironment withAutodetectEncoding(boolean autodetect)
autodetect
- true
to enable automatic server encoding detection, or false
to disable it.@FTPEnvironment.QueryParam(value="listHiddenFiles") public FTPEnvironment withListHiddenFiles(boolean listHiddenFiles)
true
.
Note that if this flag is set to false
, the current directory will (most likely) not be returned when listing directories.
That means that StandardFTPFileStrategyFactory.UNIX
will not work correctly.
Ideally, only set this flag (to false
) if the FTP server does not support the -a
option for LIST
commands.
listHiddenFiles
- true
to list hidden files, or false
to omit them.@FTPEnvironment.QueryParam(value="poolConfig.maxWaitTime") @FTPEnvironment.QueryParam(value="poolConfig.maxIdleTime") @FTPEnvironment.QueryParam(value="poolConfig.initialSize") @FTPEnvironment.QueryParam(value="poolConfig.maxSize") public FTPEnvironment withPoolConfig(FTPPoolConfig poolConfig)
The maximum pool size influences the number of concurrent threads that can access an FTP file system.
If the maximum wait time is negative, FTP file systems wait
indefinitely until a client connection is available. This is the default setting if no pool config is defined.
poolConfig
- The pool config to use.public FTPEnvironment withFileSystemExceptionFactory(FileSystemExceptionFactory factory)
factory
- The file system exception factory to use.public FTPEnvironment withFTPFileStrategyFactory(FTPFileStrategyFactory factory)
StandardFTPFileStrategyFactory.AUTO_DETECT
.factory
- The FTP file strategy factory to use.public boolean containsKey(Object key)
containsKey
in interface Map<String,Object>
public boolean containsValue(Object value)
containsValue
in interface Map<String,Object>
public boolean equals(Object o)
public int hashCode()
public static FTPEnvironment copy(Map<String,?> env)
FTPEnvironment
instance.
If the given map is an instance of FTPSEnvironment
, this method will return a new FTPSEnvironment
instance.env
- The map to copy. It can be an FTPEnvironment
instance, but does not have to be.FTPEnvironment
instance that is a copy of the given map.public static void setDefault(FTPEnvironment defaultEnvironment)
FTPFileSystemProvider.getPath(URI)
when a file system needs to be created, since no environment can be passed.
This way, certain settings like pool configuration
can still be applied.defaultEnvironment
- The default FTP environment. Use null
to reset it to an empty environment.Copyright © 2016–2024. All rights reserved.