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

public void initb() {
    try {//from w  ww  .  jav a  2 s  . c  om
        InputStream is = BrandModel.class.getClass().getResourceAsStream("/brandmodel.properties");
        Properties props = new Properties();
        props.load(is);
        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++;
        }
        System.out.println("cnt: " + cnt);
        System.out.println("BRANDMODEL: " + BRANDMODEL.size());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.cruxframework.crux.core.rebind.screen.widget.WidgetLibraryMap.java

private void initializeWidgetType() throws Exception {
    widgetTypes = new HashMap<String, String>(100);
    Properties widgets = new Properties();
    ClasspathUrlFinder.loadFromConfigFiles(widgets, "META-INF/crux-widgets-type");
    Enumeration<?> widgetClasses = (Enumeration<?>) widgets.propertyNames();
    while (widgetClasses.hasMoreElements()) {
        String widgetClass = (String) widgetClasses.nextElement();
        widgetTypes.put(widgetClass, widgets.getProperty(widgetClass));
    }/*from  w ww  .ja v a  2s  .co m*/
}

From source file:com.mgmtp.jfunk.common.util.ExtendedProperties.java

/**
 * Created an instance from the specified {@link java.util.Properties} instance.
 * //from  w  w w. j ava2s.  c o  m
 * @param props
 *            The properties instance
 * @return The {@link ExtendedProperties} instance
 */
public static ExtendedProperties fromProperties(final Properties props) {
    ExtendedProperties result = new ExtendedProperties();
    for (Enumeration<?> en = props.propertyNames(); en.hasMoreElements();) {
        String key = (String) en.nextElement();
        String value = props.getProperty(key);
        result.put(key, value);
    }
    return result;
}

From source file:org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource.java

/**
 * Parses the given properties into a name/attribute map.
 * Expects method names as keys and String attributes definitions as values,
 * parsable into TransactionAttribute instances via TransactionAttributeEditor.
 * @see #setNameMap/* w  ww  .  ja va 2 s .  com*/
 * @see TransactionAttributeEditor
 */
public void setProperties(Properties transactionAttributes) {
    TransactionAttributeEditor tae = new TransactionAttributeEditor();
    Enumeration<?> propNames = transactionAttributes.propertyNames();
    while (propNames.hasMoreElements()) {
        String methodName = (String) propNames.nextElement();
        String value = transactionAttributes.getProperty(methodName);
        tae.setAsText(value);
        TransactionAttribute attr = (TransactionAttribute) tae.getValue();
        addTransactionalMethod(methodName, attr);
    }
}

From source file:org.cruxframework.crux.core.rebind.screen.widget.WidgetLibraryMap.java

private void initializeFactoryClass() throws Exception {
    factoryClass = new HashMap<String, String>(100);
    registeredLibraries = new HashMap<String, Set<String>>();
    Properties widgets = new Properties();
    ClasspathUrlFinder.loadFromConfigFiles(widgets, "META-INF/crux-widgets-factory");
    Enumeration<?> widgetTypes = (Enumeration<?>) widgets.propertyNames();
    while (widgetTypes.hasMoreElements()) {
        String widgetType = (String) widgetTypes.nextElement();

        registerWidgetLibrary(widgetType);

        factoryClass.put(widgetType, widgets.getProperty(widgetType));
    }/*from   w  w w .j  a va  2  s  .  c  om*/
}

From source file:com.cloud.test.regression.TestCase.java

public void setCommands() {
    File asyncCommands = null;/*  www.j  a v a 2 s. c  o  m*/
    if (param.get("apicommands") == null) {
        s_logger.info("Unable to get the list of commands, exiting");
        System.exit(1);
    } else {
        asyncCommands = new File(param.get("apicommands"));
    }
    try {
        Properties pro = new Properties();
        FileInputStream in = new FileInputStream(asyncCommands);
        pro.load(in);
        Enumeration<?> en = pro.propertyNames();
        while (en.hasMoreElements()) {
            String key = (String) en.nextElement();
            commands.put(key, pro.getProperty(key));
        }
    } catch (Exception ex) {
        s_logger.info(
                "Unable to find the file " + param.get("apicommands") + " due to following exception " + ex);
    }

}

From source file:net.padlocksoftware.padlock.tools.LicenseValidator.java

public String validate() {
    Date currentDate = new Date();

    Validator v = new Validator(license, new String(Hex.encodeHex(pair.getPublic().getEncoded())));
    v.setIgnoreFloatTime(true);/*from   w  w w  .ja v  a 2s  .  c om*/

    LicenseState state;
    try {
        state = v.validate();
    } catch (ValidatorException e) {
        state = e.getLicenseState();
    }

    StringBuilder builder = new StringBuilder();

    // Show test status
    builder.append("\nValidation Test Results:\n");
    builder.append("========================\n\n");
    for (TestResult result : state.getTests()) {
        builder.append(
                "\t" + result.getTest().getName() + "\t\t\t" + (result.passed() ? "Passed" : "Failed") + "\n");
    }

    builder.append("\nLicense state: " + (state.isValid() ? "Valid" : "Invalid" + "\n"));

    //
    // Cycle through any dates
    //
    Date d = license.getCreationDate();
    builder.append("\nCreation date: \t\t" + d + "\n");

    d = license.getStartDate();
    builder.append("Start date: \t\t" + d + "\n");

    d = license.getExpirationDate();
    builder.append("Expiration date: \t" + d + "\n");

    Long floatPeroid = license.getFloatingExpirationPeriod();
    if (floatPeroid != null) {
        long seconds = floatPeroid / 1000L;
        builder.append("\nExpire after first run: " + seconds + " seconds\n");

    }

    if (floatPeroid != null || license.getExpirationDate() != null) {
        long remaining = v.getTimeRemaining(currentDate) / 1000L;
        builder.append("\nTime remaining: " + remaining + " seconds\n");
    }

    //
    // License properties
    //
    builder.append("\nLicense Properties\n");
    Properties p = license.getProperties();
    if (p.size() == 0) {
        builder.append("None\n");
    }

    for (final Enumeration propNames = p.propertyNames(); propNames.hasMoreElements();) {
        final String key = (String) propNames.nextElement();
        builder.append("Property: " + key + " = " + p.getProperty(key) + "\n");
    }

    //
    // Hardware locking
    //
    for (String address : license.getHardwareAddresses()) {
        builder.append("\nHardware lock: " + address + "\n");
    }
    builder.append("\n");

    return builder.toString();
}

From source file:com.jaspersoft.jasperserver.export.ExporterImpl.java

protected void setOutputProperties() {
    Properties properties = output.getOutputProperties();
    for (Enumeration it = properties.propertyNames(); it.hasMoreElements();) {
        String property = (String) it.nextElement();
        String value = properties.getProperty(property);
        setOutputProperty(property, value);
    }/*from  www  .  j  av a  2s.co  m*/
    String version = super.getJsVersion();
    if (version != null && !version.equals("")) {
        setOutputProperty(VERSION_ATTR, version);
    }
}

From source file:org.gnieh.blue.launcher.Main.java

/**
 * <p>//from   w  w  w .ja va2  s  .c  om
 * Loads the configuration properties in the configuration property file
 * associated with the framework installation; these properties
 * are accessible to the framework and to bundles and are intended
 * for configuration purposes. By default, the configuration property
 * file is located in the <tt>conf/</tt> directory of the Felix
 * installation directory and is called "<tt>config.properties</tt>".
 * The installation directory of Felix is assumed to be the parent
 * directory of the <tt>felix.jar</tt> file as found on the system class
 * path property. The precise file from which to load configuration
 * properties can be set by initializing the "<tt>felix.config.properties</tt>"
 * system property to an arbitrary URL.
 * </p>
 * @return A <tt>Properties</tt> instance or <tt>null</tt> if there was an error.
**/
public static Map<String, String> loadConfigProperties() {
    // The config properties file is either specified by a system
    // property or it is in the conf/ directory of the Felix
    // installation directory.  Try to load it from one of these
    // places.

    // See if the property URL was specified as a property.
    URL propURL = null;
    String custom = System.getProperty(CONFIG_PROPERTIES_PROP);
    if (custom != null) {
        try {
            propURL = new URL(custom);
        } catch (MalformedURLException ex) {
            System.err.print("Main: " + ex);
            return null;
        }
    } else {
        // Determine where the configuration directory is by figuring
        // out where felix.jar is located on the system class path.
        File confDir = null;
        String classpath = System.getProperty("java.class.path");
        int index = classpath.toLowerCase().indexOf("felix.jar");
        int start = classpath.lastIndexOf(File.pathSeparator, index) + 1;
        if (index >= start) {
            // Get the path of the felix.jar file.
            String jarLocation = classpath.substring(start, index);
            // Calculate the conf directory based on the parent
            // directory of the felix.jar directory.
            confDir = new File(new File(new File(jarLocation).getAbsolutePath()).getParent(), CONFIG_DIRECTORY);
        } else {
            // Can't figure it out so use the current directory as default.
            confDir = new File(System.getProperty("user.dir"), CONFIG_DIRECTORY);
        }

        try {
            propURL = new File(confDir, CONFIG_PROPERTIES_FILE_VALUE).toURI().toURL();
        } catch (MalformedURLException ex) {
            System.err.print("Main: " + ex);
            return null;
        }
    }

    // Read the properties file.
    Properties props = new Properties();
    InputStream is = null;
    try {
        // Try to load config.properties.
        is = propURL.openConnection().getInputStream();
        props.load(is);
        is.close();
    } catch (Exception ex) {
        // Try to close input stream if we have one.
        try {
            if (is != null)
                is.close();
        } catch (IOException ex2) {
            // Nothing we can do.
        }

        return null;
    }

    // Perform variable substitution for system properties and
    // convert to dictionary.
    Map<String, String> map = new HashMap<String, String>();
    for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
        String name = (String) e.nextElement();
        map.put(name, Util.substVars(props.getProperty(name), name, null, props));
    }

    return map;
}

From source file:fr.cnamts.njc.infra.artifactory.client.CnamtsBuildInfoDeployer.java

private void addSystemVariables(final BuildInfoBuilder builder) {
    final Properties systemProperties = System.getProperties();
    final Enumeration enumeration = systemProperties.propertyNames();
    while (enumeration.hasMoreElements()) {
        final String propertyKey = (String) enumeration.nextElement();

        builder.addProperty(propertyKey, systemProperties.getProperty(propertyKey));
    }//  w  w  w .j a  va2s.  c om
}