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:org.solmix.runtime.cm.support.SpringConfigureUnitManager.java

/**
 * @param props//from   w w  w  .ja  va  2  s. c om
 */
private void checkSystemProperties(Properties properties) {
    if (properties != null) {
        Enumeration<Object> en = properties.keys();
        while (en.hasMoreElements()) {
            Object key = en.nextElement();
            Object value = properties.get(key);
            if (value != null) {
                value = DataUtils.getTemplateValue(value.toString());
            }
            properties.put(key, value);
        }
    }

}

From source file:org.openflamingo.engine.util.VersionConfigurer.java

/**
 * Key Value ?? .//  w w  w .ja v a 2s .  co  m
 *
 * @param builder {@link StringBuilder}
 * @param props    Key Value ?
 */
private void print(StringBuilder builder, Properties props) {
    int maxLength = getMaxLength(props);
    Enumeration<Object> keys = props.keys();
    while (keys.hasMoreElements()) {
        String key = (String) keys.nextElement();
        String value = props.getProperty(key);
        builder.append("  ").append(key).append(getCharacter(maxLength - key.getBytes().length, " "))
                .append(" : ").append(value).append("\n");
    }
}

From source file:edu.vt.middleware.ldap.props.AbstractPropertyConfig.java

/** {@inheritDoc} */
public void setEnvironmentProperties(final Properties properties) {
    if (properties != null) {
        final Map<String, String> props = new HashMap<String, String>();
        final Enumeration<?> en = properties.keys();
        if (en != null) {
            while (en.hasMoreElements()) {
                final String name = (String) en.nextElement();
                final String value = (String) properties.get(name);
                if (this.hasEnvironmentProperty(name)) {
                    props.put(name, value);
                } else {
                    this.setEnvironmentProperties(name, value);
                }//from   w w w.  java 2s .c o  m
            }
            for (Map.Entry<String, String> e : props.entrySet()) {
                this.setEnvironmentProperties(e.getKey(), e.getValue());
            }
        }
    }
}

From source file:org.opennms.mock.snmp.PropsMockSnmpMOLoaderImpl.java

public List<ManagedObject> loadMOs() {
    ArrayList<ManagedObject> moList = new ArrayList<ManagedObject>();

    Properties moProps = loadProperties(m_moFile);
    if (moProps == null)
        return null;

    Enumeration<Object> moKeys = moProps.keys();
    while (moKeys.hasMoreElements()) {
        String oidStr = moKeys.nextElement().toString();
        ManagedObject newMo = getMOFromPropString(oidStr, moProps.getProperty(oidStr));
        moList.add(newMo);/*from w w  w . j  a v a 2  s  . c o  m*/
    }
    return moList;
}

From source file:cn.vlabs.umt.common.mail.MessageFormatter.java

public String getFormattedMessage(Locale locale, String emailTemplateTarget, Properties prop)
        throws TemplateNotFound {
    String content = readTemplate(locale, emailTemplateTarget);
    if (prop != null) {
        Enumeration<Object> iter = prop.keys();
        while (iter.hasMoreElements()) {
            String key = (String) iter.nextElement();
            String value = prop.getProperty(key);
            if (value == null) {
                value = "";
            }//ww w  .ja v  a 2  s .  c o  m
            content = StringUtils.replace(content, "%" + key + "%", value);
        }
    }
    return CommonUtils.trim(content);
}

From source file:com.ericsson.deviceaccess.tutorial.rest.GenericDeviceServlet.java

/**
 * @param ac/*from   w  w  w . ja  v a2  s  .co  m*/
 */
private void setArguments(GDProperties ac, Properties parms) {
    Enumeration parameterNames = parms.keys();
    while (parameterNames.hasMoreElements()) {
        String paramName = (String) parameterNames.nextElement();
        String paramValue = parms.getProperty(paramName);
        ac.setStringValue(paramName, paramValue);
    }
}

From source file:org.castor.cpa.util.classresolution.command.ClassResolutionByCDR.java

/**
 * Get all descriptors from the package defined by the
 * <code>packageName</code> that contains the
 * {@link JDOConstants#PKG_CDR_LIST_FILE} file.
 * //from w  w w .j  ava2 s  . c om
 * @param packageName
 *            the package to search descriptors for.
 * @return a {@link java.util.List} of descriptors contained in the package.
 */
public Map<String, ClassDescriptor> getDescriptors(final String packageName) {
    Map<String, ClassDescriptor> descriptors = new HashMap<String, ClassDescriptor>();

    ClassLoader loader = new ClassLoaderNature(this).getClassLoader();

    URL cdrUrl = loader
            .getResource(ResolveHelpers.getQualifiedFileName(JDOConstants.PKG_CDR_LIST_FILE, packageName));

    Properties cdrList = new Properties();

    try {
        cdrList = getProperties(cdrUrl);
        Enumeration classes = cdrList.keys();
        for (; classes.hasMoreElements();) {
            String className = (String) classes.nextElement();
            String classDescriptorName = cdrList.getProperty(className);
            Class classDescriptor = ResolveHelpers.loadClass(loader, classDescriptorName);
            if (classDescriptor != null) {
                ClassDescriptor descriptorInstance = (ClassDescriptor) classDescriptor.newInstance();
                descriptors.put(className, descriptorInstance);
            }
        }
    } catch (Exception e) {
        String message = "Failure occured while loading classes from packacge \"" + packageName
                + "\" with exception: " + e;
        LOG.warn(message);
        throw new RuntimeException(e.getMessage());
    }
    return descriptors;
}

From source file:org.pentaho.reporting.ui.datasources.jdbc.ui.SimpleJdbcDataSourceDialog.java

/**
 * Displays the dialog and returns the newly created JNDIDataSetReportElement
 *
 * @param dataFactory the datafactory to be configured or null to create a new one
 * @return the a clone of the configured datafactory or null on cancel.
 *//* w  w  w .j  a  va2s  .  c o  m*/
public SimpleSQLReportDataFactory performConfiguration(final SimpleSQLReportDataFactory dataFactory) {
    dialogModel.clear();

    // Load the data from the current report element
    if (dataFactory != null) {
        dialogModel.setJdbcPasswordField(dataFactory.getPasswordField());
        dialogModel.setJdbcUserField(dataFactory.getUserField());

        final ConnectionProvider currentJNDISource = dataFactory.getConnectionProvider();
        final JdbcConnectionDefinition definition = connectionComponent
                .createConnectionDefinition(currentJNDISource);
        dialogModel.addConnection(definition);
        dialogModel.getConnections().setSelectedItem(definition);
    }

    // Enable the dialog
    if (performEdit() == false) {
        return null;
    }

    final JdbcConnectionDefinition connectionDefinition = (JdbcConnectionDefinition) dialogModel
            .getConnections().getSelectedItem();

    if (connectionDefinition == null) {
        return null;
    }

    final SimpleSQLReportDataFactory newDataFactory;

    if (connectionDefinition instanceof JndiConnectionDefinition) {
        final JndiConnectionDefinition jcd = (JndiConnectionDefinition) connectionDefinition;
        final JndiConnectionProvider provider = new JndiConnectionProvider();
        provider.setConnectionPath(jcd.getJndiName());
        provider.setUsername(jcd.getUsername());
        provider.setPassword(jcd.getPassword());
        newDataFactory = new SimpleSQLReportDataFactory(provider);
    } else if (connectionDefinition instanceof DriverConnectionDefinition) {
        final DriverConnectionDefinition dcd = (DriverConnectionDefinition) connectionDefinition;
        final DriverConnectionProvider provider = new DriverConnectionProvider();
        provider.setDriver(dcd.getDriverClass());
        provider.setUrl(dcd.getConnectionString());

        final Properties properties = dcd.getProperties();
        final Enumeration keys = properties.keys();
        while (keys.hasMoreElements()) {
            final String key = (String) keys.nextElement();
            provider.setProperty(key, properties.getProperty(key));
        }

        newDataFactory = new SimpleSQLReportDataFactory(provider);
    } else {
        return null;
    }

    newDataFactory.setPasswordField(dialogModel.getJdbcPasswordField());
    newDataFactory.setUserField(dialogModel.getJdbcUserField());
    return newDataFactory;
}

From source file:org.guzz.connection.C3P0DataSourceProvider.java

public void configure(Properties props, int maxLoad) {
    if (c3p0 == null) {
        c3p0 = new ComboPooledDataSource();
    }//from   w w  w  . j  av a 2  s .  c  o m

    JavaBeanWrapper bw = BeanWrapper.createPOJOWrapper(c3p0.getClass());
    Enumeration e = props.keys();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        String value = props.getProperty(key);

        try {
            bw.setValueAutoConvert(c3p0, key, value);
        } catch (Exception e1) {
            log.error("unkown property:[" + key + "=" + value + "]", e1);
        }
    }

    //?500
    if (maxLoad > 1000 || maxLoad < 1) {
        maxLoad = 500;
    }

    c3p0.setMaxPoolSize(maxLoad);

    //fetch a connection to force c3p0 building the pool
    Connection c = null;
    try {
        c = c3p0.getConnection();
    } catch (SQLException e1) {
        log.error(props, e1);
    } finally {
        CloseUtil.close(c);
    }
}

From source file:org.guzz.connection.DBCPDataSourceProvider.java

public void configure(Properties props, int maxLoad) {
    if (dataSource == null) {
        dataSource = new BasicDataSource();
    }/*from   ww  w  .j av a  2s  .com*/

    JavaBeanWrapper bw = BeanWrapper.createPOJOWrapper(dataSource.getClass());
    Enumeration e = props.keys();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        String value = props.getProperty(key);

        try {
            bw.setValueAutoConvert(dataSource, key, value);
        } catch (Exception e1) {
            log.error("unkown property:[" + key + "=" + value + "]", e1);
        }
    }

    //?500
    if (maxLoad > 1000 || maxLoad < 1) {
        maxLoad = 500;
    }

    dataSource.setMaxActive(maxLoad);

    //fetch a connection to force the datasource building the pool
    Connection c = null;
    try {
        c = dataSource.getConnection();
    } catch (SQLException e1) {
        log.error(props, e1);
    } finally {
        CloseUtil.close(c);
    }
}