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

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

Introduction

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

Prototype

public static String[] stripAll(final String[] strs, final String stripChars) 

Source Link

Document

Strips any of a set of characters from the start and end of every String in an array.

Whitespace is defined by Character#isWhitespace(char) .

A new array is returned each time, except for length zero.

Usage

From source file:org.dbgl.model.Mount.java

public Mount(final String mount) throws InvalidMountstringException {
    init();/*from   w w w .  j av a  2 s . c o  m*/
    Matcher mountMatcher = MOUNT_PATRN.matcher(mount);
    Matcher imgmountMatcher = IMGMOUNT_PATRN.matcher(mount);

    if (mountMatcher.matches()) {
        if (mountMatcher.group(1) != null) {
            unmounted = true;
            driveletter = Character.toUpperCase(mountMatcher.group(1).charAt(0));
            return;
        }
        driveletter = Character.toUpperCase(mountMatcher.group(2).charAt(0));
        String mountLocation = StringUtils.strip(PlatformUtils.toNativePath(mountMatcher.group(3)), "\"");
        if (FileUtils.isPhysFS(mountLocation))
            initForPhysFS(mountLocation);
        else
            path = new File[] { FileUtils.makeRelativeToDosroot(FileUtils.canonicalToDosroot(mountLocation)) };
        mountAs = StringUtils.defaultString(mountMatcher.group(4));
        label = StringUtils.defaultString(mountMatcher.group(5));
        lowlevelCD = StringUtils.defaultString(mountMatcher.group(6));
        freesize = StringUtils.defaultString(mountMatcher.group(7));
        useCD = StringUtils.defaultString(mountMatcher.group(8));
    } else if (imgmountMatcher.matches()) {
        mountingType = MountingType.IMAGE;
        driveletter = Character.toUpperCase(imgmountMatcher.group(1).charAt(0));
        String[] paths = StringUtils.stripAll(PlatformUtils.toNativePath(imgmountMatcher.group(2)).trim()
                .split("\\s(?=([^\"]*\"[^\"]*\")*[^\"]*$)"), "\"");
        path = new File[paths.length];
        for (int i = 0; i < paths.length; i++)
            path[i] = FileUtils.makeRelativeToDosroot(FileUtils.canonicalToDosroot(paths[i]));
        mountAs = StringUtils.defaultString(imgmountMatcher.group(3));
        if (mountAs.equalsIgnoreCase("cdrom"))
            mountAs = "iso";
        fs = StringUtils.defaultString(imgmountMatcher.group(4));
        size = StringUtils.defaultString(imgmountMatcher.group(5));
    } else {
        throw new InvalidMountstringException();
    }
}

From source file:org.structr.web.auth.GitHubAuthClient.java

@Override
public String getCredential(final HttpServletRequest request) {

    OAuthResourceResponse userResponse = getUserResponse(request);

    if (userResponse == null) {

        return null;

    }/*from w ww  . j  av  a2 s  . c  om*/

    String body = userResponse.getBody();
    logger.log(Level.FINE, "User response body: {0}", body);

    String[] addresses = StringUtils.stripAll(
            StringUtils.stripAll(StringUtils.stripEnd(StringUtils.stripStart(body, "["), "]").split(",")),
            "\"");

    return addresses.length > 0 ? addresses[0] : null;

}