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

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

Introduction

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

Prototype

Short getShort(String key, Short defaultValue);

Source Link

Document

Get a Short associated with the given configuration key.

Usage

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

protected static Object getTypedPropertyWithDefault(String key, Class theClass, Configuration properties,
        Object defaultValue) {/* w  ww.  j a v  a  2 s. com*/
    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:org.apache.atlas.services.DefaultMetadataService.java

public DefaultMetadataService(final MetadataRepository repository, final ITypeStore typeStore,
        final Collection<Provider<TypesChangeListener>> typeListenerProviders,
        final Collection<Provider<EntityChangeListener>> entityListenerProviders, final TypeSystem typeSystem,
        final Configuration configuration, TypeCache typeCache) throws AtlasException {
    this.typeStore = typeStore;
    this.typeSystem = typeSystem;
    /**//from   w  w  w.  java  2 s . c o  m
     * Ideally a TypeCache implementation should have been injected in the TypeSystemProvider,
     * but a singleton of TypeSystem is constructed privately within the class so that
     * clients of TypeSystem would never instantiate a TypeSystem object directly in
     * their code. As soon as a client makes a call to TypeSystem.getInstance(), they
     * should have the singleton ready for consumption. Manually inject TypeSystem with
     * the Guice-instantiated type cache here, before types are restored.
     * This allows cache implementations to participate in Guice dependency injection.
     */
    this.typeSystem.setTypeCache(typeCache);

    this.repository = repository;

    for (Provider<TypesChangeListener> provider : typeListenerProviders) {
        typeChangeListeners.add(provider.get());
    }

    for (Provider<EntityChangeListener> provider : entityListenerProviders) {
        entityChangeListeners.add(provider.get());
    }

    if (!HAConfiguration.isHAEnabled(configuration)) {
        restoreTypeSystem();
    }

    maxAuditResults = configuration.getShort(CONFIG_MAX_AUDIT_RESULTS, DEFAULT_MAX_AUDIT_RESULTS);
}

From source file:org.apache.bookkeeper.common.conf.ConfigKey.java

/**
 * Retrieve the setting from the configuration <tt>conf</tt> as a {@link Short} value.
 *
 * @param conf configuration to retrieve the setting
 * @return the value as a short number// w  w w  .  j ava  2 s  .  co  m
 */
public short getShort(Configuration conf) {
    checkArgument(type() == Type.SHORT, "'" + name() + "' is NOT a SHORT numeric setting");
    return conf.getShort(name(), (Short) defaultValue());
}