Java 类org.apache.commons.configuration.ConversionException 实例源码

项目:DigitalMediaServer    文件:PmsConfiguration.java   
private void readDefaultSharedFolders() {
    synchronized (sharedFoldersLock) {
        if (!defaultSharedFoldersRead) {
            Boolean useDefault;
            try {
                useDefault = configuration.getBoolean(KEY_USE_DEFAULT_FOLDERS, null);
            } catch (ConversionException e) {
                useDefault = null;
                String useDefaultString = configuration.getString(KEY_USE_DEFAULT_FOLDERS, null);
                if (!isBlank(useDefaultString)) {
                    LOGGER.warn(
                        "Invalid configured value for {} \"{}\", using default",
                        KEY_USE_DEFAULT_FOLDERS,
                        useDefaultString
                    );
                }
            }
            if (useDefault != null) {
                defaultSharedFolders = useDefault.booleanValue();
            } else {
                defaultSharedFolders = isSharedFoldersEmpty();
            }
            defaultSharedFoldersRead = true;
        }
    }
}
项目:DigitalMediaServer    文件:ConfigurableProgramPaths.java   
/**
 * Gets the configured custom program {@link Path} from the
 * {@link Configuration} using the specified key. If the specified key has
 * no value, {@code null} is returned.
 *
 * @param configurationKey the {@link Configuration} key to use.
 * @return The resulting {@link Path} or {@code null}.
 * @throws ConfigurationException If the configured value can't be parsed as
 *             a valid {@link Path}.
 */
@Nullable
public Path getCustomProgramPath(@Nullable String configurationKey) throws ConfigurationException {
    if (isBlank(configurationKey) || configuration == null) {
        return null;
    }

    try {
        String configuredPath = configuration.getString(configurationKey);
        if (isBlank(configuredPath)) {
            return null;
        }
        return Paths.get(configuredPath);
    } catch (ConversionException | InvalidPathException e) {
        throw new ConfigurationException(
            "Invalid configured custom program path in \"" + configurationKey + "\": " + e.getMessage(),
            e
        );
    }
}
项目:vsphere-automation-sdk-java    文件:ParametersHelper.java   
private Object getOptionValueFromConfig(
    Option option, Configuration config) {
    Object optionValue = null;
    try {
        if (option.getType().equals(Boolean.class)) {
            optionValue = config.getString(option.getLongOpt());
            if (optionValue != null) {
                optionValue = config.getBoolean(option.getLongOpt());
            }

        } else {
            optionValue = config.getString(option.getLongOpt());
        }
    } catch (ConversionException cex) {
        optionValue = null;
    }
    return optionValue;
}
项目:marmotta    文件:ConfigurationWebService.java   
public Map<String,Object> buildConfigurationMap(String key) {
    Map<String,Object> config = new HashMap<String, Object>();
    config.put("comment",configurationService.getComment(key));
    config.put("type",configurationService.getType(key));
    config.put("value",configurationService.getConfiguration(key));
    if (config.get("type") != null) {
        try {
            if (((String) config.get("type")).startsWith("java.lang.Integer")) {
                config.put("value", configurationService.getIntConfiguration(key));
            } else if (((String) config.get("type")).startsWith("java.lang.Boolean")) {
                config.put("value", configurationService.getBooleanConfiguration(key));
            } else if (((String) config.get("type")).startsWith("java.lang.Double")) {
                config.put("value", configurationService.getDoubleConfiguration(key));
            } else if (((String) config.get("type")).startsWith("java.lang.Long")) {
                config.put("value", configurationService.getLongConfiguration(key));
            }
        } catch (ConversionException e) {
            log.warn("key {} cannot be converted to given type {}", key, config.get("type"));
        }
    }
    return config;
}
项目:DigitalMediaServer    文件:ConfigurableProgramPaths.java   
/**
 * Sets a new {@link ProgramExecutableType#CUSTOM} {@link Path} in the
 * {@link Configuration} for the specified key. No change is done to any
 * {@link ExternalProgramInfo} instance. To set the {@link Path} both in the
 * {@link Configuration} and in the {@link ExternalProgramInfo} instance in
 * one operation, use {@link #setCustomProgramPath}.
 *
 * @param customPath the new {@link Path} or {@code null} to clear it.
 * @param configurationKey the {@link Configuration} key under which to
 *            store the {@code path}.
 * @return {@code true} if a change was made, {@code false} otherwise.
 */
public boolean setCustomProgramPathConfiguration(@Nullable Path customPath, @Nonnull String configurationKey) {
    if (isBlank(configurationKey)) {
        throw new IllegalArgumentException("configurationKey can't be blank");
    }
    if (configuration == null) {
        return false;
    }
    if (customPath == null) {
        if (configuration.containsKey(configurationKey)) {
            configuration.clearProperty(configurationKey);
            return true;
        }
        return false;
    }
    boolean changed;
    try {
        String currentValue = configuration.getString(configurationKey);
        changed = !customPath.toString().equals(currentValue);
    } catch (ConversionException e) {
        changed = true;
    }
    if (changed) {
        configuration.setProperty(configurationKey, customPath.toString());
    }
    return changed;
}
项目:DigitalMediaServer    文件:ConfigurationReader.java   
/**
 * Return the <code>int</code> value for a given configuration key. First, the key
 * is looked up in the current configuration settings. If it exists and contains a
 * valid value, that value is returned. If the key contains an invalid value or
 * cannot be found, the specified default value is returned.
 *
 * @param key The key to look up.
 * @param def The default value to return when no valid key value can be found.
 * @return The value configured for the key.
 */
int getInt(String key, int def) {
    int value;

    try {
        value = configuration.getInt(key, def);
    } catch (ConversionException e) {
        value = def;
    }

    log(key, value, def);
    return value;
}
项目:DigitalMediaServer    文件:ConfigurationReader.java   
/**
 * Return the <code>long</code> value for a given configuration key. First, the key
 * is looked up in the current configuration settings. If it exists and contains a
 * valid value, that value is returned. If the key contains an invalid value or
 * cannot be found, the specified default value is returned.
 *
 * @param key The key to look up.
 * @param def The default value to return when no valid key value can be found.
 * @return The value configured for the key.
 */
long getLong(String key, long def) {
    long value;

    try {
        value = configuration.getLong(key, def);
    } catch (ConversionException e) {
        value = def;
    }

    log(key, value, def);
    return value;
}
项目:DigitalMediaServer    文件:ConfigurationReader.java   
/**
 * Return the <code>double</code> value for a given configuration key. First, the key
 * is looked up in the current configuration settings. If it exists and contains a
 * valid value, that value is returned. If the key contains an invalid value or
 * cannot be found, the specified default value is returned.
 *
 * @param key The key to look up.
 * @param def The default value to return when no valid key value can be found.
 * @return The value configured for the key.
 */
double getDouble(String key, double def) {
    double value;

    try {
        value = configuration.getDouble(key, def);
    } catch (ConversionException e) {
        value = def;
    }

    log(key, value, def);
    return value;
}
项目:DigitalMediaServer    文件:ConfigurationReader.java   
/**
 * Return the <code>boolean</code> value for a given configuration key. First, the
 * key is looked up in the current configuration settings. If it exists and contains
 * a valid value, that value is returned. If the key contains an invalid value or
 * cannot be found, the specified default value is returned.
 *
 * @param key The key to look up.
 * @param def The default value to return when no valid key value can be found.
 * @return The value configured for the key.
 */
boolean getBoolean(String key, boolean def) {
    boolean value;

    try {
        value = configuration.getBoolean(key, def);
    } catch (ConversionException e) {
        value = def;
    }

    log(key, value, def);
    return value;
}
项目:proarc    文件:ExternalProcess.java   
int getRetryCount() {
    try {
        int retry = conf.getInt("retry", DEFAULT_RETRY_ATTEMPTS);
        retry = Math.max(0, retry);
        retry = Math.min(100, retry);
        return retry;
    } catch (ConversionException ex) {
        LOG.log(Level.WARNING, null, ex);
        return DEFAULT_RETRY_ATTEMPTS;
    }
}
项目:proarc    文件:ExternalProcess.java   
long getTimeout() {
    try {
        long timeout = conf.getLong(PROP_TIMEOUT, DEFAULT_TIMEOUT);
        timeout = Math.max(0, timeout);
        return timeout;
    } catch (ConversionException ex) {
        LOG.log(Level.WARNING, null, ex);
        return DEFAULT_TIMEOUT;
    }
}
项目:proarc    文件:CejshConfig.java   
public static CejshConfig from(Configuration conf) {
        CejshConfig cc = new CejshConfig();
        cc.setCejshXslUrl(conf.getString(PROP_MODS_XSL_URL, null));
//        cc.setJournalUrl(conf.getString(PROP_JOURNALS_URL, null));
        try {
            boolean debug = conf.getBoolean(PROP_DEBUG, Boolean.FALSE);
            cc.setLogLevel(debug ? Level.INFO : Level.FINE);
        } catch (ConversionException ex) {
            LOG.log(Level.SEVERE, PROP_DEBUG, ex);
        }
        return cc;
    }
项目:proarc    文件:ImportProfile.java   
private ScalingMethod getJavaScaling(String key) {
    String val = config.getString(key);
    if (val == null || val.isEmpty()) {
        return ScalingMethod.BICUBIC_STEPPED;
    }
    try {
        ScalingMethod hint = ScalingMethod.valueOf(val);
        return hint;
    } catch (Exception e) {
        throw new ConversionException(key, e);
    }
}
项目:proarc    文件:ImportProfile.java   
private Integer getPositiveInteger(String key) {
    Integer val = config.getInteger(key, null);
    if (val != null && val <= 0) {
        throw new ConversionException(key + " expects positive integer!");
    }
    return val;
}
项目:of-patch-manager    文件:ConfigImpl.java   
@Override
public String getString(String key, String defaultValue) {
    try {
        String value = getConfiguration().getString(key, defaultValue);
        return value;
    } catch (ConversionException e) {
        return defaultValue;
    }
}
项目:of-patch-manager    文件:ConfigImpl.java   
@Override
public int getInt(String key, int defaultValue) {
    try {
        int value = getConfiguration().getInt(key, defaultValue);
        return value;
    } catch (ConversionException e) {
        return defaultValue;
    }
}
项目:honoumi    文件:ApplicationPropertiesTest.java   
@Test
public void test_getBigDecimal() {
    assertEquals(1.1, ApplicationProperties.getBigDecimal("test.bigDecimal").doubleValue());
    assertEquals(1, ApplicationProperties.getBigDecimal("test.int").intValue());
    assertNull(ApplicationProperties.getBigDecimal("test.notExist"));
    try {
        ApplicationProperties.getBigDecimal("test.hoge");
        fail();
    } catch (ConversionException e) {
    }
    assertEquals(1.1, ApplicationProperties.getBigDecimal("test.notExist", new BigDecimal(1.1)).doubleValue());
}
项目:honoumi    文件:ApplicationPropertiesTest.java   
@Test
public void test_getBigInteger() {
    assertEquals(1, ApplicationProperties.getBigInteger("test.bigInteger").intValue());
    assertEquals(1, ApplicationProperties.getBigInteger("test.int").intValue());
    assertNull(ApplicationProperties.getBigInteger("test.notExist"));
    try {
        ApplicationProperties.getBigInteger("test.hoge");
        fail();
    } catch (ConversionException e) {
    }
    assertEquals(1, ApplicationProperties.getBigInteger("test.notExist", new BigInteger("1")).intValue());
}
项目:andes    文件:ConfigurationPlugin.java   
/**
 * Provide mechanism to validate Configuration contains a Postiive Long Value
 *
 * @param property
 *
 * @throws ConfigurationException
 */
protected void validatePositiveLong(String property) throws ConfigurationException
{
    try
    {
        if (!containsPositiveLong(property))
        {
            throw new ConfigurationException(this.getClass().getSimpleName()
                                             + ": '" + property +
                                             "' must be a Positive Long value.");
        }
    }
    catch (Exception e)
    {
        Throwable last = e;

        // Find the first cause
        if (e instanceof ConversionException)
        {
            Throwable t = e.getCause();
            while (t != null)
            {
                last = t;
                t = last.getCause();
            }
        }

        throw new ConfigurationException(this.getClass().getSimpleName() +
                                         ": unable to configure invalid " +
                                         property + ":" +
                                         _configuration.getString(property),
                                         last);
    }
}
项目:opennmszh    文件:SupportRtConfigDao.java   
public Long getQueueId() {
    if (getProperties() == null) {
        return null;
    }
    try {
        return getProperties().getLong("support.queueId");
    } catch (final ConversionException e) {
        return null;
    }
}
项目:mev    文件:AbstractConfig.java   
public String[] getStringArray (String key)
{
  Object value = getProperty (key);
  String[] array = ConfigurationUtilHelpers.convertToArray (value);
  if (array == null)
    throw new ConversionException ('\'' + key + "' doesn't map to a String/List object");
  return array;
}
项目:AisAbnormal    文件:Configuration.java   
private static boolean isValidPositiveFloat(org.apache.commons.configuration.Configuration configuration, String confKey) {
    Float f;
    try {
        f = configuration.getFloat(confKey);
    } catch(ConversionException e) {
        LOG.error("Missing numeric floating point value for: " + confKey);
        return false;
    }
    if (f <= 0.0f) {
        LOG.error("Must be positive floating point number: " + confKey);
        return false;
    }
    return true;
}
项目:AisAbnormal    文件:Configuration.java   
private static boolean isValidPositiveOrZeroFloat(org.apache.commons.configuration.Configuration configuration, String confKey) {
    Float f;
    try {
        f = configuration.getFloat(confKey);
    } catch(ConversionException e) {
        LOG.error("Missing numeric floating point value for: " + confKey);
        return false;
    }
    if (f < 0.0f) {
        LOG.error("Must be positive or zero floating point number: " + confKey);
        return false;
    }
    return true;
}
项目:OpenNMS    文件:SupportRtConfigDao.java   
public Long getQueueId() {
    if (getProperties() == null) {
        return null;
    }
    try {
        return getProperties().getLong("support.queueId");
    } catch (final ConversionException e) {
        return null;
    }
}
项目:smartenit    文件:SBox.java   
/**
 * The method that reads and sets the configuration parameters from file. 
 * 
 */
private static void readConfigurationProperties () {
    logger.debug("Reading configuration parameters.");
    PropertiesConfiguration config = null;

    try {
        config = new PropertiesConfiguration(SBoxProperties.PROPERTIES_FILE_NAME);
        SBoxProperties.CONNECTION_RETRIES = config.getInt("connection.retries");
        SBoxProperties.CONNECTION_TIMEOUT = config.getLong("connection.timeout");
        SBoxProperties.CORE_POOL_SIZE = config.getInt("core.pool.size");
        SBoxProperties.DB_FILE = config.getString("db.file");
        SBoxProperties.INTER_SBOX_PORT = config.getInt("inter.sbox.port");
        SBoxProperties.MAX_FETCHING_TIME = config.getLong("max.fetching.time");

        SBoxProperties.RESET_COMP_VECTOR_AFTER_SAMPLE = config.getBoolean("reset.comp.vector.after.sample");

        SBoxProperties.LOG_TRAFFIC_DETAILS = config.getBoolean("log.traffic.details");
        SBoxProperties.TRAFFIC_DETAILS_FILE_PATH = config.getString("traffic.details.file.path");
        SBoxProperties.TRAFFIC_DETAILS_FILE_NAME = config.getString("traffic.details.file.name");

        SBoxProperties.DEFAULT_REF_VECTOR_FILE = config.getString("default.ref.vector.file");

    } catch (ConfigurationException e) {
        logger.warn("Exception while loading configuration file " 
                + SBoxProperties.PROPERTIES_FILE_NAME + ".");

    }  catch (ConversionException e2) {
        logger.warn("Invalid format of configuration parameters, using default.");

    }

    logger.debug("Configuration parameters: \n" 
            + "connection.retries: " + SBoxProperties.CONNECTION_RETRIES + "\n"
            + "connection.timeout: " + SBoxProperties.CONNECTION_TIMEOUT + "\n"
            + "core.pool.size: " + SBoxProperties.CORE_POOL_SIZE + "\n"
            + "db.file: " + SBoxProperties.DB_FILE + "\n"
            + "inter.sbox.port: " + SBoxProperties.INTER_SBOX_PORT + "\n"
            + "max.fetching.time: " + SBoxProperties.MAX_FETCHING_TIME + "\n"
            + "reset.comp.vector.after.sample: " + SBoxProperties.RESET_COMP_VECTOR_AFTER_SAMPLE + "\n"
            + "log.traffic.details: " + SBoxProperties.LOG_TRAFFIC_DETAILS + "\n"
            + "traffic.details.file.path: " + SBoxProperties.TRAFFIC_DETAILS_FILE_PATH + "\n"
            + "traffic.details.file.name: " + SBoxProperties.TRAFFIC_DETAILS_FILE_NAME + "\n"
            + "default.ref.vector.file: " + SBoxProperties.DEFAULT_REF_VECTOR_FILE);
}
项目:hraven    文件:JobHistoryFileParserHadoop2.java   
/**
 * calculate mega byte millis puts as:
 * if not uberized:
 *        map slot millis * mapreduce.map.memory.mb
 *        + reduce slot millis * mapreduce.reduce.memory.mb
 *        + yarn.app.mapreduce.am.resource.mb * job runtime
 * if uberized:
 *        yarn.app.mapreduce.am.resource.mb * job run time
 */
@Override
public Long getMegaByteMillis() {

  long endTime = this.jobDetails.getFinishTime();
  long startTime = this.jobDetails.getSubmitTime();
  if (endTime == Constants.NOTFOUND_VALUE || startTime == Constants.NOTFOUND_VALUE)
  {
    throw new ProcessingException("Cannot calculate megabytemillis for " + jobKey
        + " since one or more of endTime " + endTime + " startTime " + startTime
        + " not found!");
  }

  long jobRunTime = 0L;
  long amMb = 0L;
  long mapMb = 0L;
  long reduceMb = 0L;

  jobRunTime = endTime - startTime;

  if (jobConf == null) {
    LOG.error("job conf is null? for job key: " + jobKey.toString());
    return null;
  }

  // get am memory mb, map memory mb, reducer memory mb from job conf
  try {
    amMb = jobConf.getLong(Constants.AM_MEMORY_MB_CONF_KEY, Constants.NOTFOUND_VALUE);
    mapMb = jobConf.getLong(Constants.MAP_MEMORY_MB_CONF_KEY,  Constants.NOTFOUND_VALUE);
    reduceMb = jobConf.getLong(Constants.REDUCE_MEMORY_MB_CONF_KEY,  Constants.NOTFOUND_VALUE);
  } catch (ConversionException ce) {
    LOG.error(" Could not convert to long ", ce);
    throw new ProcessingException(
        " Can't calculate megabytemillis since conversion to long failed", ce);
  }
  if (amMb == Constants.NOTFOUND_VALUE ) {
    throw new ProcessingException("Cannot calculate megabytemillis for " + jobKey
        + " since " + Constants.AM_MEMORY_MB_CONF_KEY + " not found!");
  }

  long mapSlotMillis = this.jobDetails.getMapSlotMillis();
  long reduceSlotMillis = this.jobDetails.getReduceSlotMillis();

  /* in case of older versions of hadoop2
   *  the counter of mb millis is not available
   * then use slot millis counter value
   */
  if (this.mapMbMillis == Constants.NOTFOUND_VALUE) {
    this.mapMbMillis = (mapMb * mapSlotMillis);
  }
  if (this.reduceMbMillis == Constants.NOTFOUND_VALUE) {
     this.reduceMbMillis = (reduceMb * reduceSlotMillis);
  }

  long mbMillis = 0L;
  if (uberized) {
    mbMillis = amMb * jobRunTime;
  } else {
    mbMillis = this.mapMbMillis + this.reduceMbMillis + (amMb * jobRunTime);
  }

  LOG.debug("For " + jobKey.toString() + "\n" + Constants.MEGABYTEMILLIS + " is " + mbMillis
      + " since \n uberized: " + uberized + " \n " + "mapMbMillis: " + mapMbMillis
      + " reduceMbMillis:" + reduceMbMillis + "mapMb: " + mapMb + " mapSlotMillis: "
      + mapSlotMillis + " \n " + " reduceMb: " + reduceMb + " reduceSlotMillis: "
      + reduceSlotMillis + " \n " + " amMb: " + amMb + " jobRunTime: " + jobRunTime
      + " start time: " + startTime + " endtime " + endTime);

  this.jobDetails.setMegabyteMillis(mbMillis);
  return mbMillis;
}
项目:Prospero    文件:Config.java   
/**
    * Get a boolean associated with the given configuration key.
    * 
    * @param key
    *            The configuration key.
    * @return The associated boolean.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Boolean.
    */
   public static boolean getBoolean(String key) {
try {
    return config.getBoolean(key);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a {@link Boolean} associated with the given configuration key.
    * 
    * @param key
    *            The configuration key.
    * @param defaultValue
    *            The default value.
    * @return The associated boolean if key is found and has valid format,
    *         default value otherwise.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Boolean.
    */
   public static Boolean getBoolean(String key, Boolean defaultValue) {
try {
    return config.getBoolean(key, defaultValue);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a boolean associated with the given configuration key. If the key
    * doesn't map to an existing object, the default value is returned.
    * 
    * @param key
    *            The configuration key.
    * @param defaultValue
    *            The default value.
    * @return The associated boolean.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Boolean.
    */
   public static boolean getBoolean(String key, boolean defaultValue) {
try {
    return config.getBoolean(key, defaultValue);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a byte associated with the given configuration key.
    * 
    * @param key
    *            The configuration key.
    * @return The associated byte.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Byte.
    */
   public static byte getByte(String key) {
try {
    return config.getByte(key);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a {@link Byte} associated with the given configuration key.
    * 
    * @param key
    *            The configuration key.
    * @param defaultValue
    *            The default value.
    * @return The associated byte if key is found and has valid format, default
    *         value otherwise.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Byte.
    */
   public static Byte getByte(String key, Byte defaultValue) {
try {
    return config.getByte(key, defaultValue);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a byte associated with the given configuration key. If the key
    * doesn't map to an existing object, the default value is returned.
    * 
    * @param key
    *            The configuration key.
    * @param defaultValue
    *            The default value.
    * @return The associated byte.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Byte.
    */
   public static byte getByte(String key, byte defaultValue) {
try {
    return config.getByte(key, defaultValue);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a double associated with the given configuration key.
    * 
    * @param key
    *            The configuration key.
    * @return The associated double.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Double.
    */
   public static double getDouble(String key) {
try {
    return config.getDouble(key);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a {@link Double} associated with the given configuration key.
    * 
    * @param key
    *            The configuration key.
    * @param defaultValue
    *            The default value.
    * @return The associated double if key is found and has valid format,
    *         default value otherwise.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Double.
    */
   public static Double getDouble(String key, Double defaultValue) {
try {
    return config.getDouble(key, defaultValue);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a double associated with the given configuration key. If the key
    * doesn't map to an existing object, the default value is returned.
    * 
    * @param key
    *            The configuration key.
    * @param defaultValue
    *            The default value.
    * @return The associated double.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Double.
    */
   public static double getDouble(String key, double defaultValue) {
try {
    return config.getDouble(key, defaultValue);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a float associated with the given configuration key.
    * 
    * @param key
    *            The configuration key.
    * @return The associated float.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Float.
    */
   public static float getFloat(String key) {
try {
    return config.getFloat(key);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a {@link Float} associated with the given configuration key. If the
    * key doesn't map to an existing object, the default value is returned.
    * 
    * @param key
    *            The configuration key.
    * @param defaultValue
    *            The default value.
    * @return The associated float if key is found and has valid format,
    *         default value otherwise.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Float.
    */
   public static Float getFloat(String key, Float defaultValue) {
try {
    return config.getFloat(key, defaultValue);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a float associated with the given configuration key. If the key
    * doesn't map to an existing object, the default value is returned.
    * 
    * @param key
    *            The configuration key.
    * @param defaultValue
    *            The default value.
    * @return The associated float.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Float.
    */
   public static float getFloat(String key, float defaultValue) {
try {
    return config.getFloat(key, defaultValue);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a int associated with the given configuration key.
    * 
    * @param key
    *            The configuration key.
    * @return The associated int.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Integer.
    */
   public static int getInt(String key) {
try {
    return config.getInt(key);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }
项目:Prospero    文件:Config.java   
/**
    * Get a int associated with the given configuration key. If the key doesn't
    * map to an existing object, the default value is returned.
    * 
    * @param key
    *            The configuration key.
    * @param defaultValue
    *            The default value.
    * @return The associated int.
    * @throws ProsperoConfigConversionException
    *             is thrown if the key maps to an object that is not a Integer.
    */
   public static int getInt(String key, int defaultValue) {
try {
    return config.getInt(key, defaultValue);
} catch (ConversionException ce) {
    throw new ProsperoConfigConversionException(ce);
}
   }