本文整理汇总了Java中org.apache.commons.configuration.ConversionException类的典型用法代码示例。如果您正苦于以下问题:Java ConversionException类的具体用法?Java ConversionException怎么用?Java ConversionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConversionException类属于org.apache.commons.configuration包,在下文中一共展示了ConversionException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: readDefaultSharedFolders
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
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;
}
}
}
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:27,代码来源:PmsConfiguration.java
示例2: getCustomProgramPath
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
/**
* 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
);
}
}
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:30,代码来源:ConfigurableProgramPaths.java
示例3: getOptionValueFromConfig
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
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;
}
开发者ID:vmware,项目名称:vsphere-automation-sdk-java,代码行数:19,代码来源:ParametersHelper.java
示例4: buildConfigurationMap
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
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;
}
开发者ID:apache,项目名称:marmotta,代码行数:23,代码来源:ConfigurationWebService.java
示例5: setCustomProgramPathConfiguration
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
/**
* 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;
}
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:39,代码来源:ConfigurableProgramPaths.java
示例6: getInt
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
/**
* 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;
}
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:23,代码来源:ConfigurationReader.java
示例7: getLong
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
/**
* 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;
}
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:23,代码来源:ConfigurationReader.java
示例8: getDouble
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
/**
* 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;
}
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:23,代码来源:ConfigurationReader.java
示例9: getBoolean
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
/**
* 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;
}
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:23,代码来源:ConfigurationReader.java
示例10: getRetryCount
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
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;
}
}
开发者ID:proarc,项目名称:proarc,代码行数:12,代码来源:ExternalProcess.java
示例11: getTimeout
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
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;
}
}
开发者ID:proarc,项目名称:proarc,代码行数:11,代码来源:ExternalProcess.java
示例12: from
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
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;
}
开发者ID:proarc,项目名称:proarc,代码行数:13,代码来源:CejshConfig.java
示例13: getJavaScaling
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
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);
}
}
开发者ID:proarc,项目名称:proarc,代码行数:13,代码来源:ImportProfile.java
示例14: getPositiveInteger
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
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;
}
开发者ID:proarc,项目名称:proarc,代码行数:8,代码来源:ImportProfile.java
示例15: getString
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
@Override
public String getString(String key, String defaultValue) {
try {
String value = getConfiguration().getString(key, defaultValue);
return value;
} catch (ConversionException e) {
return defaultValue;
}
}
开发者ID:okinawaopenlabs,项目名称:of-patch-manager,代码行数:10,代码来源:ConfigImpl.java
示例16: getInt
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
@Override
public int getInt(String key, int defaultValue) {
try {
int value = getConfiguration().getInt(key, defaultValue);
return value;
} catch (ConversionException e) {
return defaultValue;
}
}
开发者ID:okinawaopenlabs,项目名称:of-patch-manager,代码行数:10,代码来源:ConfigImpl.java
示例17: test_getBigDecimal
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
@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());
}
开发者ID:be-hase,项目名称:honoumi,代码行数:13,代码来源:ApplicationPropertiesTest.java
示例18: test_getBigInteger
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
@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());
}
开发者ID:be-hase,项目名称:honoumi,代码行数:13,代码来源:ApplicationPropertiesTest.java
示例19: validatePositiveLong
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
/**
* 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);
}
}
开发者ID:wso2,项目名称:andes,代码行数:41,代码来源:ConfigurationPlugin.java
示例20: getQueueId
import org.apache.commons.configuration.ConversionException; //导入依赖的package包/类
public Long getQueueId() {
if (getProperties() == null) {
return null;
}
try {
return getProperties().getLong("support.queueId");
} catch (final ConversionException e) {
return null;
}
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:11,代码来源:SupportRtConfigDao.java
注:本文中的org.apache.commons.configuration.ConversionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论