java.lang.Object
org.miaixz.bus.extra.ssh.Connector
Represents a connector object that provides basic connection information for services like SSH, FTP, etc. This class
encapsulates the following details:
- host: The hostname or IP address of the server.
- port: The port number for the connection.
- user: The username for authentication (defaults to "root").
- password: The password for authentication.
- timeout: The connection timeout in milliseconds.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetHost()Retrieves the hostname or IP address of the server.Retrieves the password for authentication.intgetPort()Retrieves the port number for the connection.longRetrieves the connection timeout duration in milliseconds.getUser()Retrieves the username for authentication.static Connectorof()Creates a newConnectorinstance with default parameters.static ConnectorCreates a newConnectorinstance with specified host, port, user, and password.static ConnectorCreates a newConnectorinstance with specified host, port, user, password, and timeout.Sets the hostname or IP address of the server.setPassword(String password) Sets the password for authentication.setPort(int port) Sets the port number for the connection.setTimeout(long timeout) Sets the connection timeout duration in milliseconds.Sets the username for authentication.toString()Returns a string representation of the connector object.
-
Constructor Details
-
Connector
public Connector()Constructs a new, emptyConnectorinstance. -
Connector
Constructs a newConnectorinstance with specified host, port, user, password, and timeout.- Parameters:
host- The hostname or IP address of the server.port- The port number for the connection.user- The username for authentication.password- The password for authentication.timeout- The connection timeout duration in milliseconds; a value of 0 may indicate the default timeout.
-
-
Method Details
-
of
Creates a newConnectorinstance with default parameters. This is useful for a builder-style pattern of object creation.- Returns:
- A new, empty
Connectorinstance.
-
of
Creates a newConnectorinstance with specified host, port, user, and password. The timeout is set to its default value (0).- Parameters:
host- The hostname or IP address of the server.port- The port number for the connection.user- The username for authentication.password- The password for authentication.- Returns:
- A new
Connectorinstance initialized with the provided details.
-
of
Creates a newConnectorinstance with specified host, port, user, password, and timeout.- Parameters:
host- The hostname or IP address of the server.port- The port number for the connection.user- The username for authentication.password- The password for authentication.timeout- The connection timeout duration in milliseconds; a value of 0 may indicate the default timeout.- Returns:
- A new
Connectorinstance initialized with the provided details.
-
getHost
Retrieves the hostname or IP address of the server.- Returns:
- The hostname as a
String.
-
setHost
Sets the hostname or IP address of the server.- Parameters:
host- The hostname to set.- Returns:
- This
Connectorinstance, allowing for method chaining.
-
getPort
public int getPort()Retrieves the port number for the connection.- Returns:
- The port number.
-
setPort
Sets the port number for the connection.- Parameters:
port- The port number to set.- Returns:
- This
Connectorinstance, allowing for method chaining.
-
getUser
Retrieves the username for authentication.- Returns:
- The username as a
String.
-
setUser
Sets the username for authentication.- Parameters:
name- The username to set.- Returns:
- This
Connectorinstance, allowing for method chaining.
-
getPassword
Retrieves the password for authentication.- Returns:
- The password as a
String.
-
setPassword
Sets the password for authentication.- Parameters:
password- The password to set.- Returns:
- This
Connectorinstance, allowing for method chaining.
-
getTimeout
public long getTimeout()Retrieves the connection timeout duration in milliseconds.- Returns:
- The connection timeout duration.
-
setTimeout
Sets the connection timeout duration in milliseconds.- Parameters:
timeout- The connection timeout duration to set.- Returns:
- This
Connectorinstance, allowing for method chaining.
-
toString
Returns a string representation of the connector object. This method is intended for logging and debugging purposes only.
-