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

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

Introduction

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

Prototype

boolean getBoolean(String key);

Source Link

Document

Get a boolean associated with the given configuration key.

Usage

From source file:org.apache.marmotta.loader.core.test.CLITest.java

@Test
public void testStatisticsWith() throws ParseException {
    Configuration cfg = MarmottaLoader.parseOptions(new String[] { "-s", "file.png", "-f", "file1.ttl" });

    Assert.assertNotNull(cfg.getProperty(LoaderOptions.STATISTICS_ENABLED));
    Assert.assertNotNull(cfg.getProperty(LoaderOptions.STATISTICS_GRAPH));

    Assert.assertTrue(cfg.getBoolean(LoaderOptions.STATISTICS_ENABLED));
    Assert.assertEquals("file.png", cfg.getString(LoaderOptions.STATISTICS_GRAPH));
}

From source file:org.apache.marmotta.loader.core.test.CLITest.java

@Test
public void testPluginBoolean() throws ParseException {
    Configuration cfg = MarmottaLoader.parseOptions(new String[] { "-E", "-f", "file1.ttl" });

    Assert.assertNotNull(cfg.getProperty("backend.dummy.enabled"));

    Assert.assertTrue(cfg.getBoolean("backend.dummy.enabled"));

}

From source file:org.apache.tinkerpop.gremlin.driver.Settings.java

/**
 * Read configuration from a file into a new {@link Settings} object.
 *///from   w  w w  . java2s . c o m
public static Settings from(final Configuration conf) {
    final Settings settings = new Settings();

    if (conf.containsKey("port"))
        settings.port = conf.getInt("port");

    if (conf.containsKey("nioPoolSize"))
        settings.nioPoolSize = conf.getInt("nioPoolSize");

    if (conf.containsKey("workerPoolSize"))
        settings.workerPoolSize = conf.getInt("workerPoolSize");

    if (conf.containsKey("username"))
        settings.username = conf.getString("username");

    if (conf.containsKey("password"))
        settings.password = conf.getString("password");

    if (conf.containsKey("jaasEntry"))
        settings.jaasEntry = conf.getString("jaasEntry");

    if (conf.containsKey("protocol"))
        settings.protocol = conf.getString("protocol");

    if (conf.containsKey("hosts"))
        settings.hosts = conf.getList("hosts").stream().map(Object::toString).collect(Collectors.toList());

    if (conf.containsKey("serializer.className")) {
        final SerializerSettings serializerSettings = new SerializerSettings();
        final Configuration serializerConf = conf.subset("serializer");

        if (serializerConf.containsKey("className"))
            serializerSettings.className = serializerConf.getString("className");

        final Configuration serializerConfigConf = conf.subset("serializer.config");
        if (IteratorUtils.count(serializerConfigConf.getKeys()) > 0) {
            final Map<String, Object> m = new HashMap<>();
            serializerConfigConf.getKeys().forEachRemaining(name -> {
                m.put(name, serializerConfigConf.getProperty(name));
            });
            serializerSettings.config = m;
        }
        settings.serializer = serializerSettings;
    }

    final Configuration connectionPoolConf = conf.subset("connectionPool");
    if (IteratorUtils.count(connectionPoolConf.getKeys()) > 0) {
        final ConnectionPoolSettings cpSettings = new ConnectionPoolSettings();

        if (connectionPoolConf.containsKey("channelizer"))
            cpSettings.channelizer = connectionPoolConf.getString("channelizer");

        if (connectionPoolConf.containsKey("enableSsl"))
            cpSettings.enableSsl = connectionPoolConf.getBoolean("enableSsl");

        if (connectionPoolConf.containsKey("trustCertChainFile"))
            cpSettings.trustCertChainFile = connectionPoolConf.getString("trustCertChainFile");

        if (connectionPoolConf.containsKey("minSize"))
            cpSettings.minSize = connectionPoolConf.getInt("minSize");

        if (connectionPoolConf.containsKey("maxSize"))
            cpSettings.maxSize = connectionPoolConf.getInt("maxSize");

        if (connectionPoolConf.containsKey("minSimultaneousUsagePerConnection"))
            cpSettings.minSimultaneousUsagePerConnection = connectionPoolConf
                    .getInt("minSimultaneousUsagePerConnection");

        if (connectionPoolConf.containsKey("maxSimultaneousUsagePerConnection"))
            cpSettings.maxSimultaneousUsagePerConnection = connectionPoolConf
                    .getInt("maxSimultaneousUsagePerConnection");

        if (connectionPoolConf.containsKey("maxInProcessPerConnection"))
            cpSettings.maxInProcessPerConnection = connectionPoolConf.getInt("maxInProcessPerConnection");

        if (connectionPoolConf.containsKey("minInProcessPerConnection"))
            cpSettings.minInProcessPerConnection = connectionPoolConf.getInt("minInProcessPerConnection");

        if (connectionPoolConf.containsKey("maxWaitForConnection"))
            cpSettings.maxWaitForConnection = connectionPoolConf.getInt("maxWaitForConnection");

        if (connectionPoolConf.containsKey("maxContentLength"))
            cpSettings.maxContentLength = connectionPoolConf.getInt("maxContentLength");

        if (connectionPoolConf.containsKey("reconnectInterval"))
            cpSettings.reconnectInterval = connectionPoolConf.getInt("reconnectInterval");

        if (connectionPoolConf.containsKey("reconnectInitialDelay"))
            cpSettings.reconnectInitialDelay = connectionPoolConf.getInt("reconnectInitialDelay");

        if (connectionPoolConf.containsKey("resultIterationBatchSize"))
            cpSettings.resultIterationBatchSize = connectionPoolConf.getInt("resultIterationBatchSize");

        if (connectionPoolConf.containsKey("keepAliveInterval"))
            cpSettings.keepAliveInterval = connectionPoolConf.getLong("keepAliveInterval");

        settings.connectionPool = cpSettings;
    }

    return settings;
}

From source file:org.apache.tinkerpop.gremlin.process.computer.bulkloading.IncrementalBulkLoader.java

/**
 * {@inheritDoc}/*from  w  w  w.  ja v a2 s.c o  m*/
 */
@Override
public void configure(final Configuration configuration) {
    if (configuration.containsKey(BulkLoaderVertexProgram.BULK_LOADER_VERTEX_ID_CFG_KEY)) {
        bulkLoaderVertexId = configuration.getString(BulkLoaderVertexProgram.BULK_LOADER_VERTEX_ID_CFG_KEY);
    }
    if (configuration.containsKey(BulkLoaderVertexProgram.USER_SUPPLIED_IDS_CFG_KEY)) {
        userSuppliedIds = configuration.getBoolean(BulkLoaderVertexProgram.USER_SUPPLIED_IDS_CFG_KEY);
    }
    if (configuration.containsKey(BulkLoaderVertexProgram.KEEP_ORIGINAL_IDS_CFG_KEY)) {
        keepOriginalIds = configuration.getBoolean(BulkLoaderVertexProgram.KEEP_ORIGINAL_IDS_CFG_KEY);
    }
}

From source file:org.apache.tinkerpop.gremlin.process.computer.bulkloading.OneTimeBulkLoader.java

/**
 * {@inheritDoc}//from w w w. ja  v a  2  s . c  om
 */
@Override
public void configure(final Configuration configuration) {
    if (configuration.containsKey(BulkLoaderVertexProgram.USER_SUPPLIED_IDS_CFG_KEY)) {
        userSuppliedIds = configuration.getBoolean(BulkLoaderVertexProgram.USER_SUPPLIED_IDS_CFG_KEY);
    }
}

From source file:org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy.java

public static PartitionStrategy create(final Configuration configuration) {
    final PartitionStrategy.Builder builder = PartitionStrategy.build();
    if (configuration.containsKey(INCLUDE_META_PROPERTIES))
        builder.includeMetaProperties(configuration.getBoolean(INCLUDE_META_PROPERTIES));
    if (configuration.containsKey(WRITE_PARTITION))
        builder.writePartition(configuration.getString(WRITE_PARTITION));
    if (configuration.containsKey(PARTITION_KEY))
        builder.partitionKey(configuration.getString(PARTITION_KEY));
    if (configuration.containsKey(READ_PARTITIONS))
        builder.readPartitions(new ArrayList((Collection) configuration.getProperty(READ_PARTITIONS)));
    return builder.create();
}

From source file:org.apache.tinkerpop.gremlin.util.SystemUtilTest.java

@Test
public void shouldLoadSystemProperties() {
    System.setProperty("blah.aa", "1");
    System.setProperty("blah.b", "true");
    System.setProperty("blah.c", "three");
    System.setProperty("bleep.d", "false");
    Configuration configuration = SystemUtil.getSystemPropertiesConfiguration("blah", false);
    assertEquals(3, IteratorUtils.count(configuration.getKeys()));
    assertEquals(1, configuration.getInt("blah.aa"));
    assertTrue(configuration.getBoolean("blah.b"));
    assertEquals("three", configuration.getProperty("blah.c"));
    assertFalse(configuration.containsKey("d") || configuration.containsKey("bleep.d"));
    System.clearProperty("blah.aa");
    System.clearProperty("blah.b");
    System.clearProperty("blah.c");
    System.clearProperty("bleep.d");
}

From source file:org.apache.tinkerpop.gremlin.util.SystemUtilTest.java

@Test
public void shouldTrimSystemPropertyPrefixes() {
    System.setProperty("blah.a", "1");
    System.setProperty("blah.bbb", "true");
    System.setProperty("blah.c", "three");
    System.setProperty("bleep.d", "false");
    Configuration configuration = SystemUtil.getSystemPropertiesConfiguration("blah", true);
    assertEquals(3, IteratorUtils.count(configuration.getKeys()));
    assertEquals(1, configuration.getInt("a"));
    assertTrue(configuration.getBoolean("bbb"));
    assertEquals("three", configuration.getProperty("c"));
    assertFalse(configuration.containsKey("d") || configuration.containsKey("bleep.d"));
    System.clearProperty("blah.a");
    System.clearProperty("blah.bbb");
    System.clearProperty("blah.c");
    System.clearProperty("bleep.d");
}

From source file:org.apache.tinkerpop.gremlin.util.SystemUtilTest.java

@Test
public void shouldTrimSystemPropertyPrefixesAndNoMore() {
    System.setProperty("blah.a.x", "1");
    System.setProperty("blah.b.y", "true");
    System.setProperty("blah.cc.zzz", "three");
    System.setProperty("bleep.d.d", "false");
    Configuration configuration = SystemUtil.getSystemPropertiesConfiguration("blah", true);
    assertEquals(3, IteratorUtils.count(configuration.getKeys()));
    assertEquals(1, configuration.getInt("a.x"));
    assertTrue(configuration.getBoolean("b.y"));
    assertEquals("three", configuration.getProperty("cc.zzz"));
    assertFalse(configuration.containsKey("d") || configuration.containsKey("bleep.d"));
    assertFalse(configuration.containsKey("d.d") || configuration.containsKey("bleep.d.d"));
    System.clearProperty("blah.a.x");
    System.clearProperty("blah.b.y");
    System.clearProperty("blah.cc.zzz");
    System.clearProperty("bleep.d.d");
}

From source file:org.apache.wookie.helpers.WidgetInstanceFactory.java

/**
 * Create a new widget instance object, populate its default values, and save it.
 * @param persistenceManager/*from  w w  w  . ja v  a2s .c o  m*/
 * @param api_key
 * @param userId
 * @param sharedDataKey
 * @param widget
 * @param nonce
 * @param idKey
 * @param properties
 * @return
 */
private IWidgetInstance addNewWidgetInstance(IPersistenceManager persistenceManager, String api_key,
        String userId, String sharedDataKey, IWidget widget, String nonce, String idKey,
        Configuration properties, String lang) {
    IWidgetInstance widgetInstance = persistenceManager.newInstance(IWidgetInstance.class);
    widgetInstance.setUserId(userId);
    widgetInstance.setSharedDataKey(sharedDataKey);
    widgetInstance.setIdKey(idKey);
    widgetInstance.setNonce(nonce);
    widgetInstance.setApiKey(api_key);
    if (LocalizationUtils.isValidLanguageTag(lang))
        widgetInstance.setLang(lang);
    // set the defaults widget for this type         
    widgetInstance.setWidget(widget);
    widgetInstance.setHidden(false);
    widgetInstance.setShown(true);
    widgetInstance.setUpdated(false);
    widgetInstance.setLocked(false);

    // Setup opensocial token if needed
    widgetInstance.setOpensocialToken(""); //$NON-NLS-1$
    if (properties.getBoolean("opensocial.enable")) { //$NON-NLS-1$
        try {
            if (properties.getString("opensocial.token").equals("secure")) { //$NON-NLS-1$ //$NON-NLS-2$
                widgetInstance.setOpensocialToken(OpenSocialUtils.createEncryptedToken(widgetInstance,
                        properties.getString("opensocial.key"), localizedMessages)); //$NON-NLS-1$
            } else {
                widgetInstance.setOpensocialToken(
                        OpenSocialUtils.createPlainToken(widgetInstance, localizedMessages));
            }
        } catch (Exception e) {
            _logger.error(e.getMessage());
        }
    }

    // add in the sharedDataKey as a preference so that a widget can know
    // what sharedData event to listen to later
    setPreference(persistenceManager, widgetInstance, "sharedDataKey", sharedDataKey, true);//$NON-NLS-1$

    // add in widget defaults
    for (IPreferenceDefault pref : widget.getPreferenceDefaults()) {
        setPreference(persistenceManager, widgetInstance, pref.getPreference(), pref.getValue(),
                pref.isReadOnly());
    }

    // Save
    persistenceManager.save(widgetInstance);

    return widgetInstance;
}