Example usage for org.apache.commons.configuration.tree ConfigurationNode setName

List of usage examples for org.apache.commons.configuration.tree ConfigurationNode setName

Introduction

In this page you can find the example usage for org.apache.commons.configuration.tree ConfigurationNode setName.

Prototype

void setName(String name);

Source Link

Document

Sets the name of this node.

Usage

From source file:com.github.mbredel.commons.configuration.YAMLConfiguration.java

@Override
@SuppressWarnings("unchecked")
public void load(Reader in) throws ConfigurationException {
    try {/*from  w  ww. j a va  2  s .  c  o  m*/
        Yaml yaml = new Yaml();
        Map<String, Object> map = (Map) yaml.load(in);
        // Construct the configuration tree.
        ConfigurationNode configurationNode = getRootNode();
        configurationNode.setName(DEFAULT_ROOT_NAME);
        constructHierarchy(configurationNode, map);
    } catch (ClassCastException e) {
        throw new ConfigurationException("Error parsing", e);
    } catch (Exception e) {
        this.getLogger().debug("Unable to load the configuration", e);
        throw new ConfigurationException("Unable to load the configuration", e);
    }
}

From source file:com.github.mbredel.commons.configuration.YAMLConfiguration.java

/**
 * Loads the configuration from the given input stream.
 *
 * @param in the input stream//from  www  .j  a  va 2s  .c om
 * @throws ConfigurationException if an error occurs
 */
@Override
@SuppressWarnings("unchecked")
public void load(InputStream in) throws ConfigurationException {
    try {
        Yaml yaml = new Yaml();
        Map<String, Object> map = (Map) yaml.load(in);
        // Construct the configuration tree.
        ConfigurationNode configurationNode = getRootNode();
        configurationNode.setName(DEFAULT_ROOT_NAME);
        constructHierarchy(configurationNode, map);
    } catch (ClassCastException e) {
        throw new ConfigurationException("Error parsing", e);
    } catch (Exception e) {
        this.getLogger().debug("Unable to load the configuration", e);
        throw new ConfigurationException("Unable to load the configuration", e);
    }
}