|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zanata.client.config.ConfigUtil
public class ConfigUtil
| Constructor Summary | |
|---|---|
ConfigUtil()
|
|
| Method Summary | |
|---|---|
static String |
findPrefix(org.apache.commons.configuration.SubnodeConfiguration config,
URL url)
Finds the key prefix, within an ini subnode (eg [servers]) with the specified url. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConfigUtil()
| Method Detail |
|---|
public static String findPrefix(org.apache.commons.configuration.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 -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||