Top Description Fields Constructors Methods
com.mysql.cj.conf

public Class HostInfo

extends Object
implements DatabaseUrlContainer
Class Inheritance
All Implemented Interfaces
com.mysql.cj.conf.DatabaseUrlContainer
Static Imports
com.mysql.cj.util.StringUtils.isNullOrEmpty

This class holds the following MySQL host information:

Field Summary

Modifier and TypeField and Description
private final String
private static final String
private final Map<String, String>
public static final int
private final DatabaseUrlContainer
private final String
private final int
private final String

Constructor Summary

AccessConstructor and Description
public
HostInfo()

Constructs an empty HostInfo instance.

public
HostInfo(DatabaseUrlContainer
a reference to the original database URL that produced this host info
url
,
String
the host ip or name
host
,
int
the port
port
,
String
the user name
user
,
String
the user's password
password
)

Constructs a HostInfo instance initialized with the provided host, port and user info.

public
HostInfo(DatabaseUrlContainer
a reference to the original database URL that produced this host info
url
,
String
the host ip or name
host
,
int
the port
port
,
String
the user name
user
,
String
this user's password
password
,
Map<String, String>
a connection arguments map.
properties
)

Constructs a HostInfo instance initialized with the provided host, port, user, password and connection arguments.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if both objects have equal host and port pairs, false otherwise.
equalHostPortPair
(HostInfo
the HostInfo to compare with.
hi
)

Checks if this HostInfo has the same host and port pair as the given HostInfo.

public Properties

Returns:

a Properties instance containing the full host information.
exposeAsProperties
()

Exposes this host info as a single properties instance.

public String

Returns:

the database name
getDatabase
()

Shortcut to the database connection argument.

public String

Returns:

the original database URL
getDatabaseUrl
()

Implements com.mysql.cj.conf.DatabaseUrlContainer.getDatabaseUrl.

Returns the original database URL that produced this host info.

public String

Returns:

the host
getHost
()

Returns the host.

public String

Returns:

the host:port representation of this host
getHostPortPair
()

Returns a host:port representation of this host.

public Map<String, String>

Returns:

this host specific properties
getHostProperties
()

Returns the properties specific to this host.

public String

Returns:

the password
getPassword
()

Returns the password.

public int

Returns:

the port
getPort
()

Returns the port.

public String

Returns:

the connection argument for the given key
getProperty
(String
key
key
)

Returns the connection argument for the given key.

public String

Returns:

the user name
getUser
()

Returns the user name.

public String

Returns:

a string representation of this object
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

hostback to summary
private final String host
HOST_PORT_SEPARATORback to summary
private static final String HOST_PORT_SEPARATOR
hostPropertiesback to summary
private final Map<String, String> hostProperties
NO_PORTback to summary
public static final int NO_PORT
originalUrlback to summary
private final DatabaseUrlContainer originalUrl
passwordback to summary
private final String password
portback to summary
private final int port
userback to summary
private final String user

Constructor Detail

HostInfoback to summary
public HostInfo()

Constructs an empty HostInfo instance.

HostInfoback to summary
public HostInfo(DatabaseUrlContainer url, String host, int port, String user, String password)

Constructs a HostInfo instance initialized with the provided host, port and user info.

Parameters
url:DatabaseUrlContainer

a reference to the original database URL that produced this host info

host:String

the host ip or name

port:int

the port

user:String

the user name

password:String

the user's password

HostInfoback to summary
public HostInfo(DatabaseUrlContainer url, String host, int port, String user, String password, Map<String, String> properties)

Constructs a HostInfo instance initialized with the provided host, port, user, password and connection arguments.

Parameters
url:DatabaseUrlContainer

a reference to the original database URL that produced this host info

host:String

the host ip or name

port:int

the port

user:String

the user name

password:String

this user's password

properties:Map<String, String>

a connection arguments map.

Method Detail

equalHostPortPairback to summary
public boolean equalHostPortPair(HostInfo hi)

Checks if this HostInfo has the same host and port pair as the given HostInfo.

Parameters
hi:HostInfo

the HostInfo to compare with.

Returns:boolean

true if both objects have equal host and port pairs, false otherwise.

exposeAsPropertiesback to summary
public Properties exposeAsProperties()

Exposes this host info as a single properties instance. The values for host, port, user and password are added to the properties map with their standard keys.

Returns:Properties

a Properties instance containing the full host information.

getDatabaseback to summary
public String getDatabase()

Shortcut to the database connection argument.

Returns:String

the database name

getDatabaseUrlback to summary
public String getDatabaseUrl()

Implements com.mysql.cj.conf.DatabaseUrlContainer.getDatabaseUrl.

Returns the original database URL that produced this host info.

Returns:String

the original database URL

Annotations
@Override
getHostback to summary
public String getHost()

Returns the host.

Returns:String

the host

getHostPortPairback to summary
public String getHostPortPair()

Returns a host:port representation of this host.

Returns:String

the host:port representation of this host

getHostPropertiesback to summary
public Map<String, String> getHostProperties()

Returns the properties specific to this host.

Returns:Map<String, String>

this host specific properties

getPasswordback to summary
public String getPassword()

Returns the password.

Returns:String

the password

getPortback to summary
public int getPort()

Returns the port.

Returns:int

the port

getPropertyback to summary
public String getProperty(String key)

Returns the connection argument for the given key.

Parameters
key:String

key

Returns:String

the connection argument for the given key

getUserback to summary
public String getUser()

Returns the user name.

Returns:String

the user name

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this object.

Returns:String

a string representation of this object

Annotations
@Override