Class ProtocolVariables


  • public class ProtocolVariables
    extends Object
    Manages connection variables.

    This class manages a list of connection variables. Connection variables are placeholders for strings in the connections string of the SmartInspect class. Please see SmartInspect.setVariable for more information.

    This class is fully threadsafe.

    • Constructor Detail

      • ProtocolVariables

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

      • put

        public void put​(String key,
                        String value)
        Adds or updates an element with a specified key and value to the set of connection variables. This method adds a new element with a given key and value to the set of connection variables. If an element for the given key already exists, the original element's value is updated.
        Parameters:
        key - The key of the element
        value - The value of the element
        Throws:
        NullPointerException - If the key or value argument is null
      • add

        public void add​(String key,
                        String value)
        Adds a new element with a specified key and value to the set of connection variables. This method adds a new element with a given key and value to the set of connection variables. If an element for the given key already exists, the original element's value is not updated.
        Parameters:
        key - The key of the element
        value - The value of the element
        Throws:
        NullPointerException - if the key or value argument is null
      • remove

        public void remove​(String key)
        Removes an existing element with a given key from this set of connection variables.

        This method removes the element with the given key from the internal set of connection variables. Nothing happens if no element with the given key can be found.

        Parameters:
        key - The key of the element to remove
        Throws:
        NullPointerException - If the key argument is null
      • contains

        public boolean contains​(String key)
        Tests if the collection contains a value for a given key.
        Parameters:
        key - The key to test for
        Returns:
        True if a value exists for the given key and false otherwise
        Throws:
        NullPointerException - if the key argument is null
      • clear

        public void clear()
        Removes all key/value pairs of the collection.
      • getCount

        public int getCount()
        Returns the number of key/value pairs of this collection.
        Returns:
        The number of key/value pairs of this collection
      • expand

        public String expand​(String connections)
        Expands and returns a connections string. This method replaces all variables which have previously been added to this collection (with add or put) in the given connections string with their respective values and then returns it. Variables in the connections string must have the following form: $variable$.
        Parameters:
        connections - The connections string to expand and return
        Returns:
        The expanded connections string
        Throws:
        NullPointerException - If the connections argument is null
      • get

        public String get​(String key)
        Returns a value of an element for a given key.
        Parameters:
        key - The key whose value to return
        Returns:
        Either the value for a given key if an element with the given key exists or null otherwise
        Throws:
        NullPointerException - if the key argument is null