public class ConnectHelper
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 java.util.logging.Logger |
LOG
Logger
|
Constructor and Description |
---|
ConnectHelper() |
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 void |
main(java.lang.String[] args)
Test the quote removal processing.
|
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.
|
static java.util.Map<java.lang.String,java.lang.String> |
readPfFile(java.lang.String file)
Read the parameters configured in the given file.
|
private static java.lang.String |
removeEnclosingQuotes(java.lang.String txt)
Remove matched pairs of enclosing single or double quote characters from the given string
and return the result.
|
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.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.public static java.util.Map<java.lang.String,java.lang.String> readPfFile(java.lang.String file)
file
- The file containing the parameters.null
if there were
problems reading the file.private static java.lang.String removeEnclosingQuotes(java.lang.String txt)
txt
- Text to clean up.public static void main(java.lang.String[] args)
args
- Ignored.