public class ConfigUtil extends Object
Constructor and Description |
---|
ConfigUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
findPrefix(SubnodeConfiguration config,
URL url)
Finds the key prefix, within an ini subnode (eg [servers]) with the
specified url.
|
public static String findPrefix(SubnodeConfiguration config, URL url)
If the ini contains:
[servers] a.username=alice a.url=http://a.example.com b.username=bob b.url=http://b.example.comthen the code
servers = config.getSection("servers"); String prefix = findPrefix(servers, new URL("http://b.example.com")) String username = servers.getString(prefix+".username");will return "bob";
Due to an anomaly/bug in the current version of Apache Commons
Configuration's iterator, the returned prefix is actually "b." (with a
dot), and the runtime key for "b.url" is actually "b..url". Fortunately
the config.get* commands are consistent with this, so if you reference
servers.getString(prefix+".username")
the value "bob" will
be returned anyway.
config
- url
- Copyright © 2017 Zanata Project. All rights reserved.