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

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

Introduction

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

Prototype

Integer getInteger(String key, Integer defaultValue);

Source Link

Document

Get an Integer associated with the given configuration key.

Usage

From source file:com.comcast.viper.flume2storm.sink.StormSinkConfiguration.java

/**
 * @param config//from  w ww.  ja v a 2  s. c om
 *          The configuration to use
 * @return The newly built {@link StormSinkConfiguration} based on the
 *         configuration specified
 * @throws F2SConfigurationException
 *           If the configuration is invalid
 */
public static StormSinkConfiguration from(Configuration config) throws F2SConfigurationException {
    StormSinkConfiguration result = new StormSinkConfiguration();
    try {
        result.setBatchSize(config.getInteger(BATCH_SIZE, BATCH_SIZE_DEFAULT));
    } catch (Exception e) {
        throw F2SConfigurationException.with(config, BATCH_SIZE, e);
    }
    try {
        result.setLocationServiceFactoryClassName(
                config.getString(LOCATION_SERVICE_FACTORY_CLASS, LOCATION_SERVICE_FACTORY_CLASS_DEFAULT));
    } catch (Exception e) {
        throw F2SConfigurationException.with(config, LOCATION_SERVICE_FACTORY_CLASS, e);
    }
    try {
        result.setServiceProviderSerializationClassName(config.getString(SERVICE_PROVIDER_SERIALIZATION_CLASS,
                SERVICE_PROVIDER_SERIALIZATION_CLASS_DEFAULT));
    } catch (Exception e) {
        throw F2SConfigurationException.with(config, SERVICE_PROVIDER_SERIALIZATION_CLASS, e);
    }
    try {
        result.setEventSenderFactoryClassName(
                config.getString(EVENT_SENDER_FACTORY_CLASS, EVENT_SENDER_FACTORY_CLASS_DEFAULT));
    } catch (Exception e) {
        throw F2SConfigurationException.with(config, EVENT_SENDER_FACTORY_CLASS, e);
    }
    try {
        result.setConnectionParametersFactoryClassName(config.getString(CONNECTION_PARAMETERS_FACTORY_CLASS,
                CONNECTION_PARAMETERS_FACTORY_CLASS_DEFAULT));
    } catch (Exception e) {
        throw F2SConfigurationException.with(config, CONNECTION_PARAMETERS_FACTORY_CLASS, e);
    }
    result.configuration = config;
    return result;
}

From source file:com.germinus.easyconf.ComponentProperties.java

protected static Object getTypedPropertyWithDefault(String key, Class theClass, Configuration properties,
        Object defaultValue) {//w  ww. j  av a2s  .c  o  m
    if (theClass.equals(Float.class)) {
        return properties.getFloat(key, (Float) defaultValue);

    } else if (theClass.equals(Integer.class)) {
        return properties.getInteger(key, (Integer) defaultValue);

    } else if (theClass.equals(String.class)) {
        return properties.getString(key, (String) defaultValue);

    } else if (theClass.equals(Double.class)) {
        return properties.getDouble(key, (Double) defaultValue);

    } else if (theClass.equals(Long.class)) {
        return properties.getLong(key, (Long) defaultValue);

    } else if (theClass.equals(Boolean.class)) {
        return properties.getBoolean(key, (Boolean) defaultValue);

    } else if (theClass.equals(List.class)) {
        return properties.getList(key, (List) defaultValue);

    } else if (theClass.equals(BigInteger.class)) {
        return properties.getBigInteger(key, (BigInteger) defaultValue);

    } else if (theClass.equals(BigDecimal.class)) {
        return properties.getBigDecimal(key, (BigDecimal) defaultValue);

    } else if (theClass.equals(Byte.class)) {
        return properties.getByte(key, (Byte) defaultValue);

    } else if (theClass.equals(Short.class)) {
        return properties.getShort(key, (Short) defaultValue);
    }
    throw new IllegalArgumentException("Class " + theClass + " is not" + "supported for properties");
}

From source file:com.nesscomputing.config.AbstractTestConfig.java

@Test
public void loadIntValues() {
    Assert.assertThat(cfg, is(notNullValue()));
    final Configuration config = cfg.getConfiguration();

    Assert.assertThat(config, is(notNullValue()));

    final Integer s_cfg1 = config.getInteger("int-null-value", null);
    Assert.assertThat(s_cfg1, is(nullValue()));

    final int s_cfg2 = config.getInt("int-value");
    Assert.assertThat(s_cfg2, is(12345));
}

From source file:com.nesscomputing.config.AbstractTestConfig.java

@Test
public void loadIntValues2() {
    Assert.assertThat(cfg2, is(notNullValue()));
    final Configuration config = cfg2.getConfiguration();

    Assert.assertThat(config, is(notNullValue()));

    final Integer s_cfg1 = config.getInteger("int-null-value", null);
    Assert.assertThat(s_cfg1, is(nullValue()));

    final int s_cfg2 = config.getInt("int-value");
    Assert.assertThat(s_cfg2, is(12345));
}

From source file:dk.dma.ais.abnormal.analyzer.analysis.DriftAnalysis.java

@Inject
public DriftAnalysis(Configuration configuration, AppStatisticsService statisticsService,
        EventEmittingTracker trackingService, EventRepository eventRepository) {
    super(eventRepository, trackingService, null);
    this.statisticsService = statisticsService;

    setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_DRIFT_PREDICTIONTIME_MAX, -1));

    SPEED_HIGH_MARK = configuration.getFloat(CONFKEY_ANALYSIS_DRIFT_SOG_MAX, 5.0f);
    SPEED_LOW_MARK = configuration.getFloat(CONFKEY_ANALYSIS_DRIFT_SOG_MIN, 1.0f);
    MIN_HDG_COG_DEVIATION_DEGREES = configuration.getFloat(CONFKEY_ANALYSIS_DRIFT_COGHDG, 45f);
    OBSERVATION_PERIOD_MINUTES = configuration.getInt(CONFKEY_ANALYSIS_DRIFT_PERIOD, 10);
    OBSERVATION_DISTANCE_METERS = configuration.getFloat(CONFKEY_ANALYSIS_DRIFT_DISTANCE, 500f);
    SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_DRIFT_SHIPLENGTH_MIN, 50);

    LOG.info(this.getClass().getSimpleName() + " created (" + this + ").");
}

From source file:dk.dma.ais.abnormal.analyzer.analysis.ShipTypeAndSizeAnalysis.java

@Inject
public ShipTypeAndSizeAnalysis(Configuration configuration, AppStatisticsService statisticsService,
        StatisticDataRepository statisticsRepository, EventEmittingTracker trackingService,
        EventRepository eventRepository, BehaviourManager behaviourManager) {
    super(eventRepository, statisticsRepository, trackingService, behaviourManager);
    this.statisticsService = statisticsService;

    setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_TYPESIZE_PREDICTIONTIME_MAX, -1));

    TOTAL_SHIP_COUNT_THRESHOLD = configuration.getInt(CONFKEY_ANALYSIS_TYPESIZE_CELL_SHIPCOUNT_MIN, 1000);
    PD = configuration.getFloat(CONFKEY_ANALYSIS_TYPESIZE_PD, 0.001f);
    SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_TYPESIZE_SHIPLENGTH_MIN, 50);
    LOG.info(getAnalysisName() + " created (" + this + ").");
}

From source file:dk.dma.ais.abnormal.analyzer.analysis.SuddenSpeedChangeAnalysis.java

@Inject
public SuddenSpeedChangeAnalysis(Configuration configuration, AppStatisticsService statisticsService,
        EventEmittingTracker trackingService, EventRepository eventRepository) {
    super(eventRepository, trackingService, null);
    this.statisticsService = statisticsService;

    setTrackPredictionTimeMax(// w w  w  .  j  av  a2 s .c  o m
            configuration.getInteger(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_PREDICTIONTIME_MAX, -1));

    SPEED_HIGH_MARK = configuration.getFloat(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_SOG_HIGHMARK, 7f);
    SPEED_LOW_MARK = configuration.getFloat(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_SOG_LOWMARK, 1f);
    SPEED_DECAY_SECS = configuration.getInt(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_DROP_DECAY, 30);
    SPEED_SUSTAIN_SECS = configuration.getInt(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_DROP_SUSTAIN, 60);
    SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_SHIPLENGTH_MIN, 50);

    LOG.info(getAnalysisName() + " created (" + this + ").");
}

From source file:dk.dma.ais.abnormal.analyzer.analysis.SpeedOverGroundAnalysis.java

@Inject
public SpeedOverGroundAnalysis(Configuration configuration, AppStatisticsService statisticsService,
        StatisticDataRepository statisticsRepository, EventEmittingTracker trackingService,
        EventRepository eventRepository, BehaviourManager behaviourManager) {
    super(eventRepository, statisticsRepository, trackingService, behaviourManager);
    this.statisticsService = statisticsService;

    setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_SOG_PREDICTIONTIME_MAX, -1));

    TOTAL_SHIP_COUNT_THRESHOLD = configuration.getInt(CONFKEY_ANALYSIS_SOG_CELL_SHIPCOUNT_MIN, 1000);
    PD = configuration.getFloat(CONFKEY_ANALYSIS_SOG_PD, 0.001f);
    SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_SOG_SHIPLENGTH_MIN, 50);
    USE_AGGREGATED_STATS = configuration.getBoolean(CONFKEY_ANALYSIS_SOG_USE_AGGREGATED_STATS, false);

    LOG.info(getAnalysisName() + " created (" + this + ").");
}

From source file:dk.dma.ais.abnormal.analyzer.analysis.CourseOverGroundAnalysis.java

@Inject
public CourseOverGroundAnalysis(Configuration configuration, AppStatisticsService statisticsService,
        StatisticDataRepository statisticsRepository, EventEmittingTracker trackingService,
        EventRepository eventRepository, BehaviourManager behaviourManager) {
    super(eventRepository, statisticsRepository, trackingService, behaviourManager);
    this.statisticsService = statisticsService;
    setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_COG_PREDICTIONTIME_MAX, -1));

    TOTAL_SHIP_COUNT_THRESHOLD = configuration.getInt(CONFKEY_ANALYSIS_COG_CELL_SHIPCOUNT_MIN, 1000);
    PD = configuration.getFloat(CONFKEY_ANALYSIS_COG_PD, 0.001f);
    SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_COG_SHIPLENGTH_MIN, 50);
    USE_AGGREGATED_STATS = configuration.getBoolean(CONFKEY_ANALYSIS_COG_USE_AGGREGATED_STATS, false);

    LOG.info(getAnalysisName() + " created (" + this + ").");
}

From source file:dk.dma.ais.abnormal.analyzer.analysis.CloseEncounterAnalysis.java

@Inject
public CloseEncounterAnalysis(Configuration configuration, AppStatisticsService statisticsService,
        EventEmittingTracker trackingService, EventRepository eventRepository) {
    super(eventRepository, trackingService, null);
    this.statisticsService = statisticsService;
    this.sogMin = configuration.getFloat(CONFKEY_ANALYSIS_CLOSEENCOUNTER_SOG_MIN, 5.0f);
    setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_CLOSEENCOUNTER_PREDICTIONTIME_MAX, -1));
    setAnalysisPeriodMillis(configuration.getInt(CONFKEY_ANALYSIS_CLOSEENCOUNTER_RUN_PERIOD, 30000) * 1000);
    LOG.info(this.getClass().getSimpleName() + " created (" + this + ").");
}