Class BusAddress

  • Direct Known Subclasses:
    JnrUnixBusAddress, TcpBusAddress

    public class BusAddress
    extends java.lang.Object
    Defines 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.Logger LOGGER  
      private java.util.Map<java.lang.String,​java.lang.String> parameters  
      private java.lang.String type  
    • 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 instead
      protected BusAddress​(BusAddress _obj)  
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • type

        private java.lang.String type
      • parameters

        private final java.util.Map<java.lang.String,​java.lang.String> parameters
    • Constructor Detail

      • BusAddress

        @Deprecated(forRemoval=true,
                    since="4.2.0 - 2022-07-18")
        public BusAddress​(java.lang.String _address)
                   throws DBusException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use BusAddress.of instead
        Creates 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 given BusAddress. If given address is null, an empty BusAddress object 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 new BusAddress from 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 this BusAddress is 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.
        String version of the BusAddress.
        Returns:
        String
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.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, use getParameterValue(String) or hasParameter(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, null is 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