Example usage for java.util Properties keys

List of usage examples for java.util Properties keys

Introduction

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

Prototype

@Override
    public Enumeration<Object> keys() 

Source Link

Usage

From source file:com.photon.phresco.impl.IPhoneApplicationProcessor.java

public void storeConfigObjAsPlist(Configuration keyValueObj, String plistPath) throws Exception {
    XMLPropertyListConfiguration plist = new XMLPropertyListConfiguration();
    Properties properties = keyValueObj.getProperties();
    Enumeration em = properties.keys();
    while (em.hasMoreElements()) {
        String str = (String) em.nextElement();
        plist.addProperty(str, properties.get(str));
    }//from w w w  .j  ava2 s  .  co  m
    plist.save(plistPath);

}

From source file:com.photon.phresco.impl.IPhoneApplicationProcessor.java

private JSONObject envToJsonConverter(Environment env) throws PhrescoException {
    System.out.println("env " + env);
    List<Configuration> configurations = env.getConfigurations();
    JSONObject envJson = new JSONObject();

    envJson.put("-name", env.getName());
    envJson.put("-desc", env.getDesc());
    envJson.put("-default", env.isDefaultEnv());

    for (Configuration config : configurations) {
        JSONObject configJson = new JSONObject();
        configJson.put("-name", config.getName());
        configJson.put("-desc", config.getDesc());
        Properties properties = config.getProperties();
        Enumeration em = properties.keys();

        while (em.hasMoreElements()) {
            String key = (String) em.nextElement();
            Object object = properties.get(key);
            configJson.put(key, object.toString());
        }/*from  w ww. ja v  a 2  s  . c o m*/
        envJson.put(config.getType(), configJson);
    }
    JSONObject envsJson = new JSONObject();
    envsJson.put("environment", envJson);

    JSONObject finalJson = new JSONObject();
    finalJson.put("environments", envsJson);
    System.out.println("finalJson ====> " + finalJson);
    return finalJson;
}

From source file:org.springframework.security.ui.ntlm.NtlmAuthenticationFilter.java

/**
 * Loads properties starting with "jcifs" into the JCIFS configuration.
 * Any other properties are ignored.//from w w  w.  jav  a  2s  .c  o  m
 *
 * @param props The JCIFS properties to set.
 */
public void setJcifsProperties(Properties props) {
    String name;

    for (Enumeration<?> e = props.keys(); e.hasMoreElements();) {
        name = (String) e.nextElement();
        if (name.startsWith("jcifs.")) {
            Config.setProperty(name, props.getProperty(name));
        }
    }
}

From source file:edu.rice.dca.soaplabPBS.PBSJob.java

/**************************************************************************
 * Add the contents of 'props' to 'result'.
 **************************************************************************/
private void addProperties(Map<String, String> result, Properties props) {
    for (Enumeration<Object> en = props.keys(); en.hasMoreElements();) {
        String envName = (String) en.nextElement();
        result.put(envName, props.getProperty(envName));
    }//from w w  w.  j a  v a  2 s  . c o  m
}

From source file:fr.fastconnect.factory.tibco.bw.maven.packaging.MergePropertiesMojo.java

private Properties duplicateEmptyBinding(Properties properties, String par, String binding) {
    String key, value;//from w  w w . j  a  va2s .c om
    Pattern pEmptyBinding = Pattern.compile(regexEmptyBinding);

    Enumeration<Object> e = properties.keys();
    while (e.hasMoreElements()) {
        key = (String) e.nextElement();
        value = properties.getProperty(key);
        Matcher mEmptyBinding = pEmptyBinding.matcher(key);
        if (mEmptyBinding.matches() && mEmptyBinding.group(1).equals(par)) {
            key = "bw[" + mEmptyBinding.group(1) + "]/bindings/binding[" + binding + "]/"
                    + mEmptyBinding.group(3);
        }
        properties.setProperty(key, value);
    }
    return properties;
}

From source file:org.jfrog.teamcity.agent.listener.AgentListenerReleaseHelper.java

private boolean changeProperties(BuildRunnerContext runner, BuildProgressLogger logger,
        ReleaseParameters releaseParams, boolean releaseVersion) throws IOException, InterruptedException {
    logger.progressStarted("[RELEASE] Changing versions in the gradle properties file");
    File workingDir = runner.getWorkingDirectory();
    File gradlePropertiesFile = new File(workingDir, ConstantValues.GRADLE_PROPERTIES_FILE_NAME);

    Properties properties = new Properties();
    FileInputStream propertiesInputStream = null;

    try {/* w w w .  j av  a2s . c o  m*/
        propertiesInputStream = new FileInputStream(gradlePropertiesFile);
        properties.load(propertiesInputStream);
    } finally {
        IOUtils.closeQuietly(propertiesInputStream);
    }

    Map<String, String> modulesByName = Maps.newHashMap();
    Enumeration<Object> propertyKeys = properties.keys();
    while (propertyKeys.hasMoreElements()) {
        String propertyKey = (String) propertyKeys.nextElement();
        String version = releaseVersion ? releaseParams.getReleaseVersionForModule(propertyKey)
                : releaseParams.getNextVersionForModule(propertyKey);
        if (StringUtils.isNotBlank(version)) {
            modulesByName.put(propertyKey, version);
        }
    }
    vcsCoordinator.edit(gradlePropertiesFile);
    return new PropertiesTransformer(gradlePropertiesFile, modulesByName).transform();
}

From source file:org.las.tools.LanguageIdentifier.LanguageIdentifier.java

public LanguageIdentifier() {

    // Gets ngram sizes to take into account from the Nutch Config
    minLength = NGramProfile.DEFAULT_MIN_NGRAM_LENGTH;
    maxLength = NGramProfile.DEFAULT_MAX_NGRAM_LENGTH;
    // Ensure the min and max values are in an acceptale range
    // (ie min >= DEFAULT_MIN_NGRAM_LENGTH and max <= DEFAULT_MAX_NGRAM_LENGTH)

    // Gets the value of the maximum size of data to analyze
    analyzeLength = DEFAULT_ANALYSIS_LENGTH;

    Properties p = new Properties();
    try {//from w  w  w  .  jav  a 2  s  .  c o m
        p.load(this.getClass().getResourceAsStream("langmappings.properties"));

        Enumeration<?> alllanguages = p.keys();

        /*
        if (LOG.isInfoEnabled()) { 
          LOG.info(new StringBuffer()
             .append("Language identifier configuration [")
             .append(minLength).append("-").append(maxLength)
             .append("/").append(analyzeLength).append("]").toString());
        }
        */

        StringBuffer list = new StringBuffer("Language identifier plugin supports:");
        HashMap<NGramEntry, List<NGramEntry>> tmpIdx = new HashMap<NGramEntry, List<NGramEntry>>();
        while (alllanguages.hasMoreElements()) {
            String lang = (String) (alllanguages.nextElement());

            InputStream is = this.getClass().getClassLoader()
                    .getResourceAsStream("cn/nsl/lang/id/" + lang + "." + NGramProfile.FILE_EXTENSION);

            if (is != null) {
                NGramProfile profile = new NGramProfile(lang, minLength, maxLength);
                try {
                    profile.load(is);
                    languages.add(profile);
                    supportedLanguages.add(lang);
                    List<NGramEntry> ngrams = profile.getSorted();
                    for (int i = 0; i < ngrams.size(); i++) {
                        NGramEntry entry = ngrams.get(i);
                        List<NGramEntry> registered = tmpIdx.get(entry);
                        if (registered == null) {
                            registered = new ArrayList<NGramEntry>();
                            tmpIdx.put(entry, registered);
                        }
                        registered.add(entry);
                        entry.setProfile(profile);
                    }
                    list.append(" " + lang + "(" + ngrams.size() + ")");
                    is.close();
                } catch (IOException e1) {
                    if (LOG.isFatalEnabled()) {
                        LOG.fatal(e1.toString());
                    }
                }
            }
        }
        // transform all ngrams lists to arrays for performances
        Iterator<NGramEntry> keys = tmpIdx.keySet().iterator();
        while (keys.hasNext()) {
            NGramEntry entry = keys.next();
            List<NGramEntry> l = tmpIdx.get(entry);
            if (l != null) {
                NGramEntry[] array = l.toArray(new NGramEntry[l.size()]);
                ngramsIdx.put(entry.getSeq(), array);
            }
        }
        //if (LOG.isInfoEnabled()) { LOG.info(list.toString()); }
        // Create the suspect profile
        suspect = new NGramProfile("suspect", minLength, maxLength);
    } catch (Exception e) {
        if (LOG.isFatalEnabled()) {
            LOG.fatal(e.toString());
        }
    }
}

From source file:org.apache.flex.forks.velocity.runtime.configuration.Configuration.java

/**
 * Convert a standard properties class into a configuration
 * class.//from www  .jav a 2s  . co m
 *
 * @param Properties properties object to convert into
 *                   a Configuration object.
 *
 * @return Configuration configuration created from the
 *                      properties object.
 */
public static Configuration convertProperties(Properties p) {
    Configuration c = new Configuration();

    for (Enumeration e = p.keys(); e.hasMoreElements();) {
        String s = (String) e.nextElement();
        c.setProperty(s, p.getProperty(s));
    }

    return c;
}

From source file:org.jfrog.teamcity.agent.BaseBuildInfoExtractor.java

private Map<String, String> getMatrixParams() {
    Map<String, String> matrixParams = Maps.newHashMap();

    Properties buildInfoProperties = BuildInfoExtractorUtils
            .mergePropertiesWithSystemAndPropertyFile(new Properties());
    Properties filteredMatrixParams = BuildInfoExtractorUtils.filterDynamicProperties(buildInfoProperties,
            BuildInfoExtractorUtils.MATRIX_PARAM_PREDICATE);

    Enumeration<Object> propertyKeys = filteredMatrixParams.keys();
    while (propertyKeys.hasMoreElements()) {
        String key = propertyKeys.nextElement().toString();
        matrixParams.put(key, filteredMatrixParams.getProperty(key));
    }/*  ww  w . j a  va  2s  . c o  m*/
    matrixParams.put("build.name", runnerParams.get(BUILD_NAME));
    matrixParams.put("build.number", runnerContext.getBuild().getBuildNumber());
    matrixParams.put("build.timestamp", runnerParams.get(PROP_BUILD_TIMESTAMP));

    if (StringUtils.isNotBlank(runnerParams.get(PROP_PARENT_NAME))) {
        matrixParams.put("build.parentName", runnerParams.get(PROP_PARENT_NAME));
    }

    if (StringUtils.isNotBlank(runnerParams.get(PROP_PARENT_NUMBER))) {
        matrixParams.put("build.parentNumber", runnerParams.get(PROP_PARENT_NUMBER));
    }

    if (StringUtils.isNotBlank(runnerParams.get(PROP_VCS_REVISION))) {
        matrixParams.put(BuildInfoFields.VCS_REVISION, runnerParams.get(PROP_VCS_REVISION));
    }

    HashMap<String, String> allParamMap = Maps
            .newHashMap(runnerContext.getBuildParameters().getAllParameters());
    allParamMap.putAll(((BuildRunnerContextImpl) runnerContext).getConfigParameters());
    gatherBuildInfoParams(allParamMap, matrixParams, ClientProperties.PROP_DEPLOY_PARAM_PROP_PREFIX,
            Constants.ENV_PREFIX, Constants.SYSTEM_PREFIX);

    return matrixParams;
}

From source file:org.executequery.ApplicationLauncher.java

private void printSystemProperties() {
    if (Log.isTraceEnabled()) {

        Log.trace(" --- System properties --- ");

        List<String> keys = new ArrayList<String>();
        Properties properties = System.getProperties();
        for (Enumeration<Object> i = properties.keys(); i.hasMoreElements();) {

            keys.add((String) i.nextElement());
        }//from  w w w. j a  v  a  2s .c  o  m

        Collections.sort(keys);
        for (String key : keys) {

            Log.trace(key + ": " + properties.getProperty(key));
        }
    }
}