Example usage for java.util Properties propertyNames

List of usage examples for java.util Properties propertyNames

Introduction

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

Prototype

public Enumeration<?> propertyNames() 

Source Link

Document

Returns an enumeration of all the keys in this property list, 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:com.griddynamics.jagger.JaggerLauncher.java

public static void loadBootProperties(URL directory, String environmentPropertiesLocation,
        Properties environmentProperties) throws IOException {
    URL bootPropertiesFile = new URL(directory, environmentPropertiesLocation);
    System.setProperty(ENVIRONMENT_PROPERTIES, environmentPropertiesLocation);
    environmentProperties.load(bootPropertiesFile.openStream());

    String defaultBootPropertiesLocation = environmentProperties.getProperty(DEFAULT_ENVIRONMENT_PROPERTIES);
    if (defaultBootPropertiesLocation == null) {
        defaultBootPropertiesLocation = DEFAULT_ENVIRONMENT_PROPERTIES_LOCATION;
    }//from   w  ww .j  a  v  a 2 s. co  m
    URL defaultBootPropertiesFile = new URL(directory, defaultBootPropertiesLocation);
    Properties defaultBootProperties = new Properties();
    defaultBootProperties.load(defaultBootPropertiesFile.openStream());
    for (String name : defaultBootProperties.stringPropertyNames()) {
        if (!environmentProperties.containsKey(name)) {
            environmentProperties.setProperty(name, defaultBootProperties.getProperty(name));
        }
    }

    Properties properties = System.getProperties();
    for (Enumeration<String> enumeration = (Enumeration<String>) properties.propertyNames(); enumeration
            .hasMoreElements();) {
        String key = enumeration.nextElement();
        environmentProperties.put(key, properties.get(key));
    }

    System.setProperty(ENVIRONMENT_PROPERTIES, environmentPropertiesLocation);
    System.setProperty(DEFAULT_ENVIRONMENT_PROPERTIES, defaultBootPropertiesLocation);
}

From source file:ome.testing.SqlPropertiesParser.java

public static Map parse(String[] filenames) {
    // Get strings from files
    Map result = new HashMap();
    Properties props = new Properties();
    for (int i = 0; i < filenames.length; i++) {
        load(props, filenames[i]);//  www  .  ja  va 2 s  .com
    }

    // Put them into a map converting embedded ${...}
    prc.setProperties(props);
    prc.postProcessBeanFactory(null);
    for (Enumeration en = props.propertyNames(); en.hasMoreElements();) {
        String name = (String) en.nextElement();
        result.put(name, prc.doIt(props.getProperty(name)));
    }

    // Do extra parsing where necessary
    for (Iterator it = result.keySet().iterator(); it.hasNext();) {
        String name = (String) it.next();
        String value = (String) result.get(name);
        if (!value.startsWith("select")) {
            String[] strValues = value.split("\\s*,\\s*");
            Long[] longValues = new Long[strValues.length];
            for (int i = 0; i < strValues.length; i++) {
                longValues[i] = Long.valueOf(strValues[i]);
            }
            result.put(name, Arrays.asList(longValues));
        }
    }

    return result;

}

From source file:org.wso2.carbon.identity.application.authentication.endpoint.util.MutualSSLManager.java

/**
 * Get status of the availability of secured (with secure vault) properties
 *
 * @return availability of secured properties
 *///from   www. j a v a 2s .  c  om
private static boolean isSecuredPropertyAvailable(Properties properties) {

    Enumeration propertyNames = properties.propertyNames();

    while (propertyNames.hasMoreElements()) {
        String key = (String) propertyNames.nextElement();
        if (PROTECTED_TOKENS.equals(key) && StringUtils.isNotBlank(properties.getProperty(key))) {
            return true;
        }
    }
    return false;
}

From source file:com.intellij.ide.fileTemplates.FileTemplateUtil.java

public static void putAll(final Map<String, Object> props, final Properties p) {
    for (Enumeration<?> e = p.propertyNames(); e.hasMoreElements();) {
        String s = (String) e.nextElement();
        props.put(s, p.getProperty(s));//from ww w.j a  v  a  2  s  .c  o  m
    }
}

From source file:org.cruxframework.crux.core.server.dispatch.ServicesCompileMap.java

/**
 * @param context/*from   ww  w  . j a  va2s . co  m*/
 */
public static boolean initialize(ServletContext context) {
    Properties properties = new Properties();
    try {
        if (context != null) {
            properties.load(context.getResourceAsStream("/META-INF/crux-remote"));
        } else {
            properties.load(ServicesCompileMap.class.getResourceAsStream("/META-INF/crux-remote"));
        }
        Enumeration<?> serviceNames = (Enumeration<?>) properties.propertyNames();
        while (serviceNames.hasMoreElements()) {
            String serviceName = (String) serviceNames.nextElement();
            remoteServices.put(serviceName, properties.getProperty(serviceName));
        }
        return true;
    } catch (Exception e) {
        logger.info("Error initializing services with service maps strategy...");
    }
    return false;
}

From source file:org.cruxframework.crux.core.server.rest.core.registry.RestServicesCompileMap.java

/**
 * @param context//from w w w  . j  av  a  2s.co m
 */
public static boolean initialize(ServletContext context) {
    Properties properties = new Properties();
    try {
        if (context != null) {
            properties.load(context.getResourceAsStream("/META-INF/crux-rest"));
        } else {
            properties.load(RestServicesCompileMap.class.getResourceAsStream("/META-INF/crux-rest"));
        }
        Enumeration<?> serviceNames = (Enumeration<?>) properties.propertyNames();
        while (serviceNames.hasMoreElements()) {
            String serviceName = (String) serviceNames.nextElement();
            remoteServices.put(serviceName, properties.getProperty(serviceName));
        }
        return true;
    } catch (Exception e) {
        logger.info("Error initializing REST services with service maps strategy...");
    }
    return false;
}

From source file:org.springframework.cloud.dataflow.rest.util.DeploymentPropertiesUtils.java

/**
 * Convert Properties to a Map with String keys and String values.
 *
 * @param properties the properties object
 * @return the equivalent {@code Map<String,String>}
 *//*from www  .  j  av  a2s .  c  om*/
public static Map<String, String> convert(Properties properties) {
    Map<String, String> result = new HashMap<>(properties.size());
    for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();) {
        String key = (String) e.nextElement();
        result.put(key, properties.getProperty(key));
    }
    return result;
}

From source file:com.germinus.easyconf.FileUtil.java

public static String propertiesToString(Properties p) {
    StringBuffer sb = new StringBuffer();

    Enumeration enu = p.propertyNames();

    while (enu.hasMoreElements()) {
        String key = (String) enu.nextElement();

        sb.append(key);/*from   www  .  ja  v a 2  s  .co m*/
        sb.append("=");
        sb.append(p.getProperty(key));
        sb.append("\n");
    }

    return sb.toString();
}

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

/**
 * Appends the properties from the Maven session (user properties) to the command line. As the command line is
 * intended to be a Chameleon process, arguments are passed using the {@literal -Dkey=value} syntax.
 *
 * @param mojo the mojo/*from  w w w  .j a v a 2  s . c  o  m*/
 * @param cmd  the command line to extend
 */
private static void appendSystemPropertiesToCommandLine(AbstractWisdomMojo mojo, CommandLine cmd) {
    Properties userProperties = mojo.session.getUserProperties();
    if (userProperties != null) {
        //noinspection unchecked
        Enumeration<String> names = (Enumeration<String>) userProperties.propertyNames();
        while (names.hasMoreElements()) {
            String name = names.nextElement();
            cmd.addArgument("-D" + name + "=" + userProperties.getProperty(name));
        }
    }
}

From source file:org.wso2.carbon.registry.ws.api.utils.CommonUtil.java

private static WSProperty[] getPropertiesForWSResource(Properties props) {
    Enumeration keys = props.propertyNames();
    Enumeration keys2 = props.propertyNames();
    int size = 0, i = 0;
    while (keys.hasMoreElements()) {
        keys.nextElement();/*from  www .  ja v  a  2s  .co  m*/
        size++;
    }

    String[] keyarray = new String[size];
    while (keys2.hasMoreElements()) {
        keyarray[i] = (String) keys2.nextElement();
        i++;
    }
    // To avoid property element not being created in soap message
    if (keyarray.length == 0) {
        WSProperty[] properties = new WSProperty[1];
        properties[0] = new WSProperty();
        return properties;
    }
    WSProperty[] properties = new WSProperty[keyarray.length];

    for (i = 0; i < keyarray.length; i++) {
        properties[i] = new WSProperty();
        properties[i].setKey(keyarray[i]);
        List<String> list = (List<String>) props.get(keyarray[i]);
        String[] values = new String[list.size()];

        int j = 0;
        for (String str : list) {
            values[j] = str;
            j++;
        }
        properties[i].setValues(values);
    }
    return properties;
}