Example usage for org.springframework.beans.propertyeditors PropertiesEditor setAsText

List of usage examples for org.springframework.beans.propertyeditors PropertiesEditor setAsText

Introduction

In this page you can find the example usage for org.springframework.beans.propertyeditors PropertiesEditor setAsText.

Prototype

@Override
public void setAsText(@Nullable String text) throws IllegalArgumentException 

Source Link

Document

Convert String into Properties , considering it as properties content.

Usage

From source file:org.openvpms.component.business.service.security.memory.UserMapEditor.java

@Override
public void setAsText(String str) throws IllegalArgumentException {
    UserMap userMap = new UserMap();

    if (StringUtils.hasText(str)) {
        // Use properties editor to tokenize the string
        PropertiesEditor propertiesEditor = new PropertiesEditor();
        propertiesEditor.setAsText(str);

        Properties props = (Properties) propertiesEditor.getValue();
        addUsersFromProperties(userMap, props);
    }/*from   w w  w.  j a va 2  s .  c o  m*/

    setValue(userMap);
}

From source file:org.acegisecurity.intercept.method.MethodDefinitionSourceEditor.java

public void setAsText(String s) throws IllegalArgumentException {
    MethodDefinitionMap source = new MethodDefinitionMap();

    if ((s == null) || "".equals(s)) {
        // Leave value in property editor null
    } else {/*from  w  w  w .  j av a2 s. co m*/
        // Use properties editor to tokenize the string
        PropertiesEditor propertiesEditor = new PropertiesEditor();
        propertiesEditor.setAsText(s);

        Properties props = (Properties) propertiesEditor.getValue();

        // Now we have properties, process each one individually
        List mappings = new ArrayList();

        for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
            String name = (String) iter.next();
            String value = props.getProperty(name);

            MethodDefinitionSourceMapping mapping = new MethodDefinitionSourceMapping();
            mapping.setMethodName(name);

            String[] tokens = StringUtils.commaDelimitedListToStringArray(value);

            for (int i = 0; i < tokens.length; i++) {
                mapping.addConfigAttribute(tokens[i].trim());
            }

            mappings.add(mapping);
        }
        source.setMappings(mappings);
    }

    setValue(source);
}

From source file:org.pentaho.platform.plugin.services.security.userrole.memory.PentahoUserMapEditor.java

public void setAsText(String s) throws IllegalArgumentException {
    PentahoUserMap userMap = new PentahoUserMap();

    if ((s == null) || "".equals(s)) {
        // Leave value in property editor null
        logger.debug("Leaving value in property editor null");
    } else {/* w  w  w  .  j a v  a  2 s  .  com*/
        // Use properties editor to tokenize the string
        PropertiesEditor propertiesEditor = new PropertiesEditor();
        propertiesEditor.setAsText(s);

        Properties props = (Properties) propertiesEditor.getValue();
        addUsersFromProperties(userMap, props);
    }

    setValue(userMap);
}

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

public void setAsText(String s) throws IllegalArgumentException {
    MethodMapTransactionAttributeSource source = new MethodMapTransactionAttributeSource();
    if (s == null || "".equals(s)) {
        // Leave value in property editor <code>null</code>
    } else {/*ww  w . j a  v a2s . co  m*/
        // Use properties editor to tokenize the hold string
        PropertiesEditor propertiesEditor = new PropertiesEditor();
        propertiesEditor.setAsText(s);
        Properties props = (Properties) propertiesEditor.getValue();

        // Now we have properties, process each one individually
        TransactionAttributeEditor tae = new TransactionAttributeEditor();
        for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
            String name = (String) iter.next();
            String value = props.getProperty(name);

            // Convert value to a transaction attribute
            tae.setAsText(value);
            TransactionAttribute attr = (TransactionAttribute) tae.getValue();

            // Register name and attribute
            source.addTransactionalMethod(name, attr);
        }
    }
    setValue(source);
}