Example usage for java.util Properties stringPropertyNames

List of usage examples for java.util Properties stringPropertyNames

Introduction

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

Prototype

public Set<String> stringPropertyNames() 

Source Link

Document

Returns an unmodifiable set of keys from this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.

Usage

From source file:org.apache.gobblin.runtime.job_catalog.FSJobCatalogHelperTest.java

@Test(enabled = false, dependsOnMethods = { "testloadGenericJobConfigs" })
public void testloadGenericJobConfig() throws ConfigurationException, IOException {
    Path jobConfigPath = new Path(this.subDir11.getAbsolutePath(), "test111.pull");

    Properties jobProps = ConfigUtils
            .configToProperties(loader.loadPullFile(jobConfigPath, this.sysConfig, false));

    Assert.assertEquals(jobProps.stringPropertyNames().size(), 5);
    Assert.assertEquals(jobProps.getProperty(ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY),
            this.jobConfigDir.getAbsolutePath());
    Assert.assertEquals(jobProps.getProperty("k1"), "d1");
    Assert.assertEquals(jobProps.getProperty("k8"), "a8");
    Assert.assertEquals(jobProps.getProperty("k9"), "a8");
}

From source file:org.trancecode.xproc.cli.CommandLineExecutor.java

protected int execute(final String[] args, final InputStream stdin, final PrintStream stdout,
        final PrintStream stderr) {
    final GnuParser parser = new GnuParser();

    try {// ww w  . j  av  a2s. c  om
        final CommandLine commandLine = parser.parse(options, args);

        if (commandLine.hasOption(helpOption.getOpt())) {
            printHelp(stderr);
            return 0;
        }

        if (commandLine.hasOption(versionOption.getOpt())) {
            stderr.println(Tubular.productInformation());
            return 0;
        }

        if (commandLine.hasOption(verboseOption.getOpt())) {
            Logger.getRootLogger().setLevel(Level.DEBUG);
        }

        final PipelineConfiguration configurationPipelineContext = new PipelineConfiguration();
        final URIResolver uriResolver = configurationPipelineContext.getUriResolver();
        final PipelineProcessor pipelineProcessor = new PipelineProcessor(configurationPipelineContext);
        final String[] libraries = commandLine.getOptionValues(librariesOption.getOpt());

        if (libraries != null) {
            for (final String library : libraries) {
                // FIXME this will not really have any effect has the parsed
                // library is returned and the pipeline processor stays
                // unchanged
                pipelineProcessor.buildPipelineLibrary(
                        newSource(uriResolver, library, "Cannot read library from %s", library));
            }
        }

        // configurationPipelineContext.registerStepProcessor(null);
        final String xplValue = commandLine.getOptionValue(xplOption.getOpt());

        if (xplValue == null) {
            stderr.println("Required pipeline given using the --" + xplOption.getLongOpt() + " option.");
            printHelp(stderr);
            return 2;
        } else {
            final Source xplSource = newSource(uriResolver, xplValue, "Cannot read pipeline from %s", xplValue);

            if (xplSource != null) {
                final Pipeline buildPipeline = pipelineProcessor.buildPipeline(xplSource);
                final RunnablePipeline runnablePipeline = buildPipeline.load();

                final Properties portBindingProperties = commandLine
                        .getOptionProperties(portBindingOption.getOpt());
                for (final String portBindingName : portBindingProperties.stringPropertyNames()) {
                    final String portBindingValue = portBindingProperties.getProperty(portBindingName);
                    if (runnablePipeline.getPipeline().getPort(portBindingName).isInput()) {
                        LOG.debug("input port binding: {} = {}", portBindingName, portBindingValue);
                        runnablePipeline.bindSourcePort(portBindingName, newSource(uriResolver,
                                portBindingValue, "Cannot bind port to resource from %s", portBindingValue));
                    }
                }

                final Properties optionProperties = commandLine.getOptionProperties(optionOption.getOpt());
                for (final String optionName : optionProperties.stringPropertyNames()) {
                    final String optionValue = optionProperties.getProperty(optionName);
                    runnablePipeline.withOption(new QName(optionName), optionValue);
                }

                final Properties paramProperties = commandLine.getOptionProperties(paramOption.getOpt());
                for (final String paramName : paramProperties.stringPropertyNames()) {
                    final String paramValue = paramProperties.getProperty(paramName);
                    runnablePipeline.withParam(new QName(paramName), paramValue);
                }

                final PipelineResult pipelineResult = runnablePipeline.run();
                final Port primaryOutputPort = pipelineResult.getPipeline().getPrimaryOutputPort();
                if (primaryOutputPort != null && !portBindingProperties.stringPropertyNames()
                        .contains(primaryOutputPort.getPortName())) {
                    final XdmNode node = Iterables
                            .getOnlyElement(pipelineResult.readNodes(primaryOutputPort.getPortName()), null);
                    if (node != null) {
                        stdout.println(node);
                    }
                }
            } else {
                stderr.println("Argument given to option --xpl is neither a URL nor or a file.");
                printHelp(stderr);
                return 3;
            }
        }
    } catch (final ParseException ex) {
        printHelp(stderr);
        return 1;
    }
    return 0;
}

From source file:edu.buffalo.cse.pigout.Main.java

static int run(String args[], PigProgressNotificationListener listener) {
    int rc = 1;/* ww  w .  j  ava  2s .c o m*/
    boolean verbose = false;
    boolean pigoutCalled = false;
    String logFileName = null;

    try {
        Configuration conf = new Configuration(false);
        GenericOptionsParser parser = new GenericOptionsParser(conf, args);
        conf = parser.getConfiguration();

        // create and update properties from configurations
        Properties properties = new Properties();
        PropertiesUtil.loadDefaultProperties(properties);
        PropertiesUtil.loadPropertiesFromFile(properties, "./conf/pigout.properties");
        properties.putAll(ConfigurationUtil.toProperties(conf));

        for (String key : properties.stringPropertyNames()) {
            log.debug(key + " = " + properties.getProperty(key));
        }

        if (listener == null) {
            listener = makeListener(properties);
        }
        String[] pigArgs = parser.getRemainingArgs();

        boolean userSpecifiedLog = false;
        boolean checkScriptOnly = false;

        BufferedReader pin = null;
        boolean debug = false;
        boolean dryrun = false;
        boolean embedded = false;
        List<String> params = new ArrayList<String>();
        List<String> paramFiles = new ArrayList<String>();
        HashSet<String> disabledOptimizerRules = new HashSet<String>();

        CmdLineParser opts = new CmdLineParser(pigArgs);
        opts.registerOpt('4', "log4jconf", CmdLineParser.ValueExpected.REQUIRED);
        opts.registerOpt('b', "brief", CmdLineParser.ValueExpected.NOT_ACCEPTED);
        opts.registerOpt('c', "check", CmdLineParser.ValueExpected.NOT_ACCEPTED);
        opts.registerOpt('d', "debug", CmdLineParser.ValueExpected.REQUIRED);
        opts.registerOpt('e', "execute", CmdLineParser.ValueExpected.NOT_ACCEPTED);
        opts.registerOpt('f', "file", CmdLineParser.ValueExpected.REQUIRED);
        opts.registerOpt('g', "embedded", CmdLineParser.ValueExpected.REQUIRED);
        opts.registerOpt('h', "help", CmdLineParser.ValueExpected.OPTIONAL);
        opts.registerOpt('i', "version", CmdLineParser.ValueExpected.OPTIONAL);
        opts.registerOpt('l', "logfile", CmdLineParser.ValueExpected.REQUIRED);
        opts.registerOpt('m', "param_file", CmdLineParser.ValueExpected.OPTIONAL);
        opts.registerOpt('p', "param", CmdLineParser.ValueExpected.OPTIONAL);
        opts.registerOpt('r', "dryrun", CmdLineParser.ValueExpected.NOT_ACCEPTED);
        opts.registerOpt('t', "optimizer_off", CmdLineParser.ValueExpected.REQUIRED);
        opts.registerOpt('v', "verbose", CmdLineParser.ValueExpected.NOT_ACCEPTED);
        opts.registerOpt('w', "warning", CmdLineParser.ValueExpected.NOT_ACCEPTED);
        opts.registerOpt('x', "exectype", CmdLineParser.ValueExpected.REQUIRED);
        opts.registerOpt('F', "stop_on_failure", CmdLineParser.ValueExpected.NOT_ACCEPTED);
        opts.registerOpt('M', "no_multiquery", CmdLineParser.ValueExpected.NOT_ACCEPTED);
        opts.registerOpt('P', "propertyFile", CmdLineParser.ValueExpected.REQUIRED);

        ExecMode mode = ExecMode.UNKNOWN;
        String file = null;
        String engine = null;
        ExecType execType = ExecType.LOCAL;

        // set up client side system properties in UDF context
        UDFContext.getUDFContext().setClientSystemProps(properties);

        char opt;
        //properties.setProperty("opt.multiquery",""+true);

        while ((opt = opts.getNextOpt()) != CmdLineParser.EndOfOpts) {
            switch (opt) {
            case '4':
                String log4jconf = opts.getValStr();
                if (log4jconf != null) {
                    properties.setProperty(LOG4J_CONF, log4jconf);
                }
                break;

            case 'b':
                properties.setProperty(BRIEF, "true");
                break;

            case 'c':
                checkScriptOnly = true;
                break;

            case 'd':
                String logLevel = opts.getValStr();
                if (logLevel != null) {
                    properties.setProperty(DEBUG, logLevel);
                }
                debug = true;
                break;

            case 'e':
                mode = ExecMode.STRING;
                break;

            case 'f':
                mode = ExecMode.FILE;
                file = opts.getValStr();
                break;

            case 'g':
                embedded = true;
                engine = opts.getValStr();
                break;

            case 'F':
                properties.setProperty("stop.on.failure", "" + true);
                break;

            case 'h':
                String topic = opts.getValStr();
                if (topic != null) {
                    System.out.println("Topic based help is not provided yet.");
                    usage();
                } else
                    usage();
                return ReturnCode.SUCCESS;

            case 'i':
                System.out.println(getVersionString());
                return ReturnCode.SUCCESS;

            case 'l':
                //call to method that validates the path to the log file
                //and sets up the file to store the client side log file
                String logFileParameter = opts.getValStr();
                if (logFileParameter != null && logFileParameter.length() > 0) {
                    logFileName = validateLogFile(logFileParameter, null);
                } else {
                    logFileName = validateLogFile(logFileName, null);
                }
                userSpecifiedLog = true;
                properties.setProperty("pig.logfile", (logFileName == null ? "" : logFileName));
                break;

            case 'm':
                //adds a parameter file
                paramFiles.add(opts.getValStr());
                break;

            case 'M':
                // turns off multiquery optimization
                properties.setProperty("opt.multiquery", "" + false);
                break;

            case 'p':
                //adds a parameter
                params.add(opts.getValStr());
                break;

            case 'r':
                // currently only used for parameter substitution
                // will be extended in the future
                dryrun = true;
                break;

            case 't':
                //disables a opt rule
                disabledOptimizerRules.add(opts.getValStr());
                break;

            case 'v':
                properties.setProperty(VERBOSE, "" + true);
                verbose = true;
                break;

            case 'w':
                properties.setProperty("aggregate.warning", "" + false);
                break;

            case 'x':
                //sets execution type:
                try {
                    execType = ExecType.fromString(opts.getValStr());
                } catch (IOException e) {
                    throw new RuntimeException("ERROR: Unrecognized exectype.", e);
                }
                break;

            case 'P': {
                InputStream inputStream = null;
                try {
                    FileLocalizer.FetchFileRet localFileRet = FileLocalizer.fetchFile(properties,
                            opts.getValStr());
                    inputStream = new BufferedInputStream(new FileInputStream(localFileRet.file));
                    properties.load(inputStream);
                } catch (IOException e) {
                    throw new RuntimeException("Unable to parse properties file '" + opts.getValStr() + "'");
                } finally {
                    if (inputStream != null) {
                        try {
                            inputStream.close();
                        } catch (IOException e) {
                        }
                    }
                }
            }
                break;

            default: {
                Character cc = Character.valueOf(opt);
                throw new AssertionError("Unhandled option " + cc.toString());
            }
            }
        }

        // create the context with the parameter
        PigContext pigContext = new PigContext(execType, properties);

        // create the static script state object
        String commandLine = LoadFunc.join((AbstractList<String>) Arrays.asList(args), " ");
        ScriptState scriptState = ScriptState.start(commandLine, pigContext);
        if (listener != null) {
            scriptState.registerListener(listener);
        }

        pigContext.getProperties().setProperty("pig.cmd.args", commandLine);

        if (logFileName == null && !userSpecifiedLog) {
            logFileName = validateLogFile(properties.getProperty("pig.logfile"), null);
        }

        pigContext.getProperties().setProperty("pig.logfile", (logFileName == null ? "" : logFileName));

        // configure logging
        configureLog4J(properties, pigContext);

        log.info(getVersionString().replace("\n", ""));

        if (logFileName != null) {
            log.info("Logging error messages to: " + logFileName);
        }

        if (!Boolean.valueOf(properties.getProperty(PROP_FILT_SIMPL_OPT, "false"))) {
            //turn off if the user has not explicitly turned on this optimization
            disabledOptimizerRules.add("FilterLogicExpressionSimplifier");
        }
        pigContext.getProperties().setProperty("pig.optimizer.rules",
                ObjectSerializer.serialize(disabledOptimizerRules));

        PigContext.setClassLoader(pigContext.createCl(null));

        // construct the parameter substitution preprocessor
        PigOutSh pigOutSh = null;
        BufferedReader in;
        String substFile = null;

        paramFiles = fetchRemoteParamFiles(paramFiles, properties);
        pigContext.setParams(params);
        pigContext.setParamFiles(paramFiles);

        switch (mode) {
        case FILE: {
            String remainders[] = opts.getRemainingArgs();

            if (remainders != null) {
                pigContext.getProperties().setProperty(PigContext.PIG_CMD_ARGS_REMAINDERS,
                        ObjectSerializer.serialize(remainders));
            }

            FileLocalizer.FetchFileRet localFileRet = FileLocalizer.fetchFile(properties, file);
            if (localFileRet.didFetch) {
                properties.setProperty("pig.jars.relative.to.dfs", "true");
            }

            scriptState.setFileName(file);

            if (embedded) {
                return runEmbeddedScript(pigContext, localFileRet.file.getPath(), engine);
            } else {
                SupportedScriptLang type = determineScriptType(localFileRet.file.getPath());

                log.debug("File: " + localFileRet.file.getPath() + " Script type: " + type);

                if (type != null) {
                    return runEmbeddedScript(pigContext, localFileRet.file.getPath(),
                            type.name().toLowerCase());
                }
            }
            //Reader is created by first loading "pigout.load.default.statements" or .pigoutbootup file if available
            in = new BufferedReader(new InputStreamReader(
                    Utils.getCompositeStream(new FileInputStream(localFileRet.file), properties)));

            //run parameter substitution preprocessor first
            substFile = file + ".substituted";

            pin = runParamPreprocessor(pigContext, in, substFile, debug || dryrun || checkScriptOnly);

            if (dryrun) {
                if (dryrun(substFile, pigContext)) {
                    log.info("Dry run completed. Substituted pig script is at " + substFile
                            + ". Expanded pig script is at " + file + ".expanded");
                } else {
                    log.info("Dry run completed. Substituted pig script is at " + substFile);
                }
                return ReturnCode.SUCCESS;
            }

            logFileName = validateLogFile(logFileName, file);
            pigContext.getProperties().setProperty("pig.logfile", (logFileName == null ? "" : logFileName));

            // Set job name based on name of the script
            pigContext.getProperties().setProperty(PigContext.JOB_NAME, "PigOut_" + new File(file).getName());

            if (!debug) {
                new File(substFile).deleteOnExit();
            }

            scriptState.setScript(new File(file));

            // From now on, PigOut starts...
            // Create a shell interface to PigOutServer
            pigOutSh = new PigOutSh(pin, pigContext);
            pigoutCalled = true;

            if (checkScriptOnly) { // -c option
                //Check syntax
                pigOutSh.checkScript(substFile);
                System.err.println(file + " syntax OK");
                return ReturnCode.SUCCESS;
            }

            // parseAndBuild() will parse, and then generate a script
            log.info("PigOut is parsing and analyzing the script...");
            pigOutSh.parseAndBuild();

            log.debug("PigOut is partitioning the plan...");
            pigOutSh.partition();

            return ReturnCode.SUCCESS;
        }
        case STRING: {
            log.error("Please use FILE mode.");
            return -1;
        }
        default:
            break;
        }

    } catch (ParseException e) {
        usage();
        rc = ReturnCode.PARSE_EXCEPTION;
        PigStatsUtil.setErrorMessage(e.getMessage());
        PigStatsUtil.setErrorThrowable(e);
    } catch (org.apache.pig.tools.parameters.ParseException e) {
        // usage();
        rc = ReturnCode.PARSE_EXCEPTION;
        PigStatsUtil.setErrorMessage(e.getMessage());
        PigStatsUtil.setErrorThrowable(e);
    } catch (IOException e) {
        if (e instanceof PigException) {
            PigException pe = (PigException) e;
            rc = (pe.retriable()) ? ReturnCode.RETRIABLE_EXCEPTION : ReturnCode.PIG_EXCEPTION;
            PigStatsUtil.setErrorMessage(pe.getMessage());
            PigStatsUtil.setErrorCode(pe.getErrorCode());
        } else {
            rc = ReturnCode.IO_EXCEPTION;
            PigStatsUtil.setErrorMessage(e.getMessage());
        }
        PigStatsUtil.setErrorThrowable(e);

        if (!pigoutCalled) {
            LogUtils.writeLog(e, logFileName, log, verbose, "Error before Pig is launched");
        }
    } catch (Throwable e) {
        rc = ReturnCode.THROWABLE_EXCEPTION;
        PigStatsUtil.setErrorMessage(e.getMessage());
        PigStatsUtil.setErrorThrowable(e);
        e.printStackTrace();
        if (!pigoutCalled) {
            LogUtils.writeLog(e, logFileName, log, verbose, "Error before Pig is launched");
        }
    } finally {
        // clear temp files
        FileLocalizer.deleteTempFiles();
        PerformanceTimerFactory.getPerfTimerFactory().dumpTimers();
    }

    return rc;

}

From source file:dk.dma.msinm.common.settings.Settings.java

@PostConstruct
public void loadSettingsFromPropertiesFile() {
    Properties properties = new Properties();
    try {//from  www. jav  a 2 s .c  om
        properties.load(getClass().getResourceAsStream(SETTINGS_FILE));
        properties.stringPropertyNames().stream().filter(name -> em.find(SettingsEntity.class, name) == null)
                .forEach(name -> {
                    // Persist the entity
                    SettingsEntity result = new SettingsEntity(name, properties.getProperty(name));
                    em.persist(result);
                    log.info(String.format("Loaded property %s=%s from %s", name, properties.getProperty(name),
                            SETTINGS_FILE));
                });
    } catch (Exception e) {
        // Ignore
    }
}

From source file:org.ngrinder.infra.AgentConfig.java

/**
 * Update agent pid file./*from   w w w  .j  ava  2s . c  om*/
 *
 * @param startMode startMode
 */
public void updateAgentPidProperties(String startMode) {
    checkNotNull(home);
    Properties properties = home.getProperties("pid");
    Set<String> names = properties.stringPropertyNames();
    if (names.size() > 1) {
        properties.remove(startMode + ".pid");
        home.saveProperties("pid", properties);
    } else if (names.contains(startMode + ".pid")) {
        removeAgentPidProperties();
    }
}

From source file:test.automation.execution.TestExecutor.java

private Set<Property> buildProperties(final Properties properties) {
    final Set<Property> configurationProperties = new HashSet<Property>();
    for (final String key : properties.stringPropertyNames()) {
        configurationProperties.add(new Property(key, properties.getProperty(key)));
    }/*from   w  ww  . j a  v a2  s.c o  m*/

    return (configurationProperties);
}

From source file:org.openhab.io.net.http.HttpUtil.java

/**
 * Executes the given <code>url</code> with the given <code>httpMethod</code>
 * /* w  w  w  . j a  va  2 s. c o m*/
 * @param httpMethod the HTTP method to use
 * @param url the url to execute (in milliseconds)
 * @param httpHeaders optional HTTP headers which has to be set on request
 * @param content the content to be send to the given <code>url</code> or 
 * <code>null</code> if no content should be send.
 * @param contentType the content type of the given <code>content</code>
 * @param timeout the socket timeout to wait for data
 * @param proxyHost the hostname of the proxy
 * @param proxyPort the port of the proxy
 * @param proxyUser the username to authenticate with the proxy
 * @param proxyPassword the password to authenticate with the proxy
 * @param nonProxyHosts the hosts that won't be routed through the proxy
 * @return the response body or <code>NULL</code> when the request went wrong
 */
public static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content,
        String contentType, int timeout, String proxyHost, Integer proxyPort, String proxyUser,
        String proxyPassword, String nonProxyHosts) {

    HttpClient client = new HttpClient();

    // only configure a proxy if a host is provided
    if (StringUtils.isNotBlank(proxyHost) && proxyPort != null && shouldUseProxy(url, nonProxyHosts)) {
        client.getHostConfiguration().setProxy(proxyHost, proxyPort);
        if (StringUtils.isNotBlank(proxyUser)) {
            client.getState().setProxyCredentials(AuthScope.ANY,
                    new UsernamePasswordCredentials(proxyUser, proxyPassword));
        }
    }

    HttpMethod method = HttpUtil.createHttpMethod(httpMethod, url);
    method.getParams().setSoTimeout(timeout);
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
            new DefaultHttpMethodRetryHandler(3, false));
    if (httpHeaders != null) {
        for (String httpHeaderKey : httpHeaders.stringPropertyNames()) {
            method.addRequestHeader(new Header(httpHeaderKey, httpHeaders.getProperty(httpHeaderKey)));
        }
    }
    // add content if a valid method is given ...
    if (method instanceof EntityEnclosingMethod && content != null) {
        EntityEnclosingMethod eeMethod = (EntityEnclosingMethod) method;
        eeMethod.setRequestEntity(new InputStreamRequestEntity(content, contentType));
    }

    Credentials credentials = extractCredentials(url);
    if (credentials != null) {
        client.getParams().setAuthenticationPreemptive(true);
        client.getState().setCredentials(AuthScope.ANY, credentials);
    }

    if (logger.isDebugEnabled()) {
        try {
            logger.debug("About to execute '" + method.getURI().toString() + "'");
        } catch (URIException e) {
            logger.debug(e.getMessage());
        }
    }

    try {

        int statusCode = client.executeMethod(method);
        if (statusCode == HttpStatus.SC_NO_CONTENT || statusCode == HttpStatus.SC_ACCEPTED) {
            // perfectly fine but we cannot expect any answer...
            return null;
        }

        if (statusCode != HttpStatus.SC_OK) {
            logger.warn("Method failed: " + method.getStatusLine());
        }

        InputStream tmpResponseStream = method.getResponseBodyAsStream();
        Header encodingHeader = method.getResponseHeader("Content-Encoding");
        if (encodingHeader != null) {
            for (HeaderElement ehElem : encodingHeader.getElements()) {
                if (ehElem.toString().matches(".*gzip.*")) {
                    tmpResponseStream = new GZIPInputStream(tmpResponseStream);
                    logger.debug("GZipped InputStream from {}", url);
                } else if (ehElem.toString().matches(".*deflate.*")) {
                    tmpResponseStream = new InflaterInputStream(tmpResponseStream);
                    logger.debug("Deflated InputStream from {}", url);
                }
            }
        }

        String responseBody = IOUtils.toString(tmpResponseStream);
        if (!responseBody.isEmpty()) {
            logger.debug(responseBody);
        }

        return responseBody;
    } catch (HttpException he) {
        logger.error("Fatal protocol violation: {}", he.toString());
    } catch (IOException ioe) {
        logger.error("Fatal transport error: {}", ioe.toString());
    } finally {
        method.releaseConnection();
    }

    return null;
}

From source file:org.wisdom.maven.utils.Properties2HoconConverterTest.java

@Test
public void testOnWikipediaSampleUsingRawProperties() throws IOException {
    File props = new File(root, "/wiki.properties");
    File hocon = Properties2HoconConverter.convert(props, true);

    Properties properties = loadProperties(props);

    Config config = load(hocon);/*ww  w  .ja  v  a2s  .c o  m*/
    assertThat(properties.isEmpty()).isFalse();
    assertThat(config.isEmpty()).isFalse();

    for (String name : properties.stringPropertyNames()) {
        // Ignored properties are they are not supported in the 'regular' raw format.
        if (name.equalsIgnoreCase("targetCities") || name.equalsIgnoreCase("Los")) {
            continue;
        }
        String o = (String) properties.get(name);
        String v = config.getString(name);
        assertThat(o).isEqualTo(v);
    }

}

From source file:org.apache.ctakes.ytex.kernel.BaseClassifierEvaluationParser.java

protected BiMap<Integer, String> loadClassIdMap(File dataDir, String label) throws IOException {
    BiMap<Integer, String> classIndexMap = HashBiMap.create();
    String filename = FileUtil.getScopedFileName(dataDir.getPath(), label, null, null, "class.properties");
    File f = new File(filename);
    if (f.exists()) {
        BufferedReader r = null;/*w ww.ja v  a 2  s . c o  m*/
        try {
            r = new BufferedReader(new FileReader(f));
            Properties props = new Properties();
            props.load(r);
            for (String key : props.stringPropertyNames()) {
                classIndexMap.put(Integer.parseInt(key), props.getProperty(key));
            }
        } finally {
            try {
                r.close();
            } catch (IOException e) {
            }
        }
    }
    return classIndexMap;
}

From source file:org.jahia.osgi.FrameworkService.java

private Map<String, String> filterOutSystemProperties() {

    if (!"was".equals(SettingsBean.getInstance().getServer())) {
        // we skip filtering out system properties on any server except WebSphere, which sets OSGi-related properties for its internal
        // container
        return null;
    }/*from w  ww.  j  a va2s.c o  m*/

    Map<String, String> filteredOutSystemProperties = new HashMap<>();
    Properties sysProps = System.getProperties();
    for (String prop : sysProps.stringPropertyNames()) {
        if (prop.startsWith("org.osgi.framework.")) {
            logger.info("Filtering out system property {}", prop);
            filteredOutSystemProperties.put(prop, sysProps.getProperty(prop));
            sysProps.remove(prop);
        }
    }
    return filteredOutSystemProperties;
}