public class ServerConnectHelper
extends java.lang.Object
parseOptions(com.goldencode.p2j.util.character, java.util.Set<java.lang.String>, java.util.Set<java.lang.String>, java.util.Map<java.lang.String, java.lang.Integer>); using the list of
valid options, this will be able to identify no-value options (which act like flags) and also
options which must receive an int value.
The -pf file option can be used to read a set of options from a file, and override
any existing ones.
| Modifier and Type | Field and Description |
|---|---|
private static CentralLogger |
LOG
Logger
|
| Constructor and Description |
|---|
ServerConnectHelper() |
| Modifier and Type | Method and Description |
|---|---|
static int |
getInt(java.util.Map<java.lang.String,java.lang.String> parms,
java.lang.String key,
int def)
Parse the value for the specified key as an int, or default to the specified value if the
key does not exist.
|
static java.lang.String |
getString(java.util.Map<java.lang.String,java.lang.String> parms,
java.lang.String key,
java.lang.String def)
Get a string from the parameters map, using the specified key and defaulting to the
specified value, if it does not exist.
|
static java.util.Map<java.lang.String,java.lang.String> |
parseOptions(character options,
java.util.Set<java.lang.String> knownOptions,
java.util.Set<java.lang.String> noValueOptions,
java.util.Map<java.lang.String,java.lang.Integer> intOptions)
Parse and validate the given options; a map is returned with each parameters's value.
|
private static void |
parseOptions(java.lang.String options,
java.util.Set<java.lang.String> knownOptions,
java.util.Set<java.lang.String> noValueOptions,
java.util.Map<java.lang.String,java.lang.Integer> intOptions,
java.util.Map<java.lang.String,java.lang.String> params)
Parse and validate the given options; a map is returned with each parameters's value.
|
private static java.util.Map<java.lang.String,java.lang.String> |
readPfFile(java.lang.String file,
java.util.Set<java.lang.String> knownOptions,
java.util.Set<java.lang.String> noValueOptions,
java.util.Map<java.lang.String,java.lang.Integer> intOptions)
Read the parameters configured in the given file.
|
private static final CentralLogger LOG
public static java.util.Map<java.lang.String,java.lang.String> parseOptions(character options, java.util.Set<java.lang.String> knownOptions, java.util.Set<java.lang.String> noValueOptions, java.util.Map<java.lang.String,java.lang.Integer> intOptions)
null.options - The options from which the parameters will be extracted.knownOptions - Set of valid options.noValueOptions - Set of options which require no argument, i.e. "flags".intOptions - Set of options which requre an int argument.private static void parseOptions(java.lang.String options,
java.util.Set<java.lang.String> knownOptions,
java.util.Set<java.lang.String> noValueOptions,
java.util.Map<java.lang.String,java.lang.Integer> intOptions,
java.util.Map<java.lang.String,java.lang.String> params)
null.options - The options from which the parameters will be extracted.knownOptions - Set of valid options.noValueOptions - Set of options which require no argument, i.e. "flags".intOptions - Set of options which require an int argument.params - The parameter-to-value map.public static int getInt(java.util.Map<java.lang.String,java.lang.String> parms,
java.lang.String key,
int def)
parms - The options map.key - The key to search.def - The default value to return if the key does not exist.public static java.lang.String getString(java.util.Map<java.lang.String,java.lang.String> parms,
java.lang.String key,
java.lang.String def)
parms - The options map.key - The key to search.def - The default value to return if the key does not exist.private static java.util.Map<java.lang.String,java.lang.String> readPfFile(java.lang.String file,
java.util.Set<java.lang.String> knownOptions,
java.util.Set<java.lang.String> noValueOptions,
java.util.Map<java.lang.String,java.lang.Integer> intOptions)
file - The file containing the parameters.knownOptions - Set of valid options.noValueOptions - Set of options which require no argument, i.e. "flags".intOptions - Set of options which requre an int argument.null if there were
problems reading the file.