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

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

Introduction

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

Prototype

public void setEncoding(String encoding) 

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:com.bibisco.manager.ConfigManager.java

private XMLConfiguration getXMLConfiguration() {

    XMLConfiguration lXMLConfiguration = null;

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

    try {//from  www .ja  v a2  s. com
        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;
}

From source file:org.jboss.forge.shell.env.ConfigurationImpl.java

@Unwraps
public Configuration getConfiguration() throws ConfigurationException {

    Project project = shell.getCurrentProject();
    if ((project != null) && !project.equals(this.currentProject)) {
        currentProject = project;/*from  w w  w.ja  v a 2s  .c  o m*/
        ScopedConfigurationAdapter projectConfig = new ScopedConfigurationAdapter();
        XMLConfiguration projectLocalConfig;
        try {
            projectLocalConfig = new XMLConfiguration(
                    getProjectSettings(project).getUnderlyingResourceObject());
            projectLocalConfig.setEncoding("UTF-8");
        } catch (org.apache.commons.configuration.ConfigurationException e) {
            throw new ConfigurationException(e);
        }
        projectLocalConfig.setReloadingStrategy(new FileChangedReloadingStrategy());
        projectLocalConfig.setAutoSave(true);

        ConfigurationAdapter adapter = BeanManagerUtils.getContextualInstance(bm, ConfigurationAdapter.class,
                new ConfigAdapterQualifierLiteral());
        adapter.setParent(projectConfig);
        adapter.setDelegate(projectLocalConfig);
        adapter.setBeanManager(bm);
        projectConfig.setScopedConfiguration(ConfigurationScope.PROJECT, adapter);
        projectConfig.setScopedConfiguration(ConfigurationScope.USER, getUserConfig());

        this.projectConfig = projectConfig;
        return projectConfig;
    } else if ((project != null) && project.equals(this.currentProject)) {
        return projectConfig;
    }
    return getUserConfig();
}

From source file:org.jboss.forge.shell.env.ConfigurationImpl.java

public Configuration getUserConfig() throws ConfigurationException {
    // FIXME NPE caused when no project exists because config param is null
    if (userConfig == null) {
        XMLConfiguration globalXml;
        try {//from  w  w  w  .  j  a  va  2  s  . c o m
            globalXml = new XMLConfiguration(environment.getUserConfiguration().getUnderlyingResourceObject());
            globalXml.setEncoding("UTF-8");
        } catch (org.apache.commons.configuration.ConfigurationException e) {
            throw new ConfigurationException(e);
        }
        globalXml.setReloadingStrategy(new FileChangedReloadingStrategy());
        globalXml.setAutoSave(true);

        ConfigurationAdapter adapter = BeanManagerUtils.getContextualInstance(bm, ConfigurationAdapter.class,
                new ConfigAdapterQualifierLiteral());
        adapter.setDelegate(globalXml);
        adapter.setBeanManager(bm);
        userConfig = new ScopedConfigurationAdapter(ConfigurationScope.USER, adapter);
    }
    return userConfig;
}