Package org.freedesktop.dbus.connections
Class BusAddress
- java.lang.Object
-
- org.freedesktop.dbus.connections.BusAddress
-
- Direct Known Subclasses:
JnrUnixBusAddress,TcpBusAddress
public class BusAddress extends java.lang.ObjectDefines an address to connect to DBus. The address will define which transport to use.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.LoggerLOGGERprivate java.util.Map<java.lang.String,java.lang.String>parametersprivate java.lang.Stringtype
-
Constructor Summary
Constructors Modifier Constructor Description BusAddress(java.lang.String _address)Deprecated, for removal: This API element is subject to removal in a future version.Use BusAddress.of insteadprotectedBusAddress(BusAddress _obj)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BusAddressaddParameter(java.lang.String _parameter, java.lang.String _value)Add a parameter to the address.java.lang.StringgetBusType()Returns the transport type in uppercase.java.lang.StringgetGuid()BusAddressgetListenerAddress()Creates a listening BusAddress if this instance is not already listening.java.util.Map<java.lang.String,java.lang.String>getParameters()Deprecated, for removal: This API element is subject to removal in a future version.will be removed in future, usegetParameterValue(String)orhasParameter(String)java.lang.StringgetParameterValue(java.lang.String _parameter)Returns a the value of the given parameter.java.lang.StringgetParameterValue(java.lang.String _parameter, java.lang.String _default)Returns a the value of the given parameter.java.lang.StringgetRawAddress()Deprecated, for removal: This API element is subject to removal in a future version.usetoString()java.lang.StringgetType()Returns the transport type as found in the address.booleanhasParameter(java.lang.String _parameter)Checks if the given parameter is present.booleanisBusType(java.lang.String _type)Checks if thisBusAddressis for the given bus type.
The given type will be compared case-insensitive.booleanisListeningSocket()True if this is a listening address.booleanisServer()True if this address represents a listening server address.static BusAddressof(java.lang.String _address)Creates a newBusAddressfrom String.static BusAddressof(BusAddress _address)Creates a copy of the givenBusAddress.BusAddressremoveParameter(java.lang.String _parameter)Remove parameter with given name.java.lang.StringtoString()
-
-
-
Constructor Detail
-
BusAddress
@Deprecated(forRemoval=true, since="4.2.0 - 2022-07-18") public BusAddress(java.lang.String _address) throws DBusExceptionDeprecated, for removal: This API element is subject to removal in a future version.Use BusAddress.of insteadCreates a new instance from String.- Parameters:
_address- address String- Throws:
DBusException
-
BusAddress
protected BusAddress(BusAddress _obj)
-
-
Method Detail
-
of
public static BusAddress of(BusAddress _address)
Creates a copy of the givenBusAddress. If given address is null, an emptyBusAddressobject is created.- Parameters:
_address- address to copy- Returns:
- BusAddress
- Since:
- 4.2.0 - 2022-07-18
-
of
public static BusAddress of(java.lang.String _address)
Creates a newBusAddressfrom String.- Parameters:
_address- address String, never null or empty- Returns:
- BusAddress
- Since:
- 4.2.0 - 2022-07-18
-
getType
public java.lang.String getType()
Returns the transport type as found in the address.- Returns:
- type
-
getBusType
public java.lang.String getBusType()
Returns the transport type in uppercase.- Returns:
- type
-
isBusType
public boolean isBusType(java.lang.String _type)
Checks if thisBusAddressis for the given bus type.
The given type will be compared case-insensitive.
e.g.isBusType("unix");- Parameters:
_type- to compare- Returns:
- true if same type (case-insensitive), false if null or not same type
- Since:
- 4.2.0 - 2022-07-20
-
isListeningSocket
public boolean isListeningSocket()
True if this is a listening address.- Returns:
- true if listening
-
getGuid
public java.lang.String getGuid()
-
getRawAddress
@Deprecated(forRemoval=true, since="4.2.0 - 2022-07-18") public java.lang.String getRawAddress()Deprecated, for removal: This API element is subject to removal in a future version.usetoString()String version of the BusAddress.- Returns:
- String
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isServer
public boolean isServer()
True if this address represents a listening server address.- Returns:
- true if server
-
addParameter
public BusAddress addParameter(java.lang.String _parameter, java.lang.String _value)
Add a parameter to the address. Adding multiple parameters with same name is not possible and will overwrite previous values.- Parameters:
_parameter- parameter name_value- value- Returns:
- this
- Since:
- 4.2.0 - 2022-07-18
-
removeParameter
public BusAddress removeParameter(java.lang.String _parameter)
Remove parameter with given name. If parameter does not exists, nothing will happen.- Parameters:
_parameter- parameter to remove- Returns:
- this
- Since:
- 4.2.0 - 2022-07-18
-
hasParameter
public boolean hasParameter(java.lang.String _parameter)
Checks if the given parameter is present.- Parameters:
_parameter- parameter to check- Returns:
- true if parameter exists, false otherwise
- Since:
- 4.2.2 - 2023-01-11
-
getParameters
@Deprecated(forRemoval=true, since="4.2.2 - 2023-01-11") public java.util.Map<java.lang.String,java.lang.String> getParameters()Deprecated, for removal: This API element is subject to removal in a future version.will be removed in future, usegetParameterValue(String)orhasParameter(String)Returns a read-only view of the parameters currently configured.- Returns:
- Map, maybe empty
- Since:
- 4.2.0 - 2022-07-18
-
getParameterValue
public java.lang.String getParameterValue(java.lang.String _parameter)
Returns a the value of the given parameter.When no value present,
nullis returned.- Parameters:
_parameter- parameter to get value for- Returns:
- String or
null - Since:
- 4.2.0 - 2022-07-19
-
getParameterValue
public java.lang.String getParameterValue(java.lang.String _parameter, java.lang.String _default)Returns a the value of the given parameter.When no value present, the given default is returned.
- Parameters:
_parameter- parameter to get value for_default- default to return if parameter not set- Returns:
- String or default
- Since:
- 4.2.2 - 2023-01-11
-
getListenerAddress
public BusAddress getListenerAddress()
Creates a listening BusAddress if this instance is not already listening.- Returns:
- new BusAddress or this
- Since:
- 4.2.0 - 2022-07-18
-
-