Example usage for org.springframework.util StringUtils split

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

Introduction

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

Prototype

@Nullable
public static String[] split(@Nullable String toSplit, @Nullable String delimiter) 

Source Link

Document

Split a String at the first occurrence of the delimiter.

Usage

From source file:com.opensearchserver.hadse.Hadse.java

public static void main(String[] args) {
    if (args != null)
        for (String arg : args) {
            String s[] = StringUtils.split(arg, "=");
            if (s.length < 2)
                continue;
            if ("--server.port".equals(s[0]))
                port = Integer.parseInt(s[1]);
        }//from w  ww. ja va  2 s.  com
    SpringApplication app = new SpringApplication(Hadse.class);
    app.setShowBanner(false);
    app.run(args);
}

From source file:com.lpm.fanger.commons.util.Reflections.java

/**
 * Getter./*from w ww  .j av a 2  s  .c  om*/
 * ???.??.
 */
public static Object invokeGetter(Object obj, String propertyName) {
    Object object = obj;
    for (String name : StringUtils.split(propertyName, ".")) {
        String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
        object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
    }
    return object;
}

From source file:org.focusns.common.web.WebUtils.java

public static Map<String, String> getMatrixParameters(HttpServletRequest request) {
    ///* w ww.  j  a  v a 2  s.  c  o  m*/
    Map<String, String> parameterMap = new LinkedHashMap<String, String>();
    //
    String requestUri = request.getRequestURI();
    if (requestUri.contains(";")) {
        String paramsString = requestUri.substring(requestUri.indexOf(";") + 1);
        String[] paramsPair = new String[] { paramsString };
        if (paramsString.contains(",")) {
            paramsPair = StringUtils.tokenizeToStringArray(paramsString, ",");
        }
        for (String paramPair : paramsPair) {
            String[] nameAndValue = StringUtils.split(paramPair, "=");
            parameterMap.put(nameAndValue[0], nameAndValue[1]);
        }
    }
    return parameterMap;
}

From source file:com.lpm.fanger.commons.util.Reflections.java

/**
 * Setter, ???/*from w w  w  . ja v a 2s .c  o m*/
 * ???.??.
 */
public static void invokeSetter(Object obj, String propertyName, Object value) {
    Object object = obj;
    String[] names = StringUtils.split(propertyName, ".");
    if (names == null || names.length == 0)
        return;
    for (int i = 0; i < names.length; i++) {
        if (i < names.length - 1) {
            String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
            object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
        } else {
            String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
            invokeMethodByName(object, setterMethodName, new Object[] { value });
        }
    }
}

From source file:com.maiseries.core.bank.web.common.util.Reflections.java

/**
 * Setter, ??? ???.??.//  w ww. jav a2  s.  com
 */
public static void invokeSetter(Object obj, String propertyName, Object value) {
    Object object = obj;
    String[] names = StringUtils.split(propertyName, ".");
    for (int i = 0; i < names.length; i++) {
        if (i < names.length - 1) {
            String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
            object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
        } else {
            String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
            invokeMethodByName(object, setterMethodName, new Object[] { value });
        }
    }
}

From source file:com.codeabovelab.dm.cluman.cluster.docker.model.Bind.java

/**
 * Parse value-path pairs give from {@link ContainerSource#getVolumeBinds()}.
 * @param volumeStr name or path to volume
 * @param pathStr path, with optionally AccessMode
 * @return/*from   w  w  w  .  ja  v  a  2 s . co  m*/
 */
public static Bind parse(String volumeStr, String pathStr) {
    Volume volume = new Volume(volumeStr);
    String[] parts = StringUtils.split(pathStr, ":");
    if (parts == null) {
        return new Bind(pathStr, volume);
    }
    AccessMode accessMode = AccessMode.valueOf(parts[1].toLowerCase());
    return new Bind(parts[0], volume, accessMode);
}

From source file:com.codeabovelab.dm.cluman.cluster.registry.DockerRegistryAuthAdapter.java

@Override
public void handle(AuthContext ctx) {
    String tokenReq = ctx.getAuthenticate();
    String[] split = StringUtils.split(tokenReq, " ");
    Assert.isTrue(split.length == 2, "invalid token request " + tokenReq);
    String type = split[0];//  ww w.j a va  2 s .c om
    switch (type) {
    case "Bearer":
        Map<String, String> map = Splitter.on(",").withKeyValueSeparator("=").split(split[1].replace("\"", ""));
        AuthInfo authInfo = AuthInfo.builder().realm(map.get("realm")).service(map.get("service"))
                .scope(map.get("scope")).build();
        String token = getToken(authInfo);
        ctx.getRequestHeaders().add(AUTHORIZATION, "Bearer " + token);
        break;
    case "Basic":
        ctx.getRequestHeaders().add(AUTHORIZATION, createBasicHeader(provider.getRegistryCredentials()));
        break;
    default:
        throw new IllegalArgumentException("Invalid token string " + tokenReq);
    }
}

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

@Override
public GrantedAuthority[] getAuthoritiesForUser(String email) throws IllegalArgumentException {
    String[] emailParts = StringUtils.split(email, "@");
    if (emailParts == null)
        throw new IllegalArgumentException("unparsable email");
    String domain = emailParts[1];
    return domainMap.get(domain);
}

From source file:org.shept.persistence.provider.hibernate.HibernateCriteriaFilter.java

/**
 * @return a default criteria definition by simply return an empty entity object
 * @see http://stackoverflow.com/questions/1926618/hibernate-sort-by-properties-of-inner-bean
 * /*from  ww w  .java2s . c o  m*/
 */
public DetachedCriteria getCriteria(SortDefinition sortDefinition) {
    SortDefinition sd = defaultSortDefinition;
    DetachedCriteria crit = DetachedCriteria.forClass(getEntityClass());
    // set sort criteria from FormFilter
    if (null != sortDefinition && StringUtils.hasText(sortDefinition.getProperty())) {
        sd = sortDefinition;
    }
    if (null != sd && StringUtils.hasText(sd.getProperty())) {
        String prop = sd.getProperty();
        String[] pathArr = StringUtils.split(prop, ".");
        if (pathArr == null) {
            pathArr = new String[] { prop };
        }
        if (pathArr.length > 2) {
            throw new UnsupportedOperationException(
                    "Sort Criteria Definition '" + prop + "' may only nest one level deep");
        }
        if (pathArr.length == 2) {
            crit.createAlias(pathArr[0], pathArr[0]);
        }
        if (sortDefinition.isAscending())
            crit.addOrder(Order.asc(prop));
        else
            crit.addOrder(Order.desc(prop));
    }
    return crit;
}

From source file:com.nebhale.buildmonitor.web.AbstractControllerTest.java

final String toJson(String... pairs) {
    StringBuilder sb = new StringBuilder("{ ");

    Set<String> entries = Arrays.stream(pairs).map(pair -> {
        String[] parts = StringUtils.split(pair, ":");
        return String.format("\"%s\" : \"%s\"", parts[0], parts[1]);
    }).collect(Collectors.toSet());

    sb.append(StringUtils.collectionToDelimitedString(entries, ", "));

    return sb.append(" }").toString();
}