Class ConnectionsBuilder


  • public class ConnectionsBuilder
    extends Object
    Assists in building a SmartInspect connections string.

    The ConnectionsBuilder class assists in creating connections strings as used by the SmartInspect.setConnections method. To get started, please have a look at the following example. For information about connections strings, please refer to the SmartInspect.setConnections method.

    This class is not guaranteed to be threadsafe.

     Usage:
       ConnectionsBuilder builder = new ConnectionsBuilder();
       builder.beginProtocol("file");
       builder.addOption("filename", "log.sil");
       builder.addOption("append", true);
       builder.endProtocol();
       SiAuto.si.setConnections(builder.getConnections());
     
    • Constructor Detail

      • ConnectionsBuilder

        public ConnectionsBuilder()
        Creates and initializes a ConnectionsBuilder instance.
    • Method Detail

      • clear

        public void clear()
        Clears this ConnectionsBuilder instance by removing all protocols and their options.

        After this method has been called, the getConnections method returns an empty string.

      • beginProtocol

        public void beginProtocol​(String protocol)
        Begins a new protocol section.

        This method begins a new protocol with the supplied name. All subsequent protocol options are added to this protocol until the new protocol section is closed by calling the endProtocol method.

        Parameters:
        protocol - The name of the new protocol.
        Throws:
        NullPointerException - If the protocol argument is null.
      • endProtocol

        public void endProtocol()
        Ends the current protocol section.

        This method ends the current protocol. To begin a new protocol section, use the beginProtocol method.

      • addOption

        public void addOption​(String key,
                              String value)
        Overloaded method. Adds a new string option to the current protocol section.

        This method adds a new string option to the current protocol section. The supplied value argument is properly escaped if necessary.

        Parameters:
        key - The key of the new option.
        value - The value of the new option.
        Throws:
        NullPointerException - if the key or value argument is null.
      • addOption

        public void addOption​(String key,
                              boolean value)
        This method adds a new boolean option to the current protocol section.
        Parameters:
        key - The key of the new option.
        value - The value of the new option.
        Throws:
        NullPointerException - if the key argument is null
      • addOption

        public void addOption​(String key,
                              int value)
        Adds a new integer option to the current protocol section.

        This method adds a new integer option to the current protocol section.

        Parameters:
        key - The key of the new option.
        value - The value of the new option.
        Throws:
        NullPointerException - If the key argument is null.
      • addOption

        public void addOption​(String key,
                              Level value)
        Overloaded method. This method adds a new Level option to the current protocol section.
        Parameters:
        key - The key of the new option.
        value - The value of the new option.
        Throws:
        NullPointerException - if the key or value argument is null.
      • addOption

        public void addOption​(String key,
                              FileRotate value)
        Overloaded method. Adds a new FileRotate option to the current protocol section.

        This method adds a new FileRotate option to the current protocol section.

        Parameters:
        key - The key of the new option.
        value - The value of the new option.
        Throws:
        NullPointerException - if The key or value argument is null.
      • getConnections

        public String getConnections()
        Returns the built connections string.

        This method returns the connections string which has previously been built with the beginProtocol, addOption and endProtocol methods.

        Returns:
        The built connections string.