Example usage for org.apache.commons.configuration Configuration setProperty

List of usage examples for org.apache.commons.configuration Configuration setProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration setProperty.

Prototype

void setProperty(String key, Object value);

Source Link

Document

Set a property, this will replace any previously set values.

Usage

From source file:org.bhave.network.model.impl.DefaultBAForestModel.java

/**
 * Return a default configuration for this model
 *//*from   www  .  j  ava 2  s.co m*/
@Override
Configuration defaultConfiguration(Configuration config) {
    config.setProperty(PARAM_NUM_NODES, 2);
    config.setProperty(PARAM_SEED, System.currentTimeMillis());
    return config;
}

From source file:org.bhave.network.model.impl.DefaultBAModel.java

@Override
Configuration defaultConfiguration(Configuration config) {
    config.setProperty(PARAM_NUM_NODES, 2);
    config.setProperty(PARAM_MIN_DEG, 1);
    config.setProperty(PARAM_SEED, System.currentTimeMillis());
    return config;
}

From source file:org.bhave.network.model.impl.DefaultKRegularModel.java

@Override
Configuration defaultConfiguration(Configuration config) {
    config.setProperty(NUM_NODES_PARAM, 3);
    config.setProperty(K_PARAM, 1);//from  www.j a  va  2 s.  c  om
    config.setProperty(PARAM_SEED, System.currentTimeMillis());
    return config;
}

From source file:org.bhave.network.model.impl.EGilberModel.java

@Override
Configuration defaultConfiguration(Configuration config) {
    config.setProperty(PARAM_NUM_NODES, 10);
    config.setProperty(PARA_ATTACH_P, 0.5);
    config.setProperty(PARAM_SEED, System.currentTimeMillis());
    return config;
}

From source file:org.bhave.test.network.model.impl.BarabasiAlbertModelTest.java

@Test
public void configureTest() {
    BAModel model = injector.getInstance(BAModel.class);
    assertNotNull(model);//from   w  w w .  ja  va 2s.  co m

    Configuration config = model.getConfiguration();
    assertNotNull(config);
    assertTrue(config.containsKey("numNodes"));
    assertTrue(config.containsKey("seed"));

    config.setProperty("numNodes", -2);

    boolean configFail = false;
    try {
        model.configure(config);
    } catch (ConfigurationException e) {
        configFail = true;
    }
    assertTrue(configFail);

    config.setProperty("numNodes", 100);
    config.setProperty("seed", System.currentTimeMillis());

    try {
        model.configure(config);
    } catch (ConfigurationException e) {
        fail();
    }
}

From source file:org.bhave.test.network.model.impl.BarabasiAlbertModelTest.java

@Test
public void generateTest() throws ConfigurationException {
    int numNodes = 1000;

    BAModel model = injector.getInstance(BAModel.class);
    Configuration config = model.getConfiguration();
    config.setProperty("numNodes", numNodes);
    config.setProperty("d", 20);
    config.setProperty("seed", 0);

    model.configure(config);//from  w ww .  j ava2  s  .  c  o  m

    Network network = model.generate();
    assertNotNull(network);

    int sumDeg = 0;
    for (Node node : network.getNodes()) {
        int d = network.getNeighbours(node).size();
        System.out.print(d + " ");
        sumDeg += d;
    }
    System.out.println();

    assertEquals(network.getLinkCount() * 2, sumDeg);
}

From source file:org.eclipse.winery.repository.backend.BackendUtils.java

/**
 * Updates the given property in the given configuration. Currently always
 * returns "no content", because the underlying class does not report any
 * errors during updating. <br />//  w  ww. j  a va2s.  c o  m
 * 
 * If null or "" is passed as value, the property is cleared
 * 
 * @return Status.NO_CONTENT
 */
public static Response updateProperty(Configuration configuration, String property, String val) {
    if (StringUtils.isBlank(val)) {
        configuration.clearProperty(property);
    } else {
        configuration.setProperty(property, val);
    }
    return Response.noContent().build();
}

From source file:org.freeeed.main.ParameterProcessing.java

/**
 * Echo configuration, save configuration, and update application log
 *
 * @param configuration processing parameters
 * @throws ConfigurationException/*from  www . j a v  a 2s. c om*/
 * @throws MalformedURLException
 */
public static void echoProcessingParameters(Configuration configuration)
        throws ConfigurationException, MalformedURLException {
    SimpleDateFormat fileNameFormat = new SimpleDateFormat("yyMMdd_HHmmss");
    String runParameterFileName = "freeeed.parameters." + fileNameFormat.format(new Date()) + ".project";

    // save configuration
    FreeEedConfiguration configToSave = new FreeEedConfiguration();
    configToSave.cleanup();
    configToSave.append(configuration);
    configToSave.setProperty("processed_by ", Version.getVersionAndBuild());
    // TODO logs is set locally, not best design practice
    String paramPath = "logs" + runParameterFileName;
    configToSave.save(paramPath);
    configToSave.restore();

    logger.trace("Processing parameters were saved to {}", paramPath);
    configuration.setProperty(ParameterProcessing.RUN_PARAMETERS_FILE, paramPath);
}

From source file:org.janusgraph.olap.PageRankVertexProgram.java

@Override
public void storeState(final Configuration configuration) {
    configuration.setProperty(VERTEX_PROGRAM, PageRankVertexProgram.class.getName());
    configuration.setProperty(DAMPING_FACTOR, dampingFactor);
    configuration.setProperty(MAX_ITERATIONS, maxIterations);
    configuration.setProperty(VERTEX_COUNT, vertexCount);
}

From source file:org.janusgraph.olap.ShortestDistanceMapReduce.java

@Override
public void storeState(final Configuration configuration) {
    super.storeState(configuration);
    configuration.setProperty(SHORTEST_DISTANCE_MEMORY_KEY, this.memoryKey);
}