Example usage for org.apache.commons.configuration HierarchicalConfiguration configurationAt

List of usage examples for org.apache.commons.configuration HierarchicalConfiguration configurationAt

Introduction

In this page you can find the example usage for org.apache.commons.configuration HierarchicalConfiguration configurationAt.

Prototype

public SubnodeConfiguration configurationAt(String key, boolean supportUpdates) 

Source Link

Document

Returns a hierarchical subnode configuration object that wraps the configuration node specified by the given key.

Usage

From source file:com.github.steveash.typedconfig.ConfigFactoryContext.java

/**
 * Produces a resolver that knows how to deal with the given binding for the given config; does not
 * use any decorators or anything just the binding and the value type for the factory that is chosen
 * by the registry/* w w w  .j  a va2 s.c o  m*/
 *
 *
 * @param config
 * @param newMethodBinding
 *@param parentBinding @return
 */
public ValueResolver makeResolverForBinding(HierarchicalConfiguration config, ConfigBinding newMethodBinding,
        ConfigBinding parentBinding) {
    ValueResolverFactory factory = getRegistry().lookup(newMethodBinding);

    switch (factory.getValueType()) {
    case Container:
    case Simple:
        return factory.makeForThis(newMethodBinding, config, this);

    case Nested:
        Preconditions.checkNotNull(parentBinding);
        // config points to the location of the nested context
        SubnodeConfiguration subConfig = config.configurationAt(newMethodBinding.getConfigKeyToLookup(), true);
        ConfigBinding subBinding = newMethodBinding.withKey(subConfig.getSubnodeKey());
        return factory.makeForThis(subBinding, subConfig, this);

    default:
        throw new IllegalArgumentException("dont know how to handle value type: " + factory.getValueType());
    }
}