Example usage for org.apache.commons.configuration2 FixedYAMLConfiguration FixedYAMLConfiguration

List of usage examples for org.apache.commons.configuration2 FixedYAMLConfiguration FixedYAMLConfiguration

Introduction

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

Prototype

public FixedYAMLConfiguration(HierarchicalConfiguration<ImmutableNode> c) 

Source Link

Document

Creates a new instance of FixedYAMLConfiguration as a copy of the specified configuration.

Usage

From source file:com.gs.obevo.db.api.factory.DbEnvironmentXmlEnricherTest.java

@Test
public void convert() throws Exception {
    XMLConfiguration configuration = new FileBasedConfigurationBuilder<>(XMLConfiguration.class)
            .configure(new Parameters().hierarchical()
                    .setFile(new File("./src/test/resources/DbEnvironmentXmlEnricher/system-config.xml")))
            .getConfiguration();//ww w  .ja v  a 2  s  .c om

    Map<String, Object> myMap = constructMap(configuration.getNodeModel().getNodeHandler().getRootNode());

    FixedYAMLConfiguration yamlConfiguration = new FixedYAMLConfiguration(configuration);
    StringWriter sw = new StringWriter();
    //        yamlConfiguration.write();
    DumperOptions dumperOptions = new DumperOptions();
    //        dumperOptions.setPrettyFlow(true);
    dumperOptions.setDefaultFlowStyle(FlowStyle.BLOCK);
    Yaml yaml = new Yaml(dumperOptions);
    yaml.dump(myMap, sw);

    //        yamlConfiguration.dump(sw, new DumperOptions());
    System.out.println(sw.toString());
}