Example usage for org.apache.commons.configuration XMLConfiguration setBasePath

List of usage examples for org.apache.commons.configuration XMLConfiguration setBasePath

Introduction

In this page you can find the example usage for org.apache.commons.configuration XMLConfiguration setBasePath.

Prototype

public void setBasePath(String basePath) 

Source Link

Usage

From source file:com.bibisco.test.AllTests.java

private static XMLConfiguration getXMLConfiguration() throws ConfigurationException {

    XMLConfiguration lXMLConfiguration = null;
    lXMLConfiguration = new XMLConfiguration();
    lXMLConfiguration.setEncoding(ENCODING);
    lXMLConfiguration.setBasePath(CONFIG_DIR);
    lXMLConfiguration.load(CONFIG_FILENAME);
    lXMLConfiguration.setExpressionEngine(new XPathExpressionEngine());

    return lXMLConfiguration;
}

From source file:net.sf.tweety.cli.plugins.CliMain.java

/**
 * This method is meant to load the tweety plugin pathes on startup
 * /* ww w . j  a  va  2 s.  c  o m*/
 * @return an object with one or more pluginpathes
 * @throws ConfigurationException
 */
public static Map<String, String> configCLI() throws ConfigurationException, FileNotFoundException {

    System.out.println("Initialize CLI...");

    // TODO : exception handling for empty/erroneous configuration
    Map<String, String> loadablePlugins = new HashMap<String, String>();

    XMLConfiguration tweetyXmlConfig = new XMLConfiguration();
    File in = new File(TWEETY_CLI_DEFAULT_CONFIG);
    try {
        System.out.print("Loading Configuration...");
        String inPath = in.getAbsolutePath();
        tweetyXmlConfig
                .setBasePath(inPath.substring(0, inPath.length() - TWEETY_CLI_DEFAULT_CONFIG.length() - 1));
        tweetyXmlConfig.load(in);
        System.out.print("success.\n");
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    // map ueber "plugins.plugin" mit keys ()
    // TODO: Verhalten bei leeren Feldern pruefen
    // TODO: Verhalten bei einem einzelnen Eintrag prfen
    Iterator<String> it = tweetyXmlConfig.getKeys("plugin");

    // // TODO fix the casts!
    // if (it.hasNext()) {
    //
    // String pluginPath = (String) tweetyXmlConfig.getProperty(it.next()
    // .toString());
    //
    // String pluginName = (String) tweetyXmlConfig.getProperty(it.next()
    // .toString());
    //
    // // for (int i = 0; i < pluginPath.size(); i++) {
    // // System.out.println(pluginName.get(i) + pluginPath.get(i));
    // loadablePlugins.put(pluginName, pluginPath);
    // }
    // }
    System.out.print("Getting Plugins...");
    // TODO fix the casts!
    if (it.hasNext()) {
        @SuppressWarnings("unchecked")
        ArrayList<String> pluginPath = (ArrayList<String>) tweetyXmlConfig.getProperty(it.next());
        @SuppressWarnings("unchecked")
        ArrayList<String> pluginName = (ArrayList<String>) tweetyXmlConfig.getProperty(it.next());

        for (int i = 0; i < pluginPath.size(); i++) {
            // System.out.println(pluginName.get(i) + pluginPath.get(i));
            loadablePlugins.put(pluginName.get(i), pluginPath.get(i));
        }
    }
    System.out.print("done.\n");
    System.out.println("CLI initialized");
    return loadablePlugins;
}

From source file:com.bibisco.manager.ConfigManager.java

private XMLConfiguration getXMLConfiguration() {

    XMLConfiguration lXMLConfiguration = null;

    lXMLConfiguration = new XMLConfiguration();
    lXMLConfiguration.setEncoding(ENCODING);

    try {/*from  w ww  .  ja  v  a2  s .c  om*/
        lXMLConfiguration.setBasePath(CONFIG_DIR);
        lXMLConfiguration.load(CONFIG_FILENAME);
        lXMLConfiguration.setExpressionEngine(new XPathExpressionEngine());
    } catch (ConfigurationException e) {
        mLog.error(e, "Error while reading configuration from file ", CONFIG_FILENAME);
        throw new BibiscoException(e, "bibiscoException.configManager.errorWhileReadingConfiguration",
                CONFIG_FILENAME, e.getMessage());
    }
    return lXMLConfiguration;
}