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:dtu.ds.warnme.utils.PropertiesUtils.java

@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
        throws BeansException {
    super.processProperties(beanFactory, props);

    PROPERTIES = new HashMap<String, String>();
    for (Object key : props.keySet()) {
        String keyStr = key.toString();
        String valueStr = resolvePlaceholder(keyStr, props, springSystemPropertiesMode);
        PROPERTIES.put(keyStr, valueStr);
    }//  www  .  j av  a 2 s. c o m
}

From source file:com.socialize.util.HttpUtils.java

public void init(Context context) {
    InputStream in = null;/*from  w w  w  .ja va  2s  .  c o  m*/
    try {
        in = resourceLocator.locate(context, SocializeConfig.SOCIALIZE_ERRORS_PATH);

        Properties props = new Properties();
        props.load(in);

        Set<Object> keys = props.keySet();

        for (Object object : keys) {
            try {
                int code = Integer.parseInt(object.toString());
                String msg = props.getProperty(object.toString());
                httpStatusCodes.put(code, msg);
            } catch (NumberFormatException e) {
                if (logger != null && logger.isWarnEnabled()) {
                    logger.warn(object.toString() + " is not an integer");
                }
            }
        }
    } catch (Exception e) {
        if (logger != null) {
            logger.error(SocializeLogger.ERROR_CODE_LOAD_FAIL, e);
        }
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException ignore) {
            }
        }
    }
}

From source file:com.pkrete.locationservice.admin.util.PropertiesUtil.java

@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
        throws BeansException {
    super.processProperties(beanFactory, props);

    propertiesMap = new HashMap<String, String>();
    for (Object key : props.keySet()) {
        String keyStr = key.toString();
        propertiesMap.put(keyStr, parseStringValue(props.getProperty(keyStr), props, new HashSet()));
    }/*w  w  w  .  ja  v a 2 s  .  c o m*/
}

From source file:com.interface21.transaction.interceptor.TransactionAttributeSourceEditor.java

public void setAsText(String s) throws IllegalArgumentException {
    MapTransactionAttributeSource source = new MapTransactionAttributeSource();
    if (s == null || "".equals(s)) {
        // Leave value in property editor null
    } else {/* w w  w.  j a va  2  s.c om*/
        // Use properties editor to tokenize the hold string
        PropertiesEditor propertiesEditor = new PropertiesEditor();
        propertiesEditor.setAsText(s);
        Properties p = (Properties) propertiesEditor.getValue();

        // Now we have properties, process each one individually
        Set keys = p.keySet();
        for (Iterator iter = keys.iterator(); iter.hasNext();) {
            String name = (String) iter.next();
            String value = p.getProperty(name);
            parseMethodDescriptor(name, value, source);
        }
    }
    setValue(source);
}

From source file:org.apache.hadoop.hive.ql.exec.ExecDriver.java

/**
 * Given a Hive Configuration object - generate a command line fragment for passing such
 * configuration information to ExecDriver.
 *///from w  ww  . j av  a2  s . co  m
public static String generateCmdLine(HiveConf hconf) {
    try {
        StringBuilder sb = new StringBuilder();
        Properties deltaP = hconf.getChangedProperties();
        boolean hadoopLocalMode = ShimLoader.getHadoopShims().isLocalMode(hconf);
        String hadoopSysDir = "mapred.system.dir";
        String hadoopWorkDir = "mapred.local.dir";

        for (Object one : deltaP.keySet()) {
            String oneProp = (String) one;

            if (hadoopLocalMode && (oneProp.equals(hadoopSysDir) || oneProp.equals(hadoopWorkDir))) {
                continue;
            }

            String oneValue = deltaP.getProperty(oneProp);

            sb.append("-jobconf ");
            sb.append(oneProp);
            sb.append("=");
            sb.append(URLEncoder.encode(oneValue, "UTF-8"));
            sb.append(" ");
        }

        // Multiple concurrent local mode job submissions can cause collisions in
        // working dirs
        // Workaround is to rename map red working dir to a temp dir in such cases

        if (hadoopLocalMode) {
            sb.append("-jobconf ");
            sb.append(hadoopSysDir);
            sb.append("=");
            sb.append(URLEncoder.encode(hconf.get(hadoopSysDir) + "/" + Utilities.randGen.nextInt(), "UTF-8"));

            sb.append(" ");
            sb.append("-jobconf ");
            sb.append(hadoopWorkDir);
            sb.append("=");
            sb.append(URLEncoder.encode(hconf.get(hadoopWorkDir) + "/" + Utilities.randGen.nextInt(), "UTF-8"));
        }

        return sb.toString();
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.cyclopsgroup.waterview.web.ProcessFormValve.java

/**
 * Overwrite or implement method invoke()
 *
 * @see com.cyclopsgroup.waterview.spi.Valve#invoke(com.cyclopsgroup.waterview.RuntimeData, com.cyclopsgroup.waterview.spi.PipelineContext)
 *///  w  w  w  . j a  v  a 2  s. c o  m
public void invoke(RuntimeData data, PipelineContext pc) throws Exception {
    Parameters params = data.getParameters();
    String formId = params.getString("form_id");
    Form form = null;
    if (StringUtils.isNotEmpty(formId)) {
        form = (Form) data.getSessionContext().get(formId);
    }

    if (form == null) {
        pc.invokeNextValve(data);
        return;
    }

    boolean hasError = false;
    Field[] fields = form.getFields();
    for (int i = 0; i < fields.length; i++) {
        Field field = fields[i];
        field.setValue(params.getString(field.getName()));
        field.validate();
        if (field.isPassword()) {
            field.setValue(StringUtils.EMPTY);
        }
        if (!hasError && field.isInvalid()) {
            hasError = true;
        }
    }
    if (hasError) {
        if (params.getBoolean("force_validation")) {
            fail(data, pc);
            return;
        }
    }
    pc.invokeNextValve(data);
    Boolean formInvalid = (Boolean) data.getRequestContext().get("formInvalid");
    if (formInvalid != null && formInvalid.booleanValue()) {
        Properties formErrors = (Properties) data.getRequestContext().get("formErrors");
        for (Iterator i = formErrors.keySet().iterator(); i.hasNext();) {
            String fieldName = (String) i.next();
            String errorMessage = formErrors.getProperty(fieldName);
            Field field = form.getField(fieldName);
            if (field != null) {
                field.setInvalid(true);
                if (StringUtils.isEmpty(errorMessage)) {
                    field.setErrorMessage("Invalid field value ");
                } else {
                    field.setErrorMessage(errorMessage);
                }
            }
        }
        if (params.getBoolean("force_validation")) {
            fail(data, pc);
        }
    }
}

From source file:com.springer.omelet.data.PropertyMapping.java

/***
 * Create hash map for all the loaded properties file
 * //from   w  w  w .  j  a  v a  2 s  .  c  om
 * @param prop
 */
private void createHashMap(Properties prop) {
    String key;
    Iterator<Object> i = prop.keySet().iterator();
    while (i.hasNext()) {
        key = (String) i.next();
        propertiesValue.put(key, prop.getProperty(key));
    }
}

From source file:io.wcm.devops.conga.tooling.maven.plugin.ValidateVersionInfoMojo.java

private void validateVersionInfo(Properties currentVersionInfo, Properties dependencyVersionInfo)
        throws MojoExecutionException {
    for (Object keyObject : currentVersionInfo.keySet()) {
        String key = keyObject.toString();
        String currentVersionString = currentVersionInfo.getProperty(key);
        String dependencyVersionString = dependencyVersionInfo.getProperty(key);
        if (StringUtils.isEmpty(currentVersionString) || StringUtils.isEmpty(dependencyVersionString)) {
            continue;
        }/*from   ww  w. j  av  a2  s . c o m*/
        DefaultArtifactVersion currentVersion = new DefaultArtifactVersion(currentVersionString);
        DefaultArtifactVersion dependencyVersion = new DefaultArtifactVersion(dependencyVersionString);
        if (currentVersion.compareTo(dependencyVersion) < 0) {
            throw new MojoExecutionException("Newer CONGA maven plugin or plugin version required: " + key + ":"
                    + dependencyVersion.toString());
        }
    }
}

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

public void initialize(Properties properties) {
    for (Object key : properties.keySet()) {
        if (key.toString().startsWith(this.id + ".")) {
            if (logger.isDebugEnabled()) {
                logger.debug("Found: " + key);
            }/*from w ww.  ja  v a2s .  co m*/
            if (key.toString().endsWith(".name")) {
                this.name = properties.getProperty(key.toString());
            } else if (key.toString().endsWith(".description")) {
                this.description = properties.getProperty(key.toString());
            }
        }
    }
}

From source file:io.uengine.web.configuration.ConfigurationHelper.java

private void inject(Properties config) {
    Set<Object> configs = config.keySet();
    for (Object obj : configs) {
        String key = (String) obj;
        String value = config.getProperty(key);

        this.map.put(key, value);
        this.props.put(key, value);

        logger.debug("Loaded {}={}", key, value);
    }//from   w w  w. j  a  v  a  2  s  .  c o m
}