Example usage for java.util Properties keySet

List of usage examples for java.util Properties keySet

Introduction

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

Prototype

@Override
    public Set<Object> keySet() 

Source Link

Usage

From source file:burlov.ultracipher.swing.SwingGuiApplication.java

/**
 * Methode sammelt Informationen ueber Systemumgebung
 *
 * @return//from w ww .  j a v  a  2 s .  c  om
 */
static public StringBuilder createSystemInfo() {
    StringBuilder sb = new StringBuilder();
    Properties p = System.getProperties();
    for (Object key : p.keySet()) {
        if (key.toString().endsWith("path")) {
            continue;//Zu lange Werte werden nicht gebraucht
        }
        String value = (String) p.get(key);
        sb.append(key);
        sb.append(": ");
        sb.append(value);
        sb.append('\n');
    }
    return sb;
}

From source file:de.ppi.selenium.browser.DefaultWebDriverFactory.java

/**
 *
 * @param ffp the firefox profile you are using
 * @param propertiesFile the properties you want to add to the profile
 */// w w  w.  java  2 s .c  om
private static void addPreferences(FirefoxProfile ffp, String propertiesFile) {
    Properties firefoxProfile = new Properties();

    try {
        firefoxProfile.load(new FileInputStream(propertiesFile));
    } catch (Throwable th) {
        throw new RuntimeException("Could not load firefox profile", th);
    }

    for (Object o : firefoxProfile.keySet()) {
        String key = (String) o;
        String getVal = null;
        if (key.endsWith(".type")) {
            getVal = key.substring(0, key.lastIndexOf("."));
        }

        if (getVal != null) {
            String type = firefoxProfile.getProperty(key);
            String value = firefoxProfile.getProperty(getVal + ".value");

            if (value.contains("${PROJECT_PATH}")) {
                String projectPath = (new File("")).getAbsolutePath();
                value = projectPath + value.replaceAll("\\$\\{PROJECT_PATH\\}", "");
            }

            if (type.equalsIgnoreCase("BOOLEAN")) {
                ffp.setPreference(getVal, Boolean.parseBoolean(value));
            } else if (type.equalsIgnoreCase("STRING")) {
                ffp.setPreference(getVal, value);
            } else if (type.equalsIgnoreCase("INTEGER") || type.equalsIgnoreCase("INT")) {
                ffp.setPreference(getVal, Integer.parseInt(value));
            }
        }
    }
}

From source file:org.apache.geode.internal.cache.ClusterConfigurationLoader.java

/***
 * Apply the gemfire properties cluster configuration on this member
 * /*  ww w. j a  v  a2  s  . com*/
 * @param response {@link ConfigurationResponse} containing the requested {@link Configuration}
 * @param config this member's config
 */
public static void applyClusterPropertiesConfiguration(ConfigurationResponse response,
        DistributionConfig config) {
    if (response == null || response.getRequestedConfiguration().isEmpty()) {
        return;
    }

    List<String> groups = getGroups(config);
    Map<String, Configuration> requestedConfiguration = response.getRequestedConfiguration();

    final Properties runtimeProps = new Properties();

    // apply the cluster config first
    Configuration clusterConfiguration = requestedConfiguration.get(ClusterConfigurationService.CLUSTER_CONFIG);
    if (clusterConfiguration != null) {
        runtimeProps.putAll(clusterConfiguration.getGemfireProperties());
    }

    // then apply the group config
    for (String group : groups) {
        Configuration groupConfiguration = requestedConfiguration.get(group);
        if (groupConfiguration != null) {
            runtimeProps.putAll(groupConfiguration.getGemfireProperties());
        }
    }

    Set<Object> attNames = runtimeProps.keySet();
    for (Object attNameObj : attNames) {
        String attName = (String) attNameObj;
        String attValue = runtimeProps.getProperty(attName);
        try {
            config.setAttribute(attName, attValue, ConfigSource.runtime());
        } catch (IllegalArgumentException e) {
            logger.info(e.getMessage());
        } catch (UnmodifiableException e) {
            logger.info(e.getMessage());
        }
    }
}

From source file:org.apache.ranger.hadoop.client.config.HadoopConfigHolder.java

private static synchronized void init() {

    if (initialized) {
        return;//from  w  w  w.jav  a 2  s . com
    }

    try {
        InputStream in = HadoopConfigHolder.class.getClassLoader()
                .getResourceAsStream(DEFAULT_DATASOURCE_PARAM_PROP_FILE);
        if (in != null) {
            Properties prop = new Properties();
            try {
                prop.load(in);
            } catch (IOException e) {
                throw new HadoopException("Unable to get configuration information for Hadoop environments", e);
            } finally {
                try {
                    in.close();
                } catch (IOException e) {
                    // Ignored exception when the stream is closed.
                }
            }

            if (prop.size() == 0)
                return;

            for (Object keyobj : prop.keySet()) {
                String key = (String) keyobj;
                String val = prop.getProperty(key);

                int dotLocatedAt = key.indexOf(".");

                if (dotLocatedAt == -1) {
                    continue;
                }

                String dataSource = key.substring(0, dotLocatedAt);

                String propKey = key.substring(dotLocatedAt + 1);
                int resourceFoundAt = propKey.indexOf(".");
                if (resourceFoundAt > -1) {
                    String resourceName = propKey.substring(0, resourceFoundAt) + ".xml";
                    propKey = propKey.substring(resourceFoundAt + 1);
                    addConfiguration(dataSource, resourceName, propKey, val);
                }

            }
        }

        in = HadoopConfigHolder.class.getClassLoader().getResourceAsStream(GLOBAL_LOGIN_PARAM_PROP_FILE);
        if (in != null) {
            Properties tempLoginProp = new Properties();
            try {
                tempLoginProp.load(in);
            } catch (IOException e) {
                throw new HadoopException(
                        "Unable to get login configuration information for Hadoop environments from file: ["
                                + GLOBAL_LOGIN_PARAM_PROP_FILE + "]",
                        e);
            } finally {
                try {
                    in.close();
                } catch (IOException e) {
                    // Ignored exception when the stream is closed.
                }
            }
            globalLoginProp = tempLoginProp;
        }
    } finally {
        initialized = true;
    }
}

From source file:org.apache.openaz.xacml.util.XACMLProperties.java

public static Properties getPipProperties(Properties current) throws Exception {
    Properties props = new Properties();
    String list = current.getProperty(XACMLProperties.PROP_PIP_ENGINES);
    // require that PROP_PIP_ENGINES exist, even when it is empty
    if (list != null) {
        props.setProperty(XACMLProperties.PROP_PIP_ENGINES, list);
    } else {// ww w  . j  a  v  a2  s. com
        throw new Exception("Missing property: " + XACMLProperties.PROP_PIP_ENGINES);
    }
    if (list == null || list.length() == 0) {
        return props;
    }
    Iterable<String> pips = Splitter.on(',').trimResults().omitEmptyStrings().split(list);
    if (pips == null) {
        return props;
    }
    Set<Object> keys = current.keySet();
    for (String pip : pips) {
        for (Object key : keys) {
            if (key.toString().startsWith(pip)) {
                props.setProperty(key.toString(), current.getProperty(key.toString()));
            }
        }
    }
    return props;
}

From source file:org.apache.openaz.xacml.std.pap.StdEngine.java

public static void removeGroupProperties(String id, Properties properties) {
    for (Object key : properties.keySet()) {
        if (key.toString().startsWith(id + ".")) {
            properties.remove(key);//  w w  w . j  a  v a2  s.c om
        }
    }
}

From source file:com.ailk.oci.ocnosql.tools.load.single.SingleColumnImportTsv.java

private static Map<String, String> getProperty() {
    Map<String, String> map = null;
    try {//  w  w w . java 2  s  .  c  o m
        String conf_Path = SingleColumnImportTsv.class.getClassLoader().getResource(CONF_FILE).getPath();

        File file = new File(conf_Path);
        Properties prop = new Properties();
        prop.load(new FileReader(file));

        map = new HashMap<String, String>();
        for (Object key : prop.keySet()) {
            map.put((String) key, (String) prop.get(key));
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return map;
}

From source file:iristk.util.Record.java

/**
 * Converts a Properties object into a Record object.
 * @param prop Properties file with Record data
 * @return Record//w ww . j  av  a 2s. c  o m
 */
public static Record fromProperties(Properties prop) {
    Record rec = new Record();
    for (Object key : prop.keySet()) {
        rec.put(key.toString().replace(".", ":"), prop.get(key));
    }
    return rec;
}

From source file:org.apache.ode.store.ProcessStoreImpl.java

/**
 * Create a property mapping based on the initial values in the deployment descriptor.
 *
 * @param dd/* www  . j a v  a 2 s  .co m*/
 * @return
 */
public static Map<QName, Node> calcInitialProperties(Properties properties, TDeployment.Process dd) {
    HashMap<QName, Node> ret = new HashMap<QName, Node>();

    for (Object key1 : properties.keySet()) {
        String key = (String) key1;
        Document doc = DOMUtils.newDocument();
        doc.appendChild(doc.createElementNS(null, "temporary-simple-type-wrapper"));
        doc.getDocumentElement().appendChild(doc.createTextNode(properties.getProperty(key)));

        ret.put(new QName(key), doc.getDocumentElement());
    }

    for (TDeployment.Process.Property property : dd.getPropertyArray()) {
        Element elmtContent = DOMUtils.getElementContent(property.getDomNode());
        if (elmtContent != null) {
            // We'll need DOM Level 3
            Document doc = DOMUtils.newDocument();
            doc.appendChild(doc.importNode(elmtContent, true));
            ret.put(property.getName(), doc.getDocumentElement());
        } else
            ret.put(property.getName(), property.getDomNode().getFirstChild());

    }
    return ret;
}

From source file:com.mhs.hboxmaintenanceserver.utils.Utils.java

/**
 * Encode all prop values that need to be encoded
 *
 * @param propFile// w ww  .  jav a  2 s  .  c o  m
 * @throws Exception
 */
public static void encodeAllPropValues(File propFile) throws Exception {
    try {
        Properties p = new Properties();
        Set<Object> propKeySet;
        String propKey;

        try (FileInputStream fis = new FileInputStream(propFile)) {
            p.load(fis);
            propKeySet = p.keySet();
            for (Object _propKey : propKeySet) {
                propKey = String.valueOf(_propKey);
                String val = p.getProperty(propKey);
                if (val.matches("encode\\(.*\\)")) {
                    encryptProperty(propFile.getAbsolutePath(), propKey, val);
                }
            }
            fis.close();
        }
    } catch (FileNotFoundException ex) {
        DCXLogger.error(Utils.class, Level.SEVERE, ex);
    } catch (IOException ex) {
        DCXLogger.error(Utils.class, Level.SEVERE, ex);
    }
}