|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.stanbol.enhancer.servicesapi.helper.ConfigUtils
public final class ConfigUtils
Utility Class with methods allowing to parse line based configurations formatted
like:
Rules:
<key1>;<parm1>=<value1>,<value2>;<parm2>=<value1>...
<key2>;<state>
<key3>;<state>=true
<key4>;<parm1>=<value1>;<parm1>=<value2>
null)
This is intended to be used to parse richer configurations form OSGI configuration files.
| Method Summary | |
|---|---|
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getParameters(java.lang.String[] elements,
int start)
Utility that parses 'key=value,value2' parameters from the parsed array. |
static boolean |
getState(java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters,
java.lang.String key)
Parses the boolean value form the values for the parsed key. |
static java.lang.String |
getValue(java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters,
java.lang.String key)
Getter for the first value of a given key |
static java.lang.String |
guessRdfFormat(java.lang.String extension)
Guesses the RDF format based on the provided file extension. |
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> |
parseConfig(java.lang.Iterable<java.lang.String> configuration)
Parses configurations formatted like |
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> |
parseConfig(java.util.Iterator<java.lang.String> confIterator)
Parses configurations formatted like |
static java.util.Map.Entry<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> |
parseConfigEntry(java.lang.String line)
Returns the "key, parameter" entry parsed form the parsed configuration line. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.String guessRdfFormat(java.lang.String extension)
null will return the default format.
extension - the extension or null to ask for the default
null if the parsed extension is not
known.public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> parseConfig(java.lang.Iterable<java.lang.String> configuration)
<key1>;<parm1>=<value1>,<value2>;<parm2>=<value1>...
<key2>;<state>
<key3>;<state>=true
<key4>;<parm1>=<value1>;<parm1>=<value2>
Rules:null)
configuration - The configuration
java.lang.IllegalArgumentException - on any syntax error in the parsed
configurationpublic static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> parseConfig(java.util.Iterator<java.lang.String> confIterator)
<key1>;<parm1>=<value1>,<value2>;<parm2>=<value1>...
<key2>;<state>
<key3>;<state>=true
<key4>;<parm1>=<value1>;<parm1>=<value2>
Rules:null)
confIterator - The Iterator over the lines of the configuration.
java.lang.IllegalArgumentException - on any syntax error in the parsed
configurationpublic static java.util.Map.Entry<java.lang.String,java.util.Map<java.lang.String,java.util.List<java.lang.String>>> parseConfigEntry(java.lang.String line)
This method is useful if the caller need to preserve the oder of multi line configurations and therefore can not use the parseConfig methods.
line - a configuration line
public static boolean getState(java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters,
java.lang.String key)
true if the key is present and the
value is either an empty list of the first element of the list evaluates
to Boolean.parseBoolean(String) == true.
parameters - the parameterkey - the key
public static java.lang.String getValue(java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters,
java.lang.String key)
parameters - the parameterskey - the key
null if the key is not present
or the list is empty.
public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getParameters(java.lang.String[] elements,
int start)
elements - the elementsstart - the start position within the parsed array to start parsing
null but en empty list. The
returned Map provides read and write access.
IllegalArgumentExeption - if elements are illegal formatted (e.g.
if the start with an '='
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||