public class ConnectionsBuilder extends Object
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 and Description |
|---|
ConnectionsBuilder()
Creates and initializes a ConnectionsBuilder instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addOption(String key,
boolean value)
This method adds a new boolean option to the current protocol section.
|
void |
addOption(String key,
FileRotate value)
Overloaded method.
|
void |
addOption(String key,
int value)
Adds a new integer option to the current protocol
section.
|
void |
addOption(String key,
Level value)
Overloaded method.
|
void |
addOption(String key,
String value)
Overloaded method.
|
void |
beginProtocol(String protocol)
Begins a new protocol section.
|
void |
clear()
Clears this ConnectionsBuilder instance by removing all protocols
and their options.
|
void |
endProtocol()
Ends the current protocol section.
|
String |
getConnections()
Returns the built connections string.
|
public ConnectionsBuilder()
public void clear()
After this method has been called, the getConnections method returns an empty string.
public void beginProtocol(String protocol)
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.
protocol - The name of the new protocol.NullPointerException - If the protocol argument is null.public void endProtocol()
This method ends the current protocol. To begin a new protocol section, use the beginProtocol method.
public void addOption(String key, String value)
This method adds a new string option to the current protocol section. The supplied value argument is properly escaped if necessary.
key - The key of the new option.value - The value of the new option.NullPointerException - if the key or value argument is null.public void addOption(String key, boolean value)
key - The key of the new option.value - The value of the new option.NullPointerException - if the key argument is nullpublic void addOption(String key, int value)
This method adds a new integer option to the current protocol section.
key - The key of the new option.value - The value of the new option.NullPointerException - If the key argument is null.public void addOption(String key, Level value)
key - The key of the new option.value - The value of the new option.NullPointerException - if the key or value argument is null.public void addOption(String key, FileRotate value)
This method adds a new FileRotate option to the current protocol section.
key - The key of the new option.value - The value of the new option.NullPointerException - if The key or value argument is null.public String getConnections()
This method returns the connections string which has previously been built with the beginProtocol, addOption and endProtocol methods.
Copyright © 2023. All rights reserved.