Example usage for org.apache.commons.configuration ConfigurationRuntimeException ConfigurationRuntimeException

List of usage examples for org.apache.commons.configuration ConfigurationRuntimeException ConfigurationRuntimeException

Introduction

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

Prototype

public ConfigurationRuntimeException() 

Source Link

Document

Constructs a new ConfigurationRuntimeException without specified detail message.

Usage

From source file:de.nec.nle.siafu.model.DiscreteOverlay.java

/**
 * Create a discrete overlay using the thresholds int he configuration
 * object.//from w  ww  .ja  v a  2 s.  co  m
 * 
 * @param name
 *            the name of the overlay
 * @param is
 *            the InputStream with the image that represents the values
 * @param simulationConfig
 *            the configuration file where the threshold details are given
 */
public DiscreteOverlay(final String name, final InputStream is, final Configuration simulationConfig) {
    super(name, is);

    // A tree to sort the thresholds
    TreeMap<Integer, String> intervals = new TreeMap<Integer, String>();

    // Find out how many thresholds we have
    String[] property;
    try {
        property = simulationConfig.getStringArray("overlays." + name + ".threshold[@tag]");
        if (property.length == 0)
            throw new ConfigurationRuntimeException();
    } catch (ConfigurationRuntimeException e) {
        throw new RuntimeException("You forgot the description of " + name + " in the config file");
    }

    thresholds = new int[property.length];
    tags = new String[property.length];

    // Read the thresholds
    for (int i = 0; i < property.length; i++) {
        String tag = simulationConfig.getString("overlays." + name + ".threshold(" + i + ")[@tag]");
        int pixelValue = simulationConfig.getInt("overlays." + name + ".threshold(" + i + ")[@pixelvalue]");
        intervals.put(pixelValue, tag);
    }

    // Store the sorted thresholds
    int i = 0;
    for (int key : intervals.keySet()) {
        thresholds[i] = key;
        tags[i] = intervals.get(key);
        i++;
    }
}