Example usage for org.apache.commons.configuration2.tree ImmutableNode.Builder addChild

List of usage examples for org.apache.commons.configuration2.tree ImmutableNode.Builder addChild

Introduction

In this page you can find the example usage for org.apache.commons.configuration2.tree ImmutableNode.Builder addChild.

Prototype

public ImmutableNode addChild(final ImmutableNode child) 

Source Link

Document

Creates a new ImmutableNode instance which is a copy of this object, but has the given child node added.

Usage

From source file:Executable.Output.java

/**
 * Get the input config for the final imputation step
 * @return The config/*w w  w.j  av a  2s.  com*/
 */
public ImmutableNode getConfig() {
    ImmutableNode Isummary = new ImmutableNode.Builder().name("summary").value(summary).create();
    ImmutableNode Icontrol = new ImmutableNode.Builder().name("control").value(control).create();

    ImmutableNode.Builder config = new ImmutableNode.Builder().name("output").addChild(Isummary)
            .addChild(Icontrol);

    if (partial) {
        config.addChild(new ImmutableNode.Builder().name("partial").value("true").create());
    }
    if (table != null) {
        config.addChild(new ImmutableNode.Builder().name("table").value(table).create());
    }

    return config.create();
}

From source file:Executable.Input.java

/**
 * Get the input config/*from  w  w  w  .jav a  2s. co m*/
 * @return The config
 */
public ImmutableNode getConfig() {
    ImmutableNode Iin = new ImmutableNode.Builder().name("filename").value(in).create();

    ImmutableNode.Builder config = new ImmutableNode.Builder().name("input").addChild(Iin);

    for (VCFFilter filter : filters) {
        config.addChild(filter.getConfig());
    }

    if (out != null) {
        ImmutableNode Iout = new ImmutableNode.Builder().name("save").value(out).create();
        config.addChild(Iout);
    }

    if (readsformat != null) {
        ImmutableNode Ireadformat = new ImmutableNode.Builder().name("readsformat").value(readsformat).create();
        config.addChild(Ireadformat);
    }

    ImmutableNode Imax = new ImmutableNode.Builder().name("maxdepth").value(maxdepth).create();
    config.addChild(Imax);

    return config.create();
}

From source file:Executable.Input.java

/**
 * Get the input config for the final imputation step
 * @return The config/*w  w  w  .  j a v  a2 s.co m*/
 */
public ImmutableNode getImputeConfig() {
    if (out != null) {
        ImmutableNode Iin = new ImmutableNode.Builder().name("filename").value(out).create();
        return new ImmutableNode.Builder().name("input").addChild(Iin).create();
    } else {
        ImmutableNode Iin = new ImmutableNode.Builder().name("filename").value(in).create();

        ImmutableNode.Builder config = new ImmutableNode.Builder().name("input").addChild(Iin);

        for (VCFFilter filter : filters) {
            config.addChild(filter.getConfig());
        }

        return config.create();
    }
}

From source file:Executable.Case.java

/**
 * Get the final imputation stage config for this case
 * @param caller The caller to be used in the final imputation stage
 * @param imputer The optimized imputer to be used in the final imputation stage
 * @param combiner The optimized combiner to be used in the final imputation stage
 * @return The config//from w  w  w  . j  a  va  2  s. c o m
 */
public ImmutableNode getImputeConfig(Caller caller, Imputer imputer, Combiner combiner) {
    ImmutableNode Iname = new ImmutableNode.Builder().name("name").value(name).create();

    ImmutableNode.Builder config = new ImmutableNode.Builder().name("case").addChild(Iname);

    for (VCFFilter filter : filters) {
        config.addChild(filter.getConfig());
    }

    config.addChild(caller.getConfig());

    config.addChild(imputer.getConfig());

    config.addChild(combiner.getConfig());

    return config.create();
}

From source file:Executable.Case.java

/**
 * Get the config for this case/*from  ww w .  j ava  2 s  . co m*/
 * @return The config
 */
public ImmutableNode getConfig() {
    ImmutableNode Iname = new ImmutableNode.Builder().name("name").value(name).create();
    ImmutableNode Iadditional = new ImmutableNode.Builder().name("additional").value(additional).create();

    ImmutableNode.Builder config = new ImmutableNode.Builder().name("case").addChild(Iname);

    for (VCFFilter filter : filters) {
        config.addChild(filter.getConfig());
    }

    config.addChild(caller.getConfig());

    config.addChild(imputer.getConfig());

    config.addChild(combiner.getConfig());

    config.addChild(print.getConfig());

    config.addChild(Iadditional);

    return config.create();
}

From source file:Executable.PrintStats.java

/**
 * Get the imputer options config/*  w w  w. jav  a  2s. c o  m*/
 * @return The config
 */
public ImmutableNode getConfig() {
    ImmutableNode.Builder config = new ImmutableNode.Builder().name("stats");

    if (pretty != null) {
        config.addChild(new ImmutableNode.Builder().name("pretty").value(pretty.getAbsolutePath()).create());
    }
    if (depth != null) {
        config.addChild(new ImmutableNode.Builder().name("depth").value(depth.getAbsolutePath()).create());
    }
    if (geno != null) {
        config.addChild(new ImmutableNode.Builder().name("geno").value(geno.getAbsolutePath()).create());
    }
    if (depthGeno != null) {
        config.addChild(
                new ImmutableNode.Builder().name("depthgeno").value(depthGeno.getAbsolutePath()).create());
    }
    if (eachMasked != null) {
        config.addChild(
                new ImmutableNode.Builder().name("eachmasked").value(eachMasked.getAbsolutePath()).create());
    }
    if (partial) {
        config.addChild(new ImmutableNode.Builder().name("partial").value("true").create());
    }

    return config.create();
}

From source file:org.craftercms.commons.config.YamlConfiguration.java

@SuppressWarnings("unchecked")
protected void buildConfigFromKeyValuePair(String name, Object value, ImmutableNode.Builder parent) {
    if (value instanceof Map) {
        ImmutableNode.Builder node = new ImmutableNode.Builder();
        node.name(name);// www  . j a  v  a 2 s  .  co  m

        buildConfigFromMap((Map<String, Object>) value, node);

        parent.addChild(node.create());
    } else if (value instanceof Collection) {
        buildConfigFromCollection(name, (Collection<Object>) value, parent);
    } else {
        ImmutableNode.Builder node = new ImmutableNode.Builder();
        node.name(name);
        node.value(value);

        parent.addChild(node.create());
    }
}

From source file:Utils.Log.java

/**
 * Get the config for a caller//from  w w w .  j  a v a  2  s. co  m
 * @param level The level to log
 * @param log The file to log to.  Null logs nothing.
 * @return The config
 */
public static ImmutableNode getConfig(Level level, File log) {
    ImmutableNode.Builder config = new ImmutableNode.Builder().name("log");
    if (log != null) {
        config.addChild(new ImmutableNode.Builder().name("file").value(log).create());
    }

    String ls;
    switch (level) {
    case DEBUG:
        ls = "debug";
        break;
    case DETAIL:
        ls = "detail";
        break;
    case BRIEF:
        ls = "brief";
        break;
    default:
        ls = "critical";
        break;
    }

    config.addChild(new ImmutableNode.Builder().name("level").value(ls).create());

    return config.create();
}