Example usage for org.apache.commons.configuration AbstractConfiguration getDefaultListDelimiter

List of usage examples for org.apache.commons.configuration AbstractConfiguration getDefaultListDelimiter

Introduction

In this page you can find the example usage for org.apache.commons.configuration AbstractConfiguration getDefaultListDelimiter.

Prototype

public static char getDefaultListDelimiter() 

Source Link

Document

Retrieve the current delimiter.

Usage

From source file:org.apache.whirr.service.hadoop.HadoopConfigurationConverter.java

@VisibleForTesting
static List<String> asXmlConfigurationLines(Configuration hadoopConfig) {
    List<String> lines = Lists.newArrayList();
    lines.add("<configuration>");
    for (@SuppressWarnings("unchecked")
    Iterator<String> it = hadoopConfig.getKeys(); it.hasNext();) {
        String key = it.next();//from ww  w  .  j  a  v a 2  s.co m
        if (key.endsWith(FINAL_SUFFIX)) {
            continue;
        }

        // rebuild the original value by joining all of them with the default separator
        String value = StringUtils.join(hadoopConfig.getStringArray(key),
                AbstractConfiguration.getDefaultListDelimiter());
        lines.add("  <property>");
        lines.add(String.format("    <name>%s</name>", key));
        lines.add(String.format("    <value>%s</value>", value));
        String finalValue = hadoopConfig.getString(key + FINAL_SUFFIX);
        if (finalValue != null) {
            lines.add(String.format("    <final>%s</final>", finalValue));
        }
        lines.add("  </property>");
    }
    lines.add("</configuration>");
    return lines;
}