Example usage for org.apache.commons.configuration SubnodeConfiguration getRoot

List of usage examples for org.apache.commons.configuration SubnodeConfiguration getRoot

Introduction

In this page you can find the example usage for org.apache.commons.configuration SubnodeConfiguration getRoot.

Prototype

public Node getRoot() 

Source Link

Document

Returns the root node of this hierarchical configuration.

Usage

From source file:com.aol.advertising.qiao.util.XmlConfigUtil.java

public static Map<String, Object> parseSingleNodeAttributes(HierarchicalConfiguration config, String key) {
    Map<String, Object> result = null;

    // get a subnode configuration for the node specified by the given key
    SubnodeConfiguration c = config.configurationAt(key);
    if (c != null) {
        Node root = c.getRoot();
        result = new HashMap<String, Object>(root.getAttributeCount());

        List<?> attrs = root.getAttributes();
        for (Object attr : attrs) {
            ConfigurationNode nd = (ConfigurationNode) attr;
            result.put(nd.getName(), nd.getValue());
        }//from ww w  .  j a v a 2s .co m
    }

    return result;
}