Example usage for java.util Properties getProperty

List of usage examples for java.util Properties getProperty

Introduction

In this page you can find the example usage for java.util Properties getProperty.

Prototype

public String getProperty(String key, String defaultValue) 

Source Link

Document

Searches for the property with the specified key in this property list.

Usage

From source file:cz.cuni.mff.ksi.jinfer.autoeditor.automatonvisualizer.layouts.LayoutHelperFactory.java

/**
 * Creates {@link Layout} which user selected in preferences.
 *
 * @param <T> Type parameter of specified automaton.
 * @param automaton Automaton to create layout from.
 * @param edgeLabelTransformer Transformer that can transform edge to string, which is displayed as its label.
 * @return Layout by user selection./*from   w  w w  . j  ava2s .c  o m*/
 */
public static <T> Layout<State<T>, Step<T>> createUserLayout(final Automaton<T> automaton,
        final Transformer<Step<T>, String> edgeLabelTransformer) throws InterruptedException {
    final Properties p = RunningProject.getActiveProjectProps(LayoutPropertiesPanel.NAME);

    final LayoutFactory f = ModuleSelectionHelper.lookupImpl(LayoutFactory.class,
            p.getProperty(LayoutPropertiesPanel.LAYOUT_PROP, LayoutPropertiesPanel.LAYOUT_DEFAULT));
    return f.createLayout(automaton, createGraph(automaton), edgeLabelTransformer);
}

From source file:com.bt.aloha.batchtest.WeekendBatchTest.java

protected static void configure(BatchTest batchTest) throws Exception {
    Properties properties = new Properties();
    InputStream is = new FileInputStream(CONFIG_FILE);
    properties.load(is);//from w  w w. j  a  va2 s  .c om
    is.close();
    sleepTime = Integer.parseInt(properties.getProperty("sleepTime", Integer.toString(defaultSleepTime)));
    batchTest.setAudioFileUri(properties.getProperty("audioFileUri", "/provisioned/behave.wav"));
    stop = Boolean.parseBoolean(properties.getProperty("stop", "false"));
    batchTest.setNumberOfRuns(Integer.parseInt(properties.getProperty("numberOfRuns", "1000")));
    int concurrentStarts = Integer.parseInt(properties.getProperty("numberOfConcurrentStarts", "4"));
    batchTest.setNumberOfConcurrentStarts(concurrentStarts);
    if (executorService == null)
        executorService = Executors.newFixedThreadPool(concurrentStarts);
    batchTest.setExecutorService(executorService);
    batchTest.setMaximumScenarioCompletionWaitTimeSeconds(
            Integer.parseInt(properties.getProperty("maximumScenarioCompletionWaitTimeSeconds", "60")));
    addBatchScenarios(batchTest);
}

From source file:dk.alexandra.fresco.suite.tinytables.prepro.TinyTablesPreproConfiguration.java

public static ProtocolSuiteConfiguration fromCmdLine(SCEConfiguration sceConf, CommandLine cmd)
        throws ParseException, IllegalArgumentException {

    Options options = new Options();

    TinyTablesPreproConfiguration configuration = new TinyTablesPreproConfiguration();

    /*//from w  w  w. jav  a  2 s .  c o m
     * Parse TinyTables specific options
     */

    String otExtensionOption = "tinytables.otExtension";
    String otExtensionPortOption = "tinytables.otExtensionPort";
    String tinytablesFileOption = "tinytables.file";

    options.addOption(Option.builder("D").desc(
            "Specify whether we should try to use SCAPIs OT-Extension lib. This requires the SCAPI library to be installed.")
            .longOpt(otExtensionOption).required(false).hasArgs().build());

    options.addOption(Option.builder("D")
            .desc("The port number for the OT-Extension lib. Both players should specify the same here.")
            .longOpt(otExtensionPortOption).required(false).hasArgs().build());

    options.addOption(Option.builder("D").desc("The file where the generated TinyTables should be stored.")
            .longOpt(tinytablesFileOption).required(false).hasArgs().build());

    Properties p = cmd.getOptionProperties("D");

    boolean useOtExtension = Boolean.parseBoolean(p.getProperty(otExtensionOption, "false"));
    configuration.setUseOtExtension(useOtExtension);

    int otExtensionPort = Integer.parseInt(p.getProperty(otExtensionPortOption, "9005"));
    Party sender = sceConf.getParties().get(1);
    configuration.setSenderAddress(InetSocketAddress.createUnresolved(sender.getHostname(), otExtensionPort));
    ;

    String tinyTablesFilePath = p.getProperty(tinytablesFileOption, "tinytables");
    File tinyTablesFile = new File(tinyTablesFilePath);
    configuration.setTinyTablesFile(tinyTablesFile);

    // We are not testing when running from command line
    configuration.setTesting(false);

    return configuration;
}

From source file:com.bt.aloha.batchtest.JmxScenarioExporter.java

protected static void configure(BatchTest batchTest) throws Exception {
    Properties properties = new Properties();
    InputStream is = new FileInputStream(CONFIG_FILE);
    properties.load(is);//from ww  w.  j  a va  2  s.  c o m
    is.close();
    batchTest.setAudioFileUri(properties.getProperty("audioFileUri", "/provisioned/behave.wav"));
    batchTest.setNumberOfRuns(1);
    batchTest.setNumberOfConcurrentStarts(1);
    batchTest.setMaximumScenarioCompletionWaitTimeSeconds(
            Integer.parseInt(properties.getProperty("maximumScenarioCompletionWaitTimeSeconds", "60")));
    batchTest.setExecutorService(Executors.newFixedThreadPool(4));
    addBatchScenarios(batchTest);
}

From source file:forge.properties.ForgeProfileProperties.java

private static Map<String, String> getMap(final Properties props, final String propertyKey) {
    final String strMap = props.getProperty(propertyKey, "").trim();
    return FileSection.parseToMap(strMap, "->", "|");
}

From source file:com.jkoolcloud.tnt4j.streams.custom.kafka.interceptors.InterceptorsTest.java

private static Consumer<String, String> initConsumer() throws Exception {
    Properties props = new Properties();
    props.load(new FileReader(System.getProperty("consumer.config"))); // NON-NLS
    topicName = props.getProperty("test.app.topic.name", "tnt4j_streams_kafka_intercept_test_page_visits"); // NON-NLS
    props.remove("test.app.topic.name");

    Consumer<String, String> consumer = new KafkaConsumer<>(props);
    consumer.subscribe(Collections.singletonList(topicName));

    return consumer;
}

From source file:ezbake.deployer.utilities.VersionHelper.java

private static String getVersionFromPomProperties(File artifact) throws IOException {
    List<JarEntry> pomPropertiesFiles = new ArrayList<>();
    String versionNumber = null;//from   w ww.jav  a 2 s.  co  m
    try (JarFile jar = new JarFile(artifact)) {
        JarEntry entry;
        Enumeration<JarEntry> entries = jar.entries();
        while (entries.hasMoreElements()) {
            entry = entries.nextElement();
            if (!entry.isDirectory() && entry.getName().endsWith("pom.properties")) {
                pomPropertiesFiles.add(entry);
            }
        }

        if (pomPropertiesFiles.size() == 1) {
            Properties pomProperties = new Properties();
            pomProperties.load(jar.getInputStream(pomPropertiesFiles.get(0)));
            versionNumber = pomProperties.getProperty("version", null);
        } else {
            logger.debug("Found {} pom.properties files. Cannot use that for version",
                    pomPropertiesFiles.size());
        }
    }
    return versionNumber;
}

From source file:com.siemens.sw360.importer.LicenseImporter.java

private static void addLicenses(LicenseService.Iface licenseClient) throws IOException {
    Properties properties = CommonUtils.loadProperties(LicenseImporter.class, "/csvfiles.properties");
    String riskCategoryFilename = properties.getProperty("riskCategoryFilename", "dbo.Riskcategory.csv");
    String riskFilename = properties.getProperty("riskFilename", "dbo.Risk.csv");
    String obligationFilename = properties.getProperty("obligationFilename", "dbo.Obligation.csv");
    String obligationTodoFilename = properties.getProperty("obligationTodoFilename", "dbo.obligationtodo.csv");
    String todoFilename = properties.getProperty("todoFilename", "dbo.Todo.csv");
    String licenseTypeFilename = properties.getProperty("licenseTypeFilename", "dbo.Licensetype.csv");
    String licenseTodoFilename = properties.getProperty("licenseTodoFilename", "dbo.licensetodo.csv");
    String licenseRiskFilename = properties.getProperty("licenseRiskFilename", "dbo.licenserisk.csv");
    String licenseFilename = properties.getProperty("licenseFilename", "dbo.License.csv");

    log.debug("Parsing risk Categories ...");
    Map<Integer, RiskCategory> riskCategoryMap = getIntegerRiskCategoryMap(licenseClient, riskCategoryFilename);

    log.debug("Parsing risks ...");
    Map<Integer, Risk> riskMap = getIntegerRiskMap(licenseClient, riskFilename, riskCategoryMap);

    log.debug("Parsing obligations ...");
    Map<Integer, Obligation> obligationMap = getIntegerObligationMap(licenseClient, obligationFilename);

    log.debug("Parsing obligation todos ...");
    Map<Integer, Set<Integer>> obligationTodoMapping;
    try (final InputStream in = getURL(obligationTodoFilename).openStream()) {
        List<CSVRecord> obligationTodoRecords = ImportCSV.readAsCSVRecords(in);
        obligationTodoMapping = ConvertRecord.convertObligationTodo(obligationTodoRecords);
    }//from  ww w.  j a va2  s.c om

    log.debug("Parsing todos ...");
    Map<Integer, Todo> todoMap;
    todoMap = getTodoMap(licenseClient, todoFilename, obligationMap, obligationTodoMapping);

    log.debug("Parsing license types ...");
    Map<Integer, LicenseType> licenseTypeMap = getLicenseTypeMap(licenseClient, licenseTypeFilename);

    log.debug("Parsing license todos ...");
    Map<String, Set<Integer>> licenseTodoMap;
    try (final InputStream in = getURL(licenseTodoFilename).openStream()) {
        List<CSVRecord> licenseTodoRecord = ImportCSV.readAsCSVRecords(in);
        licenseTodoMap = ConvertRecord.convertRelationalTable(licenseTodoRecord);
    }

    log.debug("Parsing license risks ...");
    Map<String, Set<Integer>> licenseRiskMap;
    try (final InputStream in = getURL(licenseRiskFilename).openStream()) {
        List<CSVRecord> licenseRiskRecord = ImportCSV.readAsCSVRecords(in);
        licenseRiskMap = ConvertRecord.convertRelationalTable(licenseRiskRecord);
    }

    log.debug("Parsing licenses ...");
    List<CSVRecord> licenseRecord;
    try (final InputStream in = getURL(licenseFilename).openStream()) {
        licenseRecord = ImportCSV.readAsCSVRecords(in);
    }

    final List<License> licensesToAdd = ConvertRecord.fillLicenses(licenseRecord, licenseTypeMap, todoMap,
            riskMap, licenseTodoMap, licenseRiskMap);

    ConvertRecord.addLicenses(licenseClient, licensesToAdd, log);
}

From source file:com.navercorp.pinpoint.collector.config.CollectorConfiguration.java

protected static String readString(Properties properties, String propertyName, String defaultValue) {
    final String result = properties.getProperty(propertyName, defaultValue);
    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("{}={}", propertyName, result);
    }//from   w w  w .j a  v a 2  s  .co m
    return result;
}

From source file:forge.properties.ForgeProfileProperties.java

private static int getInt(final Properties props, final String propertyKey, final int defaultValue) {
    final String strValue = props.getProperty(propertyKey, "").trim();
    if (StringUtils.isNotBlank(strValue) && StringUtils.isNumeric(strValue)) {
        return Integer.parseInt(strValue);
    }//  www  . j a  v a 2s  . c om
    return defaultValue;
}