Class ProtocolVariables
- java.lang.Object
-
- com.gurock.smartinspect.protocols.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 Summary
Constructors Constructor Description ProtocolVariables()Creates and initializes a ProtocolVariables instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String key, String value)Adds a new element with a specified key and value to the set of connection variables.voidclear()Removes all key/value pairs of the collection.booleancontains(String key)Tests if the collection contains a value for a given key.Stringexpand(String connections)Expands and returns a connections string.Stringget(String key)Returns a value of an element for a given key.intgetCount()Returns the number of key/value pairs of this collection.voidput(String key, String value)Adds or updates an element with a specified key and value to the set of connection variables.voidremove(String key)Removes an existing element with a given key from this set of connection variables.
-
-
-
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 elementvalue- 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 elementvalue- 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
-
-