Example usage for org.apache.commons.configuration CompositeConfiguration getInt

List of usage examples for org.apache.commons.configuration CompositeConfiguration getInt

Introduction

In this page you can find the example usage for org.apache.commons.configuration CompositeConfiguration getInt.

Prototype

public int getInt(String key) 

Source Link

Usage

From source file:com.runwaysdk.configuration.CommonsConfigurationTest.java

@Test
public void testCommonsConfigOverride() {
    BaseConfiguration bc = new BaseConfiguration();
    BaseConfiguration bc2 = new BaseConfiguration();

    bc2.addProperty("test.prop", 52);

    CompositeConfiguration cconfig = new CompositeConfiguration();
    cconfig.addConfiguration(bc);/*ww w. ja  va  2  s.  co m*/
    cconfig.addConfiguration(bc2);

    bc.addProperty("test.prop", 112);

    Assert.assertEquals(112, cconfig.getInt("test.prop"));
}

From source file:com.runwaysdk.configuration.CommonsConfigurationTest.java

@Test
public void testCommonsConfigOverrideSetVsAdd() {
    BaseConfiguration bc = new BaseConfiguration();
    BaseConfiguration bc2 = new BaseConfiguration();

    bc2.addProperty("test.prop", 52);

    CompositeConfiguration cconfig = new CompositeConfiguration();
    cconfig.addConfiguration(bc);/*w w w .ja v a 2 s .c o m*/
    cconfig.addConfiguration(bc2);

    bc.setProperty("test.prop", 112);

    Assert.assertEquals(112, cconfig.getInt("test.prop"));
}

From source file:br.eti.kinoshita.testlinkjavaapi.TestLinkAPI.java

/**
 * Creates XML-RPC client configuration.
 * /*from w w w  . java2 s  .  c  om*/
 * By default enabled for extensions is always true. 
 * 
 * @param url Application URL.
 * @param appConfig Application composite configuration.
 * @return XML-RPC client configuration.
 */
private XmlRpcClientConfigImpl createXmlRpcClientConfiguration(URL url, CompositeConfiguration appConfig) {
    final XmlRpcClientConfigImpl xmlRpcClientConfig = new XmlRpcClientConfigImpl();

    xmlRpcClientConfig.setServerURL(url);
    xmlRpcClientConfig.setEnabledForExtensions(true);

    xmlRpcClientConfig.setBasicEncoding(appConfig.getString(XMLRPC_BASIC_ENCODING));
    xmlRpcClientConfig.setBasicPassword(appConfig.getString(XMLRPC_BASIC_PASSWORD));
    xmlRpcClientConfig.setBasicUserName(appConfig.getString(XMLRPC_BASIC_USERNAME));

    try {
        xmlRpcClientConfig.setConnectionTimeout(appConfig.getInt(XMLRPC_CONNECTION_TIMEOUT));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }

    try {
        xmlRpcClientConfig.setContentLengthOptional(appConfig.getBoolean(XMLRPC_CONTENT_LENGTH_OPTIONAL));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }

    try {
        xmlRpcClientConfig.setEnabledForExceptions(appConfig.getBoolean(XMLRPC_ENABLED_FOR_EXCEPTIONS));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }

    xmlRpcClientConfig.setEncoding(appConfig.getString(XMLRPC_ENCODING));

    try {
        xmlRpcClientConfig.setGzipCompressing(appConfig.getBoolean(XMLRPC_GZIP_COMPRESSION));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }

    try {
        xmlRpcClientConfig.setGzipRequesting(appConfig.getBoolean(XMLRPC_GZIP_REQUESTING));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }

    try {
        xmlRpcClientConfig.setReplyTimeout(appConfig.getInt(XMLRPC_REPLY_TIMEOUT));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }

    xmlRpcClientConfig.setUserAgent(appConfig.getString(XMLRPC_USER_AGENT));

    return xmlRpcClientConfig;
}

From source file:org.mozilla.testopia.transport.TestopiaXmlRpcClient.java

/**
 * Creates XML-RPC client configuration.
 * @param configuration/*ww  w .  j a v a 2 s .c  o  m*/
 * @return XmlRpcClientConfig
 */
private XmlRpcClientConfig createXmlRpcClientConfiguration(CompositeConfiguration configuration) {
    final XmlRpcClientConfigImpl xmlRpcClientConfig = new XmlRpcClientConfigImpl();
    // basic settings
    xmlRpcClientConfig.setEnabledForExtensions(true);
    // xmlrpc basic encoding
    xmlRpcClientConfig.setBasicEncoding(configuration.getString(XMLRPC_BASIC_ENCODING));
    xmlRpcClientConfig.setBasicPassword(configuration.getString(XMLRPC_BASIC_PASSWORD));
    xmlRpcClientConfig.setBasicUserName(configuration.getString(XMLRPC_BASIC_USERNAME));
    // connectino timeout
    try {
        xmlRpcClientConfig.setConnectionTimeout(configuration.getInt(XMLRPC_CONNECTION_TIMEOUT));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }
    // content length optional
    try {
        xmlRpcClientConfig.setContentLengthOptional(configuration.getBoolean(XMLRPC_CONTENT_LENGTH_OPTIONAL));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }
    // xmlrpc enabled for exceptions
    try {
        xmlRpcClientConfig.setEnabledForExceptions(configuration.getBoolean(XMLRPC_ENABLED_FOR_EXCEPTIONS));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }
    // xmlrpc encoding
    xmlRpcClientConfig.setEncoding(configuration.getString(XMLRPC_ENCODING));
    // gzip compression
    try {
        xmlRpcClientConfig.setGzipCompressing(configuration.getBoolean(XMLRPC_GZIP_COMPRESSION));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }
    // gzip request
    try {
        xmlRpcClientConfig.setGzipRequesting(configuration.getBoolean(XMLRPC_GZIP_REQUESTING));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }
    // timeout
    try {
        xmlRpcClientConfig.setReplyTimeout(configuration.getInt(XMLRPC_REPLY_TIMEOUT));
    } catch (ConversionException ce) {
        this.debug(ce);
    } catch (NoSuchElementException nsee) {
        this.debug(nsee);
    }
    // user agent
    xmlRpcClientConfig.setUserAgent(configuration.getString(XMLRPC_USER_AGENT));
    return xmlRpcClientConfig;
}

From source file:tw.com.mt.DocAPIDemo.java

/**
 * Default constructor./*from w w  w .j  a  v a 2  s.c o  m*/
 */
public DocAPIDemo() {
    CompositeConfiguration config = new CompositeConfiguration();
    config.addConfiguration(new SystemConfiguration());
    try {
        config.addConfiguration(new PropertiesConfiguration(propertyFile));
        this.projObjKey = config.getInt("projObjKey");
        this.parentObjKey = config.getInt("parentObjKey");
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:tw.com.mt.ObsAPIDemo.java

/**
 * Default constructor./*  w  w  w.  j  a  va  2s. c  o m*/
 */
public ObsAPIDemo() {
    CompositeConfiguration config = new CompositeConfiguration();
    config.addConfiguration(new SystemConfiguration());
    try {
        config.addConfiguration(new PropertiesConfiguration(propertyFile));
        this.parentObjKey = config.getInt("parentObjKey");
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:tw.com.mt.TaskAPIDemo.java

/**
 * Default constructor./*from w  w  w  .jav  a 2  s .c  o  m*/
 */
public TaskAPIDemo() {
    CompositeConfiguration config = new CompositeConfiguration();
    config.addConfiguration(new SystemConfiguration());
    try {
        config.addConfiguration(new PropertiesConfiguration(propertyFile));
        this.projObjKey = config.getInt("projObjKey");
        this.parentObjKey = config.getInt("parentObjKey");
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:tw.com.mt.TopicAPIDemo.java

/**
 * Default constructor.//from  ww  w .ja va  2  s .  c  o m
 */
public TopicAPIDemo() {
    CompositeConfiguration config = new CompositeConfiguration();
    config.addConfiguration(new SystemConfiguration());
    try {
        config.addConfiguration(new PropertiesConfiguration(propertyFile));
        this.projObjKey = config.getInt("projObjKey");
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:umich.ms.batmass.gui.viewers.map2d.components.BaseMap2D.java

/**
 * TODO: this is a rather ugly solution overall, needs refactoring.
 * @throws ConfigurationException/*from   ww w  .j av a2 s  . co  m*/
 * @throws IOException
 */
private void setStaticVarsFromConfig() throws ConfigurationException, IOException {
    CompositeConfiguration config = Map2DOptions.getInstance().getConfig();

    doBasePeakMode = config.getBoolean("doBasePeakMode");
    doInterpRt = config.getBoolean("doUpscaling");
    doMzCloseZoomGapFilling = config.getBoolean("doMzCloseZoomGapFilling");
    doProfileModeGapFilling = config.getBoolean("doProfileModeGapFilling");
    colorLevels = config.getInt("colorLevels");
    colorPalette = Arrays.asList(Map2DOptions.getColorsFromConfig(config));
}