Example usage for org.springframework.util StringUtils commaDelimitedListToStringArray

List of usage examples for org.springframework.util StringUtils commaDelimitedListToStringArray

Introduction

In this page you can find the example usage for org.springframework.util StringUtils commaDelimitedListToStringArray.

Prototype

public static String[] commaDelimitedListToStringArray(@Nullable String str) 

Source Link

Document

Convert a comma delimited list (e.g., a row from a CSV file) into an array of strings.

Usage

From source file:com.gopivotal.cla.EnvironmentVariableConfiguration.java

@Bean
String[] adminEmailDomains() {
    return StringUtils.commaDelimitedListToStringArray(getRequiredProperty("ADMIN_EMAIL_DOMAINS"));
}

From source file:spring.osgi.utils.OsgiHeaderUtils.java

private static String[] getHeaderAsTrimmedStringArray(Bundle bundle, String header) {
    if (bundle == null || !StringUtils.hasText(header))
        return new String[0];

    String headerContent = bundle.getHeaders().get(header);
    String[] entries = StringUtils.commaDelimitedListToStringArray(headerContent);
    for (int i = 0; i < entries.length; i++) {
        entries[i] = entries[i].trim();/*from w w  w  .j a  va2  s  .co  m*/
    }

    return entries;
}

From source file:io.cloudslang.lang.cli.converters.ListConverter.java

@Override
public List<String> convertFromText(String value, Class<?> targetType, String optionContext) {
    String[] values = StringUtils.commaDelimitedListToStringArray(value);
    List<String> list = new ArrayList<>();
    for (String v : values) {
        list.add(v);//  w w w . j a  v  a  2s  .  c  o  m
    }
    return list;
}

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

public static UserMap addUsersFromProperties(UserMap userMap, Properties props) {
    for (Object o : props.keySet()) {
        String username = (String) o;
        String value = props.getProperty(username);

        // now retrieve the rest of the user details including the 
        // details and the authorities
        String[] tokens = StringUtils.commaDelimitedListToStringArray(value);
        String password = tokens[0];

        // the rest need to be granted authorities
        ArrayList<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        for (int index = 1; index < tokens.length; index++) {
            authorities.add(new ArchetypeAwareGrantedAuthority(tokens[index]));
        }/* w ww .j  a  va 2 s  .  c  o m*/

        userMap.addUser(new User(username, password, true));
    }

    return userMap;
}

From source file:io.cloudslang.lang.cli.converters.MapConverter.java

@Override
public Map<String, String> convertFromText(String value, Class<?> targetType, String optionContext) {
    value = value.replace("\\,", ESCAPE_EXPRESSION);
    String[] values = StringUtils.commaDelimitedListToStringArray(value);
    Map<String, String> map = new HashMap<>();

    for (String v : values) {
        String[] keyValue = StringUtils.delimitedListToStringArray(v, "=");
        if (keyValue.length == 2) {
            keyValue[1] = keyValue[1].replace(ESCAPE_EXPRESSION, ",");
            map.put(keyValue[0], keyValue[1]);
        } else {/*from ww w . j av  a  2  s.  com*/
            throw new RuntimeException(
                    "Input should be in a key=value comma separated format, e.g. key1=val1,key2=val2 etc.");
        }
    }

    return map;
}

From source file:org.cloudfoundry.identity.uaa.password.PasswordCheckEndpoint.java

@RequestMapping(value = "/password/score", method = RequestMethod.POST)
@ResponseBody//from w w w.ja v  a  2  s  .c  om
public PasswordScore passwordScore(@RequestParam String password,
        @RequestParam(defaultValue = "") String userData) {
    return scoreCalculator.computeScore(password, StringUtils.commaDelimitedListToStringArray(userData));
}

From source file:pt.webdetails.browserid.spring.authorities.DomainWhitelistAuthoritiesService.java

/**
 * /*from   ww  w  .ja v a 2  s. c  o m*/
 * @param properties entries in the form &lt;domain&gt;=&lt;roleName&gt;[,&ltroleName&gt;]*&nbsp;
 */
public void setDomainMap(Properties properties) {
    Map<String, GrantedAuthority[]> domainMap = new HashMap<String, GrantedAuthority[]>(properties.size());
    for (Entry<Object, Object> entry : properties.entrySet()) {

        String domain = (String) entry.getKey();
        String authoritiesAsText = (String) entry.getValue();

        //parse authorities, may return empty
        String[] roles = StringUtils.commaDelimitedListToStringArray(authoritiesAsText);
        GrantedAuthority[] authorities = new GrantedAuthority[roles.length];
        int i = 0;
        for (String role : roles) {
            authorities[i++] = new GrantedAuthorityImpl(role);
        }

        domainMap.put(domain, authorities);

    }
    this.domainMap = domainMap;
}

From source file:org.jasypt.spring31.xml.encryption.AbstractEncryptablePropertyLoadingBeanDefinitionParser.java

@Override
protected void doParse(final Element element, final BeanDefinitionBuilder builder) {

    String location = element.getAttribute("location");
    if (StringUtils.hasLength(location)) {
        String[] locations = StringUtils.commaDelimitedListToStringArray(location);
        builder.addPropertyValue("locations", locations);
    }//from   ww  w  .j  a  v a2 s.c o m

    String propertiesRef = element.getAttribute("properties-ref");
    if (StringUtils.hasLength(propertiesRef)) {
        builder.addPropertyReference("properties", propertiesRef);
    }

    String fileEncoding = element.getAttribute("file-encoding");
    if (StringUtils.hasLength(fileEncoding)) {
        builder.addPropertyReference("fileEncoding", fileEncoding);
    }

    String order = element.getAttribute("order");
    if (StringUtils.hasLength(order)) {
        builder.addPropertyValue("order", Integer.valueOf(order));
    }

    builder.addPropertyValue("ignoreResourceNotFound",
            Boolean.valueOf(element.getAttribute("ignore-resource-not-found")));

    builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override")));

    builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
}

From source file:org.cloudfoundry.identity.uaa.config.EnvironmentPropertiesFactoryBeanTests.java

private Properties getProperties(String input) {
    Properties properties = StringUtils
            .splitArrayElementsIntoProperties(StringUtils.commaDelimitedListToStringArray(input), "=");
    return properties;
}

From source file:com.acm.cloud.config.server.DBEnvironmentRepository.java

@Override
public Environment findOne(String config, String profile, String label) {
    Environment env = new Environment(config, StringUtils.commaDelimitedListToStringArray(profile), label);
    List<Config> configList = configService.searchList(config, profile, label);
    return processConfig(env, configList);
}