public class VFSConnection extends Object
Objects of this type are managed using the VFSConnectionDialog
.
Subclasses may add URL specific parameters as necessary.
Modifier and Type | Field and Description |
---|---|
static String |
PARAM_HOST
The ip address or the name of the host (
String ). |
static String |
PARAM_PATH
The (absolute) path on the host (
String ). |
static String |
PARAM_PORT
The port number for the host access (
int ). |
static String |
PARAM_SAVE_PASSWORD
Save the password for the user (
boolean )? |
static String |
PARAM_USER
The name of the user (
String ). |
static String |
PARAM_USER_PASSWORD
The password for the user (
String ). |
static String |
VAR_CONNECTION_ID
Configuration variable name (
String ). |
static String |
VAR_CONNECTION_NAME
Configuration variable name (
String ). |
static String |
VAR_EXPERT_DISPLAY_BEFORE
Configuration variable name (
boolean ). |
static String |
VAR_EXPERT_ENCODING
Configuration variable name (
String ). |
static String |
VAR_EXPERT_KEEP_ALIVE
Configuration variable name (
boolean ). |
static String |
VAR_EXPERT_KEEP_ALIVE_PING
Configuration variable name (
boolean ). |
static String |
VAR_EXPERT_KEEP_ALIVE_RESOLVE
Configuration variable name (
boolean ). |
static String |
VAR_EXPERT_KEEP_ALIVE_SECONDS
Configuration variable name (
int ). |
static String |
VAR_EXPERT_MAX_WAIT
Configuration variable name (
boolean ). |
static String |
VAR_EXPERT_MAX_WAIT_SECONDS
Configuration variable name (
int ). |
static String |
VAR_PROTOCOL
Configuration variable name (
String ). |
Constructor and Description |
---|
VFSConnection()
Constructor method for i18n purposes only.
|
VFSConnection(VFSFileSystemManager vfsmanager,
String id)
Constructor method setting default values.
|
VFSConnection(VFSFileSystemManager vfsmanager,
String id,
Properties props,
org.apache.commons.vfs2.FileSystemOptions options)
Constructor method setting the container.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkUniqueName(Vector<VFSConnection> connections)
Checks if the name for the given connection is unique over all connections.
|
boolean |
checkUniqueUser(Vector<VFSConnection> connections)
Checks if the user for the given connection is unique over all connections of the same scheme.
|
VFSConnection |
clone()
Makes a copy of this object.
|
static VFSConnection |
createConnection(VFSFileSystemManager vfsmanager,
String protocol,
String id)
Creates a fresh new connection appropriate for the given VFS scheme/protocol.
|
static VFSConnection |
createConnection(VFSFileSystemManager vfsmanager,
String protocol,
String id,
Properties config,
org.apache.commons.vfs2.FileSystemOptions options)
Creates a fresh new connection appropriate for the given VFS scheme/protocol.
|
static boolean |
elementOf(Object object,
Object array)
Checks if the given object is element of the given array (equals).
|
static org.apache.commons.vfs2.FileSystemOptions |
getDefaultFileSystemOptions(String scheme,
String encoding)
Provides the default options for a certain protocol.
|
boolean |
getDisplayBefore(boolean fallback)
Provides the expert setting if settings shall be displayed before connection is established.
|
String |
getDisplayURI()
Assembles the URI which can be displayed safely (no cleartext passwords).
|
String |
getEncoding(String fallback)
Provides the expert setting which file system encoding shall be used.
|
VFSFileSystemManager |
getFileSystemManager()
Provides the file system manager.
|
org.apache.commons.vfs2.FileSystemOptions |
getFileSystemOptions()
The file system specific options for this connection.
|
String |
getHost(String fallback)
Provides the URL host part.
|
String |
getID(String fallback)
Provides the unique connection identifier.
|
boolean |
getKeepAlive(boolean fallback)
Provides the expert setting if connection is kept alive automatically.
|
boolean |
getKeepAlivePing(boolean fallback)
Provides the expert setting if connection is kept alive with ping.
|
boolean |
getKeepAliveResolve(boolean fallback)
Provides the expert setting if connection is kept alive with entry resolves.
|
int |
getKeepAliveSeconds(int fallback)
Provides the keep alive interval.
|
boolean |
getMaxWait(boolean fallback)
Provides the expert setting if to wait for connect.
|
int |
getMaxWaitSeconds(int fallback)
Provides the maximum number of seconds to wait for connect.
|
String |
getName(String fallback)
Provides the connection name.
|
String |
getPassword(String fallback)
Provides the URL password part.
|
String |
getPath(String fallback)
Provides the URL path part.
|
int |
getPort(int fallback)
Provides the URL port part.
|
String |
getProtocol(String fallback)
Provides the type of protocol (aka scheme like "sftp").
|
String |
getRootURI()
Assembles the root URI which can be used for VFS resolves etc.
|
String |
getRootURI(String username,
String password)
Assembles the root URI which can be used for VFS resolves etc.
|
boolean |
getSavePassword(boolean save)
Provides the info if the password should be remembered.
|
Properties |
getSettings()
Provides access to the internal cache of settings (driver parameters, expert settings).
|
static String |
getUniqueConnectionID(Vector<VFSConnection> connections)
Provides the next connection identifier unique for this instance.
|
String |
getURI()
Assembles the URI which can be used for VFS resolves etc.
|
String |
getURI(String username,
String password)
Assembles the URI which can be used for VFS resolves etc.
|
String |
getURIHost()
Convenience to get the host/IP address represented by this connection.
|
String |
getUser(String fallback)
Provides the URL user part.
|
boolean |
hasFileSystemOptions()
Any file system specific options for this connection available (internal cache not empty)?
|
boolean |
hasSettings()
Provides the info if the internal settings cache is not empty.
|
boolean |
isApplicable(String url,
boolean compareuser)
Checks if the given entry can be processed/listed by this connection instance.
|
boolean |
isAvailable()
Convenience method to get the info if the underlying VFS scheme is available.
|
boolean |
isConnected()
Provides the info if this connection is currently alive.
|
boolean |
isReachable()
Provides the info if the connection host can be reached (connection test).
|
String |
isValid(Vector<VFSConnection> connections)
Provides the info if this connection is configured properly and can therefore be used.
|
void |
setFileSystemOptions(org.apache.commons.vfs2.FileSystemOptions options)
The file system specific options for this connection.
|
void |
setName(String value)
Sets the connection name.
|
void |
setPassword(String password)
Sets the URL password part.
|
void |
setProtocol(String value)
Sets the type of protocol (aka scheme like "sftp").
|
void |
setSavePassword(boolean save)
Sets the info if the password should be remembered.
|
void |
setUser(String user)
Sets the URL user part.
|
String |
toString()
Provides the characteristic textual representation of this connection (identifier).
|
public static final String VAR_CONNECTION_ID
String
).public static final String VAR_CONNECTION_NAME
String
).public static final String VAR_PROTOCOL
String
).public static final String VAR_EXPERT_MAX_WAIT
boolean
).public static final String VAR_EXPERT_MAX_WAIT_SECONDS
int
).public static final String VAR_EXPERT_KEEP_ALIVE
boolean
).public static final String VAR_EXPERT_KEEP_ALIVE_SECONDS
int
).public static final String VAR_EXPERT_KEEP_ALIVE_PING
boolean
).public static final String VAR_EXPERT_KEEP_ALIVE_RESOLVE
boolean
).public static final String VAR_EXPERT_DISPLAY_BEFORE
boolean
).public static final String VAR_EXPERT_ENCODING
String
).public static final String PARAM_HOST
String
).public static final String PARAM_PORT
int
).public static final String PARAM_PATH
String
).public static final String PARAM_USER
String
).public static final String PARAM_USER_PASSWORD
String
).public static final String PARAM_SAVE_PASSWORD
boolean
)?public VFSConnection() throws InstantiationException
InstantiationException
- Error indicationpublic VFSConnection(VFSFileSystemManager vfsmanager, String id)
vfsmanager
- The file system managerid
- The unique connection identifierNullPointerException
- If parameter is null
public VFSConnection(VFSFileSystemManager vfsmanager, String id, Properties props, org.apache.commons.vfs2.FileSystemOptions options)
vfsmanager
- The file system managerid
- The unique connection identifierprops
- The container, empty is OKoptions
- Scheme specific options like FtpFileSystemConfigBuilder.getInstance().setPassiveMode()
NullPointerException
- If parameter is null
public VFSFileSystemManager getFileSystemManager()
public org.apache.commons.vfs2.FileSystemOptions getFileSystemOptions()
null
public void setFileSystemOptions(org.apache.commons.vfs2.FileSystemOptions options)
options
- The options, may be emptypublic boolean hasFileSystemOptions()
public boolean isAvailable()
Availability here means if the VFS driver is available on the classpath.
public String getID(String fallback)
fallback
- The default valuenull
public String getName(String fallback)
fallback
- The default valuenull
public void setName(String value)
value
- The connection name, removed if null
public String getProtocol(String fallback)
fallback
- The default valuenull
public void setProtocol(String value)
value
- The protocol, removed if null
public boolean getMaxWait(boolean fallback)
fallback
- The default valuepublic int getMaxWaitSeconds(int fallback)
fallback
- The default valuepublic boolean getKeepAlive(boolean fallback)
fallback
- The default valuepublic int getKeepAliveSeconds(int fallback)
fallback
- The default valuepublic boolean getKeepAlivePing(boolean fallback)
fallback
- The default valuepublic boolean getKeepAliveResolve(boolean fallback)
fallback
- The default valuepublic boolean getDisplayBefore(boolean fallback)
fallback
- The default valuepublic String getEncoding(String fallback)
fallback
- The default valuepublic String getHost(String fallback)
fallback
- The default valuenull
public int getPort(int fallback)
fallback
- The default valuenull
public String getPath(String fallback)
fallback
- The default valuenull
public String getUser(String fallback)
fallback
- The default valuenull
public void setUser(String user)
user
- The user namepublic String getPassword(String fallback)
fallback
- The default valuenull
public void setPassword(String password)
password
- The user passwordpublic boolean getSavePassword(boolean save)
save
- The default valuepublic void setSavePassword(boolean save)
save
- Remember?public Properties getSettings()
public boolean hasSettings()
public static String getUniqueConnectionID(Vector<VFSConnection> connections)
connections
- The container holding the IDs in usepublic static VFSConnection createConnection(VFSFileSystemManager vfsmanager, String protocol, String id)
vfsmanager
- The file system managerprotocol
- VFS scheme like "sftp"id
- The unique identifiernull
indicates errorpublic static VFSConnection createConnection(VFSFileSystemManager vfsmanager, String protocol, String id, Properties config, org.apache.commons.vfs2.FileSystemOptions options)
vfsmanager
- The file system managerprotocol
- VFS scheme like "sftp"id
- The unique identifierconfig
- The settings to useoptions
- Scheme specific options like FtpFileSystemConfigBuilder.getInstance().setPassiveMode()
null
indicates errorpublic String toString()
public boolean isConnected()
public String getURIHost()
null
public String isValid(Vector<VFSConnection> connections)
For cloud file systems an access token must be well-known. Although the user name is just for display here we have to make sure it is unique for each scheme (do not mix up pool connections!). Also the connection name must be unique for the same reasons.
connections
- The other connections (optional)public boolean isReachable()
public VFSConnection clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
- If cloning is not supportedpublic String getURI()
null
indicates errorpublic String getURI(String username, String password)
username
- The login name, use connection credentials otherwisepassword
- The password, use connection credentials otherwisenull
indicates errorpublic String getRootURI()
null
indicates errorpublic String getRootURI(String username, String password)
username
- The login name, use connection credentials otherwisepassword
- The password, use connection credentials otherwisenull
indicates errorpublic String getDisplayURI()
null
indicates errorpublic boolean isApplicable(String url, boolean compareuser)
url
- The network file/directorycompareuser
- Compare user info?public static org.apache.commons.vfs2.FileSystemOptions getDefaultFileSystemOptions(String scheme, String encoding)
Here, all scheme specific options are being preconfigured that are supported by the dialog protocol panels.
scheme
- The protocol/scheme like "sftp"encoding
- The encoding like UTF-8 (optional)NullPointerException
- If parameter is null
public boolean checkUniqueUser(Vector<VFSConnection> connections)
connections
- The other connectionsNullPointerException
- If a parameter is null
public boolean checkUniqueName(Vector<VFSConnection> connections)
connections
- The other connectionsNullPointerException
- If a parameter is null
public static boolean elementOf(Object object, Object array)
object
- The object to be checkedarray
- The array to check againstNullPointerException
- If object and/or array is null
Copyright © 2005-2024 Leisenfels GmbH. All rights reserved.