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:org.chililog.server.common.SystemProperties.java

/**
 * String representation of the values are have parsed
 *///  w  w  w  .jav a 2  s .c o  m
public String toString() {
    StringBuilder sb = new StringBuilder();

    // Get all system properties
    Properties props = System.getProperties();

    // Enumerate all system properties
    Enumeration<?> e = props.propertyNames();
    for (; e.hasMoreElements();) {
        String name = (String) e.nextElement();
        String value = (String) props.get(name);

        sb.append(name);
        sb.append(" = ");
        sb.append(value);
        sb.append("\n");
    }

    return sb.toString();
}

From source file:org.metaeffekt.dcc.commons.ant.ApplyVelocityTemplateTask.java

private void addConcreteExtensionSequence(Pattern extensionPattern, VelocityContext velocityContext,
        String suffix, Properties inputProperties) {

    final Set<String> existingKeys = new HashSet<>();
    for (Enumeration<?> enumeration = inputProperties.propertyNames(); enumeration.hasMoreElements();) {
        final String key = (String) enumeration.nextElement();
        final Matcher matcher = extensionPattern.matcher(key);
        if (matcher.matches()) {
            final List<String> sequence = deserializeSequence(inputProperties.getProperty(key));
            final String extensionName = matcher.group(1);
            String variableName = removeIllegalCharactersFromVariableName(extensionName + suffix);
            if (existingKeys.contains(variableName)) {
                variableName = generateUniqueName(variableName, existingKeys);
            }//from w w w  . ja va2  s. c o  m
            existingKeys.add(variableName);
            velocityContext.put(variableName, sequence);
        } else {
            existingKeys.add(key);
        }
    }
}

From source file:org.opennms.netmgt.ticketer.quickbase.QuickBaseTicketerPlugin.java

private void addAdditionCreationFields(HashMap<String, String> record, Properties props) {
    final String prefix = "quickbase.create.";
    Enumeration keys = props.propertyNames();
    while (keys.hasMoreElements()) {
        String key = (String) keys.nextElement();
        if (key.startsWith(prefix)) {
            String field = key.substring(prefix.length());
            record.put(field, props.getProperty(key));
        }//from   ww w  .  j ava 2 s.c  om
    }
}

From source file:org.wso2.carbon.identity.notification.mgt.json.bean.JsonSubscription.java

/**
 * Set endpoints to the json subscription object
 *
 * @param prefix              Prefix of the endpoint properties key. ie json.subscribe.eventName.endpoint.endpointName
 * @param endpointsProperties Properties which are relevant to endpoint.
 *//*from www .j  av a  2s . c  om*/
private void setEndpoints(String prefix, Properties endpointsProperties) {

    Properties endpointNames = NotificationManagementUtils.getSubProperties(prefix, endpointsProperties);
    Enumeration endpointNameSet = endpointNames.propertyNames();

    while (endpointNameSet.hasMoreElements()) {
        String key = (String) endpointNameSet.nextElement();
        String endpointName = (String) endpointNames.remove(key);

        String endpointKey = prefix + "." + endpointName;
        Properties endpointProperties = NotificationManagementUtils.getPropertiesWithPrefix(endpointKey,
                endpointsProperties);

        try {
            endpointInfoList.add(buildEndpoint(endpointKey, endpointProperties));
        } catch (NotificationManagementException e) {
            log.error("Error while building endpoint object with key " + endpointKey, e);
        }
    }
}

From source file:org.nuxeo.ecm.platform.importer.properties.MetadataCollector.java

public void addPropertyFile(File propertyFile) throws Exception {

    Properties mdProperties = new Properties();
    mdProperties.load(new FileInputStream(propertyFile));

    Map<String, String> stringMap = new HashMap<String, String>();
    Enumeration names = mdProperties.propertyNames();
    while (names.hasMoreElements()) {
        String name = (String) names.nextElement();
        stringMap.put(name, mdProperties.getProperty(name));
    }//from w ww. jav a2  s .c om
    String contextPath = new File(propertyFile.getPath()).getParent();
    addPropertiesFromStrings(contextPath, stringMap);
}

From source file:org.gbif.ipt.config.JdbcSupport.java

protected int setProperties(Properties props) {
    driver.clear();/*from  www . j  a v  a  2s. co m*/
    // get distinct list of driver names
    Set<String> names = new HashSet<String>();
    for (Enumeration propertyNames = props.propertyNames(); propertyNames.hasMoreElements();) {
        String name = StringUtils.substringBefore((String) propertyNames.nextElement(), ".");
        names.add(name);
    }
    // create a jdbc info object for each
    for (String name : names) {
        name = name.toLowerCase();
        LIMIT_TYPE lt = LIMIT_TYPE.valueOf(props.getProperty(name + ".limitType"));
        JdbcInfo info = new JdbcInfo(name, props.getProperty(name + ".title"),
                props.getProperty(name + ".driver"), props.getProperty(name + ".url"), lt);
        driver.put(name, info);
    }
    return driver.size();
}

From source file:org.springmodules.workflow.osworkflow.configuration.ConfigurationBean.java

/**
 * Sets the locations of the workflow definition files as a
 * <code>Properties</code> instance. The key of each entry corresponds to
 * the logical name for the workflow definition and the value of each entry
 * is the location of the definition file. <p/> Locations are specified as
 * Spring-style resource paths and classpath: resources are fully supported.
 *//*from w  ww.j a va  2 s.  c  om*/
public void setWorkflowLocations(Properties workflowLocations) {
    Assert.notNull(workflowLocations, "workflowLocations cannot be null");

    Enumeration workflowNames = workflowLocations.propertyNames();
    while (workflowNames.hasMoreElements()) {
        String name = (String) workflowNames.nextElement();
        String resourceLocation = workflowLocations.getProperty(name);

        if (logger.isInfoEnabled()) {
            logger.info("Loading workflow [" + name + "] from [" + resourceLocation + "].");
        }

        workflows.put(name, loadWorkflowDescriptor(resourceLocation, name));
    }

    this.initialized = true;
}

From source file:org.apache.syncope.core.provisioning.java.job.notification.NotificationJobDelegate.java

@Override
public void afterPropertiesSet() throws Exception {
    if (mailSender instanceof JavaMailSenderImpl) {
        JavaMailSenderImpl javaMailSender = (JavaMailSenderImpl) mailSender;

        Properties javaMailProperties = javaMailSender.getJavaMailProperties();

        Properties props = PropertyUtils.read(Encryptor.class, "mail.properties", "conf.directory").getLeft();
        for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();) {
            String prop = (String) e.nextElement();
            if (prop.startsWith("mail.smtp.")) {
                javaMailProperties.setProperty(prop, props.getProperty(prop));
            }/*from   w  w  w  . j av a 2s .co  m*/
        }

        if (StringUtils.isNotBlank(javaMailSender.getUsername())) {
            javaMailProperties.setProperty("mail.smtp.auth", "true");
        }

        javaMailSender.setJavaMailProperties(javaMailProperties);

        String mailDebug = props.getProperty("mail.debug", "false");
        if (BooleanUtils.toBoolean(mailDebug)) {
            Session session = javaMailSender.getSession();
            session.setDebug(true);
            session.setDebugOut(new PrintStream(new LogOutputStream(LOG)));
        }
    }
}

From source file:com.stacksync.desktop.Environment.java

public void main(String[] args) {
    Properties properties = System.getProperties();

    Enumeration e = properties.propertyNames();

    System.out.println("Properties");
    System.out.println("---------------");

    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        System.out.println(key + " = " + System.getProperty(key));
    }/*from  ww w. j  av a  2s . c o  m*/

    System.out.println("ENV");
    System.out.println("---------------");

    for (Map.Entry<String, String> es : System.getenv().entrySet()) {
        System.out.println(es.getKey() + " = " + es.getValue());
    }
}

From source file:org.apache.stratos.metadata.service.registry.CarbonRegistry.java

public List<Property> getApplicationProperties(String applicationName) throws RegistryException {
    Registry tempRegistry = getRegistry();
    String resourcePath = mainResource + applicationName;

    if (!tempRegistry.resourceExists(resourcePath)) {
        return null;
    }/*from www .  ja va2s  .  c  om*/

    PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
    ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);

    Resource regResource = tempRegistry.get(resourcePath);
    ArrayList<Property> newProperties = new ArrayList<Property>();

    Properties props = regResource.getProperties();
    Enumeration<?> x = props.propertyNames();
    while (x.hasMoreElements()) {
        String key = (String) x.nextElement();
        List<String> values = regResource.getPropertyValues(key);
        Property property = new Property();
        property.setKey(key);
        String[] valueArr = new String[values.size()];
        property.setValues(values.toArray(valueArr));

        newProperties.add(property);
    }
    return newProperties;
}