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

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

Introduction

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

Prototype

List getList(String key);

Source Link

Document

Get a List of strings associated with the given configuration key.

Usage

From source file:es.udc.gii.common.eaf.algorithm.parallel.topology.migration.GridMigrationTopology.java

@Override
protected void doConfigure(Configuration conf) {
    List listDimensions = conf.getList("Dimension[@count]");

    this.nodesPerDimension = new int[listDimensions.size()];
    this.dimIsPeriodic = new boolean[listDimensions.size()];

    for (int i = 0; i < listDimensions.size(); i++) {
        nodesPerDimension[i] = conf.getInt("Dimension(" + i + ")[@count]");
        dimIsPeriodic[i] = conf.getBoolean("Dimension(" + i + ")[@periodic]", false);
    }/*from ww  w .j a  va  2s  .co  m*/
}

From source file:es.udc.gii.common.eaf.problem.Problem.java

/**
 * Creates the list of objective functions of this problem from the Configuration object.
 * @param conf a Configuration object with the configuration of this problem.
 * @return the list of objective functions.
 *//*ww  w  .  j  a  v  a2 s  . c om*/
private List<ObjectiveFunction> createObjectiveFunctions(Configuration conf) {

    List<ObjectiveFunction> listObj = new ArrayList<ObjectiveFunction>();
    List objs = conf.getList("ObjectiveFunction.Class");

    for (int i = 0; i < objs.size(); i++) {
        try {
            ObjectiveFunction obj = (ObjectiveFunction) Class.forName((String) objs.get(i)).newInstance();
            obj.configure(conf.subset("ObjectiveFunction(" + i + ")"));
            listObj.add(obj);
        } catch (Exception ex) {
            throw new ConfigurationException("Wrong objective function configuration for "
                    + (String) objs.get(i) + " ?" + " \n Thrown exception: \n" + ex);
        }
    }

    return listObj;
}

From source file:com.strandls.alchemy.inject.AlchemyModuleFilterConfiguration.java

/**
 * Load filter configuration into the internal map.
 *//*from w w  w .j  a v a 2s.  c  o m*/
private void loadConfiguration() {
    environmentFilterConfig.clear();
    final Configuration configuration = readConfiguration();
    for (final Environment env : Environment.values()) {
        final List<String> filterConfig = Lists.transform(configuration.getList(env.name() + FILTER_PROPERTY),
                new Function<Object, String>() {

                    @Override
                    public String apply(final Object input) {
                        final String pattern = ObjectUtils.toString(input);
                        log.info("For environment {} found module filter pattern {} ", env, pattern);
                        return pattern;
                    }
                });
        environmentFilterConfig.put(env, Collections.unmodifiableList(filterConfig));
    }
}

From source file:com.boozallen.cognition.ingest.storm.bolt.geo.LocationResolverBolt.java

@Override
public void configure(Configuration conf) throws ConfigurationException {
    _luceneIndexDir = conf.getString(LUCENE_INDEX_DIR);
    _localIndexDir = conf.getString(LOCAL_INDEX_DIR);
    _textFields = conf.getList(TEXT_FIELDS);
    _pipClavinLocationPrefix = conf.getString(PIP_CLAVIN_LOCATION_PREFIX, "pip.clavinLocation_");
    _fieldName = conf.getString(FIELD_NAME, FIELD_NAME);
    _name = conf.getString(NAME, NAME);//from w ww . java2s  .co  m
    _admin1Code = conf.getString(ADMIN1CODE, ADMIN1CODE);
    _admin2Code = conf.getString(ADMIN2CODE, ADMIN2CODE);
    _countryCode = conf.getString(COUNTRYCODE, COUNTRYCODE);
    _latitude = conf.getString(LATITUDE, LATITUDE);
    _longitude = conf.getString(LONGITUDE, LONGITUDE);
    _confidence = conf.getString(CONFIDENCE, CONFIDENCE);

    Configuration hadoopConfigSubset = conf.subset(HADOOP_CONFIG);
    for (Iterator<String> itr = hadoopConfigSubset.getKeys(); itr.hasNext();) {
        String key = itr.next();
        String value = hadoopConfigSubset.getString(key);
        hadoopConfig.put(key, value);
    }
}

From source file:net.handle.servlet.Settings.java

@SuppressWarnings("unchecked")
private void initErrorResponseTemplates(Configuration configuration) throws SettingsException {
    try {//from  w  ww  . j a  va 2s .c om
        List<String> errorTemplateNames = configuration.getList(ERROR_TEMPLATE_NAME_KEY);
        List<String> errorTemplateMimetypes = configuration.getList(ERROR_TEMPLATE_MIMETYPE_KEY);

        if (!(isValidTemplateConfiguration(errorTemplateNames, errorTemplateMimetypes))) {
            throw new SettingsException(
                    "Missing error template configuration. " + "Please check that you have specified a name "
                            + "and a mimetype for each configured template");
        }

        errorResponseTemplates = new HashMap<Mimetype, Template>();
        for (int i = 0; i < errorTemplateNames.size(); i++) {
            String configuredMimetype = errorTemplateMimetypes.get(i);
            Mimetype mimetype = Mimetype.forName(configuredMimetype);
            if (mimetype == null) {
                throw new SettingsException("Unsupported or invalid mimetype: " + configuredMimetype);
            }

            String name = errorTemplateNames.get(i);
            Template template = new Template(mimetype, name, Template.Type.ERROR_RESPONSE);
            errorResponseTemplates.put(mimetype, template);

            if (i == 0) {
                defaultErrorResponseTemplate = template;
            }
        }
    } catch (ConversionException e) {
        throw new SettingsException(e);
    }
}

From source file:net.handle.servlet.Settings.java

@SuppressWarnings("unchecked")
private void initHandleResponseTemplates(Configuration configuration) throws SettingsException {
    try {//from  ww w  .ja v a  2  s. c  o  m
        List<String> handleTemplateNames = configuration.getList(RESPONSE_TEMPLATE_NAME_KEY);
        List<String> handleTemplateMimetypes = configuration.getList(RESPONSE_TEMPLATE_MIMETYPE_KEY);

        if (!(isValidTemplateConfiguration(handleTemplateNames, handleTemplateMimetypes))) {
            throw new SettingsException(
                    "Missing response template configuration. " + "Please check that you have specified a name "
                            + "and a mimetype for each configured template");
        }

        handleResponseTemplates = new HashMap<Mimetype, Template>();
        for (int i = 0; i < handleTemplateNames.size(); i++) {
            String configuredMimetype = handleTemplateMimetypes.get(i);
            Mimetype mimetype = Mimetype.forName(configuredMimetype);
            if (mimetype == null) {
                throw new SettingsException("Unsupported or invalid mimetype: " + configuredMimetype);
            }

            String name = handleTemplateNames.get(i);
            Template template = new Template(mimetype, name, Template.Type.HANDLE_RESPONSE);
            handleResponseTemplates.put(mimetype, template);

            if (i == 0) {
                defaultHandleResponseTemplate = template;
            }
        }
    } catch (ConversionException e) {
        throw new SettingsException(e);
    }
}

From source file:net.handle.servlet.Settings.java

@SuppressWarnings("unchecked")
private void initHandleClientOptions(Configuration configuration) throws SettingsException {
    try {//from www.ja  v a  2s .com
        preferredProtocols = Protocol.toIntArrayFromList(configuration.getList(PREFERRED_PROTOCOLS_KEY));
        if (preferredProtocols != null && preferredProtocols.length > 0) {
            for (int i : preferredProtocols) {
                LOG.info("Adding preferred protocol '" + Protocol.forInt(i).toString() + "'");
            }
        } else {
            throw new SettingsException(PREFERRED_PROTOCOLS_KEY + " is blank");
        }

        traceMessages = configuration.getBoolean(TRACE_MESSAGES_KEY);
        LOG.info("Setting traceMessages '" + traceMessages + "'");
    } catch (ConversionException e) {
        throw new SettingsException(e);
    }
}

From source file:net.sf.jclal.activelearning.algorithm.AbstractALAlgorithm.java

/**
 *
 * @param configuration The configuration object
 * /* w w w  .  j a  v  a 2 s  .co  m*/
 * The XML labels supported are:
 * 
 * <ul>
 * <li><b>listener type = class:</b>
 * <p>
 * Adds the specified listener to receive algorithm events from this
 * algorithm.
 * </p>
 * <p>
 * Package: net.sf.jclal.listener</p>
 * <p>
 * Class: All</p>
 * </li>
 * </ul>
 */
@Override
public void configure(Configuration configuration) {
    // Number of defined listeners
    int numberOfListeners = configuration.getList("listener[@type]").size();
    // For each listener in list
    String listenerError;
    for (int i = 0; i < numberOfListeners; i++) {
        String header = "listener(" + i + ")";
        listenerError = "listener type= ";
        try {
            // Listener classname
            String listenerClassname = configuration.getString(header + "[@type]");
            listenerError += listenerClassname;
            // Listener class
            Class<? extends IAlgorithmListener> listenerClass = (Class<? extends IAlgorithmListener>) Class
                    .forName(listenerClassname);
            // Listener instance
            IAlgorithmListener listener = listenerClass.newInstance();
            // Configure listener (if necessary)
            if (listener instanceof IConfigure) {
                ((IConfigure) listener).configure(configuration.subset(header));
            }
            // Add this listener to the algorithm
            addListener(listener);
        } catch (ClassNotFoundException e) {
            throw new ConfigurationRuntimeException("\nIllegal listener classname: " + listenerError, e);
        } catch (InstantiationException e) {
            throw new ConfigurationRuntimeException("\nIllegal listener classname: " + listenerError, e);
        } catch (IllegalAccessException e) {
            throw new ConfigurationRuntimeException("\nIllegal listener classname: " + listenerError, e);
        }
    }
}

From source file:net.sf.jclal.activelearning.stopcriterion.PassiveLearningMeasureStopCriterion.java

/**
 * The measures that are actually recognize for single label data are
 * the following:// w  ww.  j av a  2s  . c o m
 * <ul>
 * <li>Correctly Classified Instances</li>
 * <li>Incorrectly Classified Instances</li>
 * <li>Kappa statistic</li>
 * <li>Mean absolute error</li>
 * <li>Root mean squared error</li>
 * <li>Relative absolute error</li>
 * <li>Root relative squared error</li>
 * <li>Coverage of cases</li>
 * <li>Mean region size</li>
 * <li>Weighted Precision</li>
 * <li>Weighted Recall</li>
 * <li>Weighted FMeasure</li>
 * <li>Weighted TruePositiveRate</li>
 * <li>Weighted FalsePositiveRate</li>
 * <li>Weighted MatthewsCorrelation</li>
 * <li>Weighted AreaUnderROC</li>
 * <li>Weighted AreaUnderPRC</li>
 * </ul>
 * <br>
 * The measures that are actually recognize for multi label data are the
 * following:
 * <ul>
 * <li>Hamming Loss</li>
 * <li>Subset Accuracy</li>
 * <li>Example-Based Precision</li>
 * <li>Example-Based Recall</li>
 * <li>Example-Based F Measure</li>
 * <li>Example-Based Accuracy</li>
 * <li>Example-Based Specificity</li>
 * <li>Micro-averaged Precision</li>
 * <li>Micro-averaged Recall</li>
 * <li>Micro-averaged F-Measure</li>
 * <li>Micro-averaged Specificity</li>
 * <li>Macro-averaged Precision</li>
 * <li>Macro-averaged Recall</li>
 * <li>Macro-averaged F-Measure</li>
 * <li>Macro-averaged Specificity</li>
 * <li>Average Precision</li>
 * <li>Coverage</li>
 * <li>OneError</li>
 * <li>IsError</li>
 * <li>ErrorSetSize</li>
 * <li>Ranking Loss</li>
 * <li>Mean Average Precision</li>
 * <li>Geometric Mean Average Precision</li>
 * <li>Mean Average Interpolated Precision</li>
 * <li>Geometric Mean Average Interpolated Precision</li>
 * <li>Micro-averaged AUC</li>
 * <li>Macro-averaged AUC</li>
 * </ul>
 *
 * If more than one measure is settled then by default the set of
 * expressions are evaluated in disjunctive form.
 *
 *The XML labels supported are:
 *
 * <ul>
 * <li><b>disjunctive-form= boolean</b></li>
 * <li><b>measure= String</b>, attribute: maximal= boolean</li>
 * </ul>
 *
 * @param settings the object that stores the configuration
 */
@Override
public void configure(Configuration settings) {

    boolean disjunctiveForm = settings.getBoolean("disjunctive-form", disjunctive);

    setDisjunctive(disjunctiveForm);

    // Number of defined measures
    int numberMeasures = settings.getList("measure").size();

    // For each listener in list
    for (int i = 0; i < numberMeasures; i++) {
        String header = "measure(" + i + ")";

        // measure classname
        String measureNameT = settings.getString(header, "");
        boolean maximalT = settings.getBoolean(header + "[@maximal]");

        // Add this measure
        addMeasure(measureNameT, maximalT);
    }
}

From source file:com.boozallen.cognition.ingest.storm.bolt.geo.TwoFishesGeocodeBolt.java

@Override
public void configure(Configuration conf) throws ConfigurationException {
    _server = conf.getString(SERVER);/*from w  ww. ja  v  a2s . c o m*/
    coordinatesField = conf.getString(COORDINATES_FIELD, "geo.coordinates");
    _locationFields = new ArrayList<>();
    conf.getList(LOCATION_FIELDS).forEach(x -> _locationFields.add(x.toString()));
    _successCount = 0;
    _failCount = 0;
    _exceptionCount = 0;
    _useMultipleLocations = conf.getBoolean(USE_MULTIPLE_LOCATIONS, false);
}