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

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

Introduction

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

Prototype

int getAttributeCount();

Source Link

Document

Returns the number of attributes of this node.

Usage

From source file:com.gamma.dam.conf.db.DBConfigReader.java

/**
 * Instantiates a new DB config reader.//w  w  w .  j a va 2 s. c  o  m
 */
private DBConfigReader() {
    String basePath = ResourceProperties.instance().getValue(ResourceProperties.DATABASE_CONF);
    String home = System.getProperty("DAM_HOME");
    if (home != null) {
        basePath = home + File.separator + basePath;
    }
    try {
        XMLConfiguration xml = new XMLConfiguration(basePath);
        ReloadingStrategy strategy = new FileChangedReloadingStrategy();
        xml.setReloadingStrategy(strategy);
        Node node = xml.getRoot();
        if (node.hasChildren()) {
            for (ConfigurationNode n : node.getChildren()) {
                DBConfig db = new DBConfig();
                String name = null;
                if (n.getAttributeCount() > 0) {
                    for (ConfigurationNode attr : n.getAttributes()) {
                        switch (attr.getName()) {
                        case "id":

                            break;
                        case "name":
                            name = (String) attr.getValue();
                            break;

                        default:
                            break;
                        }
                    }
                }

                db.parse(n);
                dbs.put(name, db);
            }
        }
    } catch (ConfigurationException e) {
        throw new DAMConfigurationException(e);
    }
}