Example usage for org.apache.commons.lang3 StringUtils splitByWholeSeparatorPreserveAllTokens

List of usage examples for org.apache.commons.lang3 StringUtils splitByWholeSeparatorPreserveAllTokens

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils splitByWholeSeparatorPreserveAllTokens.

Prototype

public static String[] splitByWholeSeparatorPreserveAllTokens(final String str, final String separator,
        final int max) 

Source Link

Document

Splits the provided text into an array, separator string specified.

Usage

From source file:com.ibasco.agql.core.client.AbstractRestClient.java

/**
 * <p>A Simply utility method for parsing Content-Type which contains parameters</p>
 *
 * @param contentType A {@link String} containing the Content-Type
 *
 * @return The parsed content-type {@link String} excluding the parameters
 *//*from   w w w .  j a  v a2 s  . co m*/
private String parseContentType(String contentType) {
    if (!StringUtils.isEmpty(contentType) && contentType.contains(";")) {
        String[] types = StringUtils.splitByWholeSeparatorPreserveAllTokens(contentType, ";", 2);
        if (types != null && types.length > 1)
            return types[0].trim();
    }
    return contentType;
}

From source file:org.spicyurl.UrlParser.java

protected void parse() {
    String[] stage0 = StringUtils.splitByWholeSeparatorPreserveAllTokens(url.getRaw(), SCHEME_SEP, 2);

    url.setScheme(stage0[0]);//from  w  w w.j  av a 2  s .  co  m
    if (stage0.length != 2) {
        url.getValidationErrorsModifiable().add(UrlErrors.HOST_IS_MISSING);
        return;
    }

    // Check for first separator, to split host from path/query/fragment
    int hostSeperatorIdx = StringUtils.indexOfAny(stage0[1], PATH_SEP, QUERY_SEP, FRAGMENT_SEP);
    if (hostSeperatorIdx == -1) {
        // Just host
        parseLoginHostPort(stage0[1]);
    } else {
        parseLoginHostPort(StringUtils.substring(stage0[1], 0, hostSeperatorIdx));
        parsePathQueryFregment(StringUtils.substring(stage0[1], hostSeperatorIdx));
    }

}