Example usage for org.apache.commons.configuration DataConfiguration getURL

List of usage examples for org.apache.commons.configuration DataConfiguration getURL

Introduction

In this page you can find the example usage for org.apache.commons.configuration DataConfiguration getURL.

Prototype

public URL getURL(String key, URL defaultValue) 

Source Link

Document

Get an URL associated with the given configuration key.

Usage

From source file:gda.configuration.properties.JakartaPropertiesConfig.java

@Override
public URL getURL(String name, URL defaultValue) {
    // Use decorator, which can convert to URLs, Locales, Dates, Colours,
    // etc.//from w w  w.  j a  v  a  2  s. c om
    DataConfiguration dataConfig = new DataConfiguration(config);

    return dataConfig.getURL(name, defaultValue);
}

From source file:org.davidmason.zayf.config.ConfigLoader.java

private List<ServerInfo> findServerInfoByPrefixes(DataConfiguration serverConfig, List<String> prefixes) {
    List<ServerInfo> servers = new ArrayList<ServerInfo>();
    for (String prefix : prefixes) {
        String urlKey = prefix + URL_KEY_SUFFIX;
        String userNameKey = prefix + USER_NAME_SUFFIX;
        String apiKeyKey = prefix + API_KEY_SUFFIX;
        ServerInfo server = new ServerInfo(prefix, serverConfig.getURL(urlKey, null),
                serverConfig.getString(userNameKey, null), serverConfig.getString(apiKeyKey, null));
        servers.add(server);// ww  w. ja  v  a2 s .  c o  m
    }
    return servers;
}

From source file:org.davidmason.zayf.rest.ServerProxyImpl.java

private List<ServerInfo> getServerList(DataConfiguration serverConfig) {
    List<String> prefixes = new ArrayList<String>();
    Iterator<String> iter = serverConfig.getKeys();
    // TODO log.debug
    System.out.print("Keys: ");
    while (iter.hasNext()) {
        String key = iter.next();
        // TODO log.debug
        System.out.print(key + " ");
        if (key.endsWith(urlKeySuffix)) {
            String prefix = key.substring(0, key.length() - urlKeySuffix.length());
            if (!prefix.isEmpty()) {
                prefixes.add(prefix);/*from  w w w  .ja v  a2s . c om*/
            }
        }
    }
    // TODO log.debug
    System.out.println();

    List<ServerInfo> servers = new ArrayList<ServerInfo>();
    for (String prefix : prefixes) {
        String urlKey = prefix + urlKeySuffix;
        String userNameKey = prefix + userNameSuffix;
        String apiKeyKey = prefix + apiKeyKeySuffix;
        // TODO log.debug
        System.out.println("urlKey: " + urlKey + " userNameKey: " + userNameKey + " apiKeyKey: " + apiKeyKey);
        ServerInfo server = new ServerInfo(prefix, serverConfig.getURL(urlKey, null),
                serverConfig.getString(userNameKey, null), serverConfig.getString(apiKeyKey, null));
        servers.add(server);
    }

    return servers;
}