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.sanlq.common.BrandModel.java

private void inita() {
    if (BRANDMODEL_CONTENT == null) {
        BRANDMODEL_CONTENT = readHDFSFile("hdfs://hadoopcluster/data/lib/brandmodel/brandmodel.dat");
        try {/* w  ww.j a v  a2  s.com*/
            //                String content = new String(BRANDMODEL_CONTENT, "UTF-8");
            //                List<ModelBean> list = JSON.parseArray(content, ModelBean.class);
            //                Integer cnt = 0;
            //                for (ModelBean modelBean : list) {
            //                    BRANDMODEL.put(modelBean.getTitleOrg(), modelBean);
            //                    cnt++;
            //                    if (cnt % 1000 == 0) {
            //                        log.info("ALREADY IMPORT " + cnt + " MODEL ");
            //                    }
            //                }
            Properties props = new Properties();
            BufferedReader bf = new BufferedReader(
                    new InputStreamReader(new ByteArrayInputStream(BRANDMODEL_CONTENT)));
            props.load(bf);
            System.out.println("props: " + props.size());
            Enumeration enu2 = props.propertyNames();
            Integer cnt = 0;
            while (enu2.hasMoreElements()) {
                String key = (String) enu2.nextElement();
                String d = props.getProperty(key);
                String[] arrd = d.split("::");
                ModelBean mbean = new ModelBean();
                if (arrd.length == 6) {
                    mbean.setBrandId(Integer.valueOf(arrd[0]));
                    mbean.setBrandTitleEn(arrd[1]);
                    mbean.setBrandTitleCn(arrd[2]);
                    mbean.setTitleOrg(arrd[3]);
                    mbean.setTitleCn(arrd[4]);
                    mbean.setTitleEn(arrd[5]);
                    if (BRANDMODEL.contains(arrd[3])) {
                        System.out.println("Exist: " + d);
                    } else {
                        BRANDMODEL.put(arrd[3], mbean);
                    }
                } else {
                    System.out.println("ERR: " + d);
                }
                cnt++;
            }
            log.info("DONE IMPORT " + cnt + " MODEL " + BRANDMODEL.size());
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(BrandModel.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(BrandModel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

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

private void addSystemProperties(BuildInfoBuilder builder, IncludeExcludePatterns patterns) {
    Properties systemProperties = System.getProperties();
    Enumeration<?> enumeration = systemProperties.propertyNames();
    while (enumeration.hasMoreElements()) {
        String propertyKey = (String) enumeration.nextElement();
        if (PatternMatcher.pathConflicts(propertyKey, patterns)) {
            continue;
        }//from www .  jav  a 2s . c  om
        builder.addProperty(propertyKey, systemProperties.getProperty(propertyKey));
    }
}

From source file:org.ops4j.pax.runner.platform.felix.internal.FelixPlatformBuilder.java

/**
 * Writes properties to configuration file.
 *
 * @param writer     a property writer/*  w  w  w  .  j a  v  a2 s .co m*/
 * @param properties properties to be written; can be null
 */
private void appendProperties(final PropertiesWriter writer, final Properties properties) {
    if (properties != null) {
        final Enumeration<?> enumeration = properties.propertyNames();
        while (enumeration.hasMoreElements()) {
            final String key = (String) enumeration.nextElement();
            writer.append(key, properties.getProperty(key));
        }
    }
}

From source file:org.canova.cli.subcommands.Vectorize.java

/**
 * Dont change print stuff, its part of application console output UI
 * //from w w  w.  j av  a2 s . com
 */
public void debugLoadedConfProperties() {
    Properties props = this.configProps; //System.getProperties();
    Enumeration e = props.propertyNames();

    System.out.println("\n--- Start Canova Configuration ---");

    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        System.out.println(key + " -- " + props.getProperty(key));
    }

    System.out.println("---End Canova Configuration ---\n");
}

From source file:net.erdfelt.android.sdkfido.configer.Configer.java

/**
 * Restore from persistent storage./*from  w w w.  j  a v a2 s. c om*/
 * 
 * @throws IOException
 *             if unable to read persisted storage file.
 * @see #setPersistFile(File)
 * @see #persist()
 */
public void restore() throws IOException {
    if (!this.persistFile.exists()) {
        return; // nothing to load. skip it.
    }
    FileReader reader = null;
    try {
        reader = new FileReader(this.persistFile);
        Properties props = new Properties();
        props.load(reader);

        @SuppressWarnings("unchecked")
        Enumeration<String> keys = (Enumeration<String>) props.propertyNames();
        while (keys.hasMoreElements()) {
            String key = keys.nextElement();
            setValue(key, props.getProperty(key));
        }
    } finally {
        IOUtils.closeQuietly(reader);
    }
}

From source file:org.springframework.batch.admin.web.util.HomeController.java

private Set<String> buildUrlsFromProperties(Properties properties) {
    Set<String> urls = new HashSet<String>();
    if (properties == null) {
        return urls;
    }/*from   w w w .j ava2  s .c  o  m*/
    for (Enumeration<?> iterator = properties.propertyNames(); iterator.hasMoreElements();) {
        String key = (String) iterator.nextElement();
        String url = key.substring(key.indexOf("/"));
        urls.add(url);
    }
    return urls;
}

From source file:org.finra.herd.dao.ReloadablePropertySourceTest.java

/**
 * Creates a clone of the specified properties object.
 *
 * @param properties the source properties.
 *
 * @return the cloned properties.//ww  w  .j a va 2  s. com
 */
private Properties cloneProperties(Properties properties) {
    Properties clonedProperties = new Properties();
    for (Enumeration<?> propertyNames = properties.propertyNames(); propertyNames.hasMoreElements();) {
        Object key = propertyNames.nextElement();
        clonedProperties.put(key, properties.get(key));
    }
    return clonedProperties;
}

From source file:org.wso2.carbon.identity.event.EventMgtConfigBuilder.java

/**
 * Build a list of subscription by a particular module
 *
 * @param moduleName       Name of the module
 * @param moduleProperties Set of properties which
 * @return A list of subscriptions by the module
 *///from w w w  .  j a va  2 s  .c o  m
private List<Subscription> buildSubscriptionList(String moduleName, Properties moduleProperties) {
    // Get subscribed events
    Properties subscriptions = EventManagementUtils.getSubProperties(moduleName + "." + "subscription",
            moduleProperties);

    List<Subscription> subscriptionList = new ArrayList<Subscription>();
    Enumeration propertyNames = subscriptions.propertyNames();
    // Iterate through events and build event objects
    while (propertyNames.hasMoreElements()) {
        String key = (String) propertyNames.nextElement();
        String subscriptionName = (String) subscriptions.remove(key);
        // Read all the event properties starting from the event prefix
        Properties subscriptionProperties = EventManagementUtils.getPropertiesWithPrefix(
                moduleName + "." + "subscription" + "." + subscriptionName, moduleProperties);
        Subscription subscription = new Subscription(subscriptionName, subscriptionProperties);
        subscriptionList.add(subscription);
    }
    return subscriptionList;
}

From source file:org.trpr.platform.servicefw.impl.spring.web.HomeController.java

/**
 * @param properties/* w w  w  .j  a v  a  2  s. c om*/
 * 
 */
private Set<String> buildUrlsFromProperties(Properties properties) {
    Set<String> urls = new HashSet<String>();
    if (properties == null) {
        return urls;
    }
    for (Enumeration<?> iterator = properties.propertyNames(); iterator.hasMoreElements();) {
        String key = (String) iterator.nextElement();
        String url = key.substring(key.indexOf("/"));
        urls.add(url);
    }
    return urls;
}

From source file:org.wso2.carbon.identity.event.IdentityEventConfigBuilder.java

/**
 * Build a list of subscription by a particular module
 *
 * @param moduleName       Name of the module
 * @param moduleProperties Set of properties which
 * @return A list of subscriptions by the module
 *//*from  w w w . j av  a2 s . co m*/
private List<Subscription> buildSubscriptionList(String moduleName, Properties moduleProperties) {
    // Get subscribed events
    Properties subscriptions = IdentityEventUtils.getSubProperties(moduleName + "." + "subscription",
            moduleProperties);

    List<Subscription> subscriptionList = new ArrayList<Subscription>();
    Enumeration propertyNames = subscriptions.propertyNames();
    // Iterate through events and build event objects
    while (propertyNames.hasMoreElements()) {
        String key = (String) propertyNames.nextElement();
        String subscriptionName = (String) subscriptions.remove(key);
        // Read all the event properties starting from the event prefix
        Properties subscriptionProperties = IdentityEventUtils.getPropertiesWithPrefix(
                moduleName + "." + "subscription" + "." + subscriptionName, moduleProperties);
        Subscription subscription = new Subscription(subscriptionName, subscriptionProperties);
        subscriptionList.add(subscription);
    }
    return subscriptionList;
}