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.springframework.amqp.rabbit.stocks.web.EnvironmentController.java

/**
 * Set some system properties and refresh a bean in the application context (provided it is in refresh scope).
 * //from w ww  . j a  va2  s.  c  o m
 * @param request a refresh request
 */
public void handleRefresh(RefreshRequest request) {

    logger.info("Handling refresh: " + request);

    String name = request.getBeanName();
    Properties updates = request.getUpdates();
    for (String property : updates.stringPropertyNames()) {
        String old = environmentProperties.getProperty(property);
        String update = updates.getProperty(property);
        if (update.length() > 0 && !update.equals(old)) {
            environmentProperties.setProperty(property, update);
            if (redisTemplate != null) {
                redisTemplate.boundValueOps("env." + property).set(update);
            }
        }
    }

    if (name != null && refreshScope != null) {
        refreshScope.refresh(name);
    }

}

From source file:org.apache.hadoop.hive.cli.OptionsProcessor.java

public boolean process_stage1(String[] argv) {
    try {/*w  w w  .j ava 2 s.  c o m*/
        commandLine = new GnuParser().parse(options, argv);
        Properties confProps = commandLine.getOptionProperties("hiveconf");
        for (String propKey : confProps.stringPropertyNames()) {
            // with HIVE-11304, hive.root.logger cannot have both logger name and log level.
            // if we still see it, split logger and level separately for hive.root.logger
            // and hive.log.level respectively
            if (propKey.equalsIgnoreCase("hive.root.logger")) {
                CommonCliOptions.splitAndSetLogger(propKey, confProps);
            } else {
                System.setProperty(propKey, confProps.getProperty(propKey));
            }
        }

        Properties hiveVars = commandLine.getOptionProperties("define");
        for (String propKey : hiveVars.stringPropertyNames()) {
            hiveVariables.put(propKey, hiveVars.getProperty(propKey));
        }

        Properties hiveVars2 = commandLine.getOptionProperties("hivevar");
        for (String propKey : hiveVars2.stringPropertyNames()) {
            hiveVariables.put(propKey, hiveVars2.getProperty(propKey));
        }
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        printUsage();
        return false;
    }
    return true;
}

From source file:io.personium.core.rs.StatusResource.java

/**
 * GET???./*from   ww w.ja v  a 2s  . c om*/
 * @return JAS-RS Response
 */
@SuppressWarnings("unchecked")
@GET
@Produces("application/json")
public Response get() {
    StringBuilder sb = new StringBuilder();

    // 
    Properties props = PersoniumUnitConfig.getProperties();
    JSONObject responseJson = new JSONObject();
    JSONObject propertiesJson = new JSONObject();
    for (String key : props.stringPropertyNames()) {
        String value = props.getProperty(key);
        propertiesJson.put(key, value);
    }
    responseJson.put("properties", propertiesJson);

    // Cell?/
    //responseJson.put("service", checkServiceStatus());

    // ElasticSearch Health
    EsClient client = EsModel.client();
    JSONObject esJson = new JSONObject();
    esJson.put("health", client.checkHealth());
    responseJson.put("ElasticSearch", esJson);

    sb.append(responseJson.toJSONString());
    return Response.status(HttpStatus.SC_OK).entity(sb.toString()).build();
}

From source file:org.apache.hadoop.hive.cli.OptionsProcessor.java

public boolean process_stage2(CliSessionState ss) {
    ss.getConf();//from   w  w  w .  j  ava  2 s  . c  o m

    if (commandLine.hasOption('H')) {
        printUsage();
        return false;
    }

    ss.setIsSilent(commandLine.hasOption('S'));

    ss.database = commandLine.getOptionValue("database");

    ss.execString = commandLine.getOptionValue('e');

    ss.fileName = commandLine.getOptionValue('f');

    ss.setIsVerbose(commandLine.hasOption('v'));

    String[] initFiles = commandLine.getOptionValues('i');
    if (null != initFiles) {
        ss.initFiles = Arrays.asList(initFiles);
    }

    if (ss.execString != null && ss.fileName != null) {
        System.err.println("The '-e' and '-f' options cannot be specified simultaneously");
        printUsage();
        return false;
    }

    if (commandLine.hasOption("hiveconf")) {
        Properties confProps = commandLine.getOptionProperties("hiveconf");
        for (String propKey : confProps.stringPropertyNames()) {
            ss.cmdProperties.setProperty(propKey, confProps.getProperty(propKey));
        }
    }

    return true;
}

From source file:org.nuxeo.common.utils.TestTextTemplate.java

@Test
public void test2() {
    Properties vars = new Properties();
    vars.setProperty("k1", "v1");
    TextTemplate tt = new TextTemplate(vars);

    assertEquals(vars.stringPropertyNames(), tt.getVariables().stringPropertyNames());
    assertEquals("v1", tt.getVariable("k1"));

    tt.setVariable("k2", "v2");
    String text = tt.processText("${k1}-${k2}");
    assertEquals("v1-v2", text);
}

From source file:com.fujitsu.dc.core.rs.StatusResource.java

/**
 * GET???.// ww  w.j  av a  2 s .  co m
 * @return JAS-RS Response
 */
@SuppressWarnings("unchecked")
@GET
@Produces("application/json")
public Response get() {
    StringBuilder sb = new StringBuilder();

    // 
    Properties props = DcCoreConfig.getProperties();
    JSONObject responseJson = new JSONObject();
    JSONObject propertiesJson = new JSONObject();
    for (String key : props.stringPropertyNames()) {
        String value = props.getProperty(key);
        propertiesJson.put(key, value);
    }
    responseJson.put("properties", propertiesJson);

    // Cell?/
    //responseJson.put("service", checkServiceStatus());

    // Ads??
    responseJson.put("ads", checkAds());

    // ElasticSearch Health
    EsClient client = EsModel.client();
    JSONObject esJson = new JSONObject();
    esJson.put("health", client.checkHealth());
    responseJson.put("ElasticSearch", esJson);

    sb.append(responseJson.toJSONString());
    return Response.status(HttpStatus.SC_OK).entity(sb.toString()).build();
}

From source file:org.nuxeo.theme.html.CSSUtils.java

public static String styleToCss(final Style style, final Collection<String> viewNames,
        final boolean ignoreViewName, final boolean ignoreClassName, final boolean indent) {

    final StringBuilder sb = new StringBuilder();
    final StringBuilder pSb = new StringBuilder();
    for (String viewName : viewNames) {
        final String className = computeCssClassName(style);
        pSb.setLength(0);//from w w w.  j  a v  a 2s  .c  om
        boolean addSpace = false;
        if (!ignoreClassName) {
            pSb.append('.').append(className);
            addSpace = true;
        }
        if (!ignoreViewName && !"*".equals(viewName)) {
            pSb.append(toUpperCamelCase(viewName));
            addSpace = true;
        }

        for (String path : style.getPathsForView(viewName)) {
            final Properties styleProperties = style.getPropertiesFor(viewName, path);
            // if (styleProperties.isEmpty()) {
            // continue;
            // }

            final String[] splitPaths = path.split(",");
            final int len = splitPaths.length;
            for (int i = 0; i < len; i++) {
                sb.append(pSb);
                if (addSpace && !"".equals(path)) {
                    sb.append(' ');
                }
                sb.append(splitPaths[i].trim());
                if (i < len - 1) {
                    sb.append(", ");
                }
            }
            sb.append(" {");
            if (indent) {
                sb.append('\n');
            }

            for (String propertyName : styleProperties.stringPropertyNames()) {
                String value = styleProperties.getProperty(propertyName);
                if (value == null) {
                    continue;
                }
                if (indent) {
                    sb.append("  ");
                }
                sb.append(propertyName);
                sb.append(':');
                if (indent) {
                    sb.append(' ');
                }
                sb.append(value).append(';');
                if (indent) {
                    sb.append('\n');
                }
            }
            sb.append("}\n");
            if (indent) {
                sb.append('\n');
            }

        }
    }
    return sb.toString();
}

From source file:com.soulgalore.velocity.MergeXMLWithVelocity.java

private Map<String, String> getClasses(Properties properties) {

    Map<String, String> keyAndClass = new HashMap<String, String>();
    Set<String> keys = properties.stringPropertyNames();
    for (String key : keys) {
        if (key.startsWith(CONTEXT_PROPERTY_OBJECT)) {
            String value = properties.getProperty(key);
            String className = value.substring(0, value.indexOf(":"));
            String contextKey = value.substring(value.indexOf(":") + 1, value.length());
            keyAndClass.put(contextKey, className);
        }/*from ww w  . j av a  2  s  .com*/
    }
    return keyAndClass;
}

From source file:com.wso2telco.core.dbutils.fileutils.FileReader.java

public Map<String, String> readPropertyFile(String file) {

    HashMap<String, String> confPropertyMap = new HashMap<String, String>();
    Properties props = new Properties();
    FileInputStream fileStream = null;

    try {/*www .  j  av a2s. c  o m*/

        fileStream = new FileInputStream(file);

        props.load(fileStream);

        for (String key : props.stringPropertyNames()) {

            String value = props.getProperty(key);
            confPropertyMap.put(key, value);
        }
    } catch (FileNotFoundException e) {

        log.debug("file not found in " + file, e);
    } catch (IOException e) {

        log.debug("unable to close " + file, e);
    } finally {

        try {

            fileStream.close();
        } catch (IOException e) {

            log.debug("unable to close " + file, e);
        }
    }

    return confPropertyMap;
}

From source file:de.codesourcery.jasm16.ide.ApplicationConfig.java

protected void loadConfig() throws IOException {
    boolean success = false;
    if (configFile.exists()) {
        LOG.info("loadConfig(): Loading application configuration");
        try {/*from  w  ww.j  av  a 2  s.c  o  m*/
            final Properties props = loadPropertiesFile(configFile);
            for (String key : props.stringPropertyNames()) {
                configProperties.put(key, props.getProperty(key));
            }
            success = true;
        } catch (IOException e) {
            LOG.error("loadConfiguration(): Failed to load workspace configuration");
        }
    }

    if (!success) {
        configProperties.clear();
        configProperties.putAll(createDefaultConfiguration());
        saveConfiguration();
    }
}