Example usage for org.apache.commons.configuration2.convert DisabledListDelimiterHandler DisabledListDelimiterHandler

List of usage examples for org.apache.commons.configuration2.convert DisabledListDelimiterHandler DisabledListDelimiterHandler

Introduction

In this page you can find the example usage for org.apache.commons.configuration2.convert DisabledListDelimiterHandler DisabledListDelimiterHandler.

Prototype

DisabledListDelimiterHandler

Source Link

Usage

From source file:com.gs.obevo.api.factory.XmlFileConfigReader.java

@Override
public HierarchicalConfiguration getConfig(FileObject checkoutFolder) {
    try {/*from  ww w.  j a v  a 2s. co m*/
        FileObject envFileToRead = getEnvFileToRead(checkoutFolder);
        if (envFileToRead.getName().getExtension().equals("xml")) {
            // For the XML lookup, we want all access to fall to attribute queries if we choose. To do that, we override
            // the expression engine.
            DefaultExpressionEngine engine = new DefaultExpressionEngine(
                    DefaultExpressionEngineSymbols.DEFAULT_SYMBOLS) {
                @Override
                public <T> List<QueryResult<T>> query(T root, String key, NodeHandler<T> handler) {
                    List<QueryResult<T>> results = super.query(root, key, handler);
                    if (!results.isEmpty()) {
                        return results;
                    }

                    // If we find no results, fall back to the query that specifies the attribute handler
                    return super.query(root, this.attributeKey(null, key), handler);
                }
            };

            XMLConfiguration configuration = new FileBasedConfigurationBuilder<>(XMLConfiguration.class)
                    .configure(new Parameters().hierarchical().setURL(envFileToRead.getURLDa())
                            .setListDelimiterHandler(new DisabledListDelimiterHandler())
                            .setExpressionEngine(engine))
                    .getConfiguration();
            postProcess(configuration);
            return configuration;
        } else {
            return new FileBasedConfigurationBuilder<>(FixedYAMLConfiguration.class)
                    .configure(new Parameters().hierarchical().setURL(envFileToRead.getURLDa())
                            .setListDelimiterHandler(new DisabledListDelimiterHandler()))
                    .getConfiguration();
        }
    } catch (ConfigurationException e) {
        throw new DeployerRuntimeException(e);
    }
}