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

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

Introduction

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

Prototype

public static String[] split(final String str, final String separatorChars) 

Source Link

Document

Splits the provided text into an array, separators specified.

Usage

From source file:com.refreshsf.contrib.client.types.opts.HtmlOptions.java

public List<String> customAttrSurround() {
    return Arrays.asList(StringUtils.split(get("customAttrSurround", ""), ","));
}

From source file:de.micromata.genome.gwiki.web.tags.GWikiAuthTag.java

private String[] splitRights(String rightsString) {
    return StringUtils.split(rightsString, RIGHTS_SEPARATOR);
}

From source file:ch.cyberduck.core.s3.RequestEntityRestStorageService.java

public RequestEntityRestStorageService(final S3Session session, final Jets3tProperties properties,
        final HttpClientBuilder configuration) {
    super(session.getHost().getCredentials().isAnonymousLogin() ? null : new AWSCredentials(null, null) {
        @Override/*from  ww w  .j  a va 2s. co  m*/
        public String getAccessKey() {
            return session.getHost().getCredentials().getUsername();
        }

        @Override
        public String getSecretKey() {
            return session.getHost().getCredentials().getPassword();
        }
    }, new PreferencesUseragentProvider().get(), null, properties);
    this.session = session;
    configuration.disableContentCompression();
    configuration.setRetryHandler(
            new S3HttpRequestRetryHandler(this, preferences.getInteger("http.connections.retry")));
    configuration.setRedirectStrategy(new DefaultRedirectStrategy() {
        @Override
        public HttpUriRequest getRedirect(final HttpRequest request, final HttpResponse response,
                final HttpContext context) throws ProtocolException {
            if (response.containsHeader("x-amz-bucket-region")) {
                final String host = ((HttpUriRequest) request).getURI().getHost();
                if (!StringUtils.equals(session.getHost().getHostname(), host)) {
                    regionEndpointCache.putRegionForBucketName(
                            StringUtils
                                    .split(StringUtils.removeEnd(((HttpUriRequest) request).getURI().getHost(),
                                            session.getHost().getHostname()), ".")[0],
                            response.getFirstHeader("x-amz-bucket-region").getValue());
                }
            }
            return super.getRedirect(request, response, context);
        }
    });
    this.setHttpClient(configuration.build());
}

From source file:info.magnolia.ui.actionbar.definition.ActionbarSectionDefinitionKeyGenerator.java

/**
 * Will generate keys for the message bundle in the following form <code> &lt;app-name&gt;.&lt;sub-app-name&gt;.actionbar.sections.&lt;section-name&gt;[.name of getter or field annotated with {@link info.magnolia.i18nsystem.I18nText}]</code>.
 *//*from w ww  .ja  va2  s .c o m*/
@Override
protected void keysFor(List<String> keys, ActionbarSectionDefinition sectionDefinition, AnnotatedElement el) {
    Object root = getRoot(sectionDefinition);
    final String fieldOrGetterName = fieldOrGetterName(el);

    if (root instanceof AppDescriptor) {
        // Action bar within an app
        AppDescriptor appDescriptor = (AppDescriptor) root;
        SubAppDescriptor subAppDescriptor = null;
        List<?> ancestors = getAncestors(sectionDefinition);
        for (Object ancestor : ancestors) {
            if (ancestor instanceof SubAppDescriptor) {
                subAppDescriptor = (SubAppDescriptor) ancestor;
                break;
            }
        }
        final String appName = appDescriptor.getName();
        final String sectionName = sectionDefinition.getName();
        final String subappName = subAppDescriptor != null ? subAppDescriptor.getName() : "";
        addKey(keys, appName, subappName, "actionbar", "sections", sectionName, fieldOrGetterName);
        addKey(keys, appName, subappName, "actionbar", sectionName, fieldOrGetterName);
        addKey(keys, appName, "actionbar", "sections", sectionName, fieldOrGetterName);
        addKey(keys, appName, "actionbar", sectionName, fieldOrGetterName);

    } else {
        // Action bar within e.g. a MessageView in the pulse
        String idOrName = getIdOrNameForUnknownRoot(sectionDefinition);
        addKey(keys, idOrName, "actionbar", "sections", sectionDefinition.getName(), fieldOrGetterName);
        addKey(keys, idOrName, "actionbar", sectionDefinition.getName(), fieldOrGetterName);
        String[] parts = StringUtils.split(idOrName, ".");
        if (parts.length > 1) {
            String noModuleName = parts[parts.length - 1];
            addKey(keys, noModuleName, "actionbar", "sections", sectionDefinition.getName(), fieldOrGetterName);
            addKey(keys, noModuleName, "actionbar", sectionDefinition.getName(), fieldOrGetterName);
        }
    }
}

From source file:com.tuplejump.stargate.util.CQLUnitD.java

public static Map<String, Integer> getHostsAndPorts(String nodes) {
    String[] hostsAndPortsArr = StringUtils.split(nodes, ',');
    Map<String, Integer> hostsAndPorts = new HashMap<String, Integer>();
    for (String hostAndPortStr : hostsAndPortsArr) {
        String[] hostAndPort = StringUtils.split(hostAndPortStr, ':');
        hostsAndPorts.put(hostAndPort[0], Integer.parseInt(hostAndPort[1]));
    }//  w w w . j a  v  a  2  s.  c o  m
    return hostsAndPorts;
}

From source file:catchla.yep.util.YepArrayUtils.java

@NonNull
public static long[] parseLongArray(final String string, final char token) {
    if (TextUtils.isEmpty(string))
        return new long[0];
    final String[] itemsStringArray = StringUtils.split(string, token);
    final long[] array = new long[itemsStringArray.length];
    for (int i = 0, j = itemsStringArray.length; i < j; i++) {
        try {//from w w w  .j a va2  s .c o  m
            array[i] = Long.parseLong(itemsStringArray[i]);
        } catch (final NumberFormatException e) {
            return new long[0];
        }
    }
    return array;
}

From source file:com.gargoylesoftware.htmlunit.javascript.host.dom.DOMTokenList.java

/**
 * {@inheritDoc}//from  w  w  w .ja v  a2  s .  c  o  m
 */
@Override
public String getDefaultValue(final Class<?> hint) {
    if (getPrototype() == null) {
        return (String) super.getDefaultValue(hint);
    }
    final DomAttr attr = (DomAttr) getDomNodeOrDie().getAttributes().getNamedItem(attributeName_);
    if (attr != null) {
        String value = attr.getValue();
        if (getBrowserVersion().hasFeature(JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_EDIT)) {
            value = StringUtils.join(StringUtils.split(value, whitespaceChars()), ' ');
        }
        return value;
    }
    return "";
}

From source file:com.refreshsf.contrib.client.types.opts.HtmlOptions.java

public List<String> customAttrCollapse() {
    return Arrays.asList(StringUtils.split(get("customAttrCollapse", ""), ","));
}

From source file:com.joey.Fujikom.modules.sys.security.SystemAuthorizingRealm.java

/**
 * ?, ???//  w  w w  .  j  a  v  a2  s.  c  om
 */
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
    Principal principal = (Principal) getAvailablePrincipal(principals);
    User user = getSystemService().getUserByLoginName(principal.getLoginName());
    if (user != null) {
        UserUtils.putCache("user", user);
        SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
        List<Menu> list = UserUtils.getMenuList();
        for (Menu menu : list) {
            if (StringUtils.isNotBlank(menu.getPermission())) {
                // Permission???
                for (String permission : StringUtils.split(menu.getPermission(), ",")) {
                    info.addStringPermission(permission);
                }
            }
        }
        // IP
        getSystemService().updateUserLoginInfo(user.getId());
        return info;
    } else {
        return null;
    }
}

From source file:de.jcup.egradle.core.util.LinkToTypeConverter.java

private LinkData handleMethodOrProperty(String typeName, LinkData data) {
    String[] splitted = StringUtils.split(typeName, "#");
    if (splitted == null || splitted.length == 0) {
        /* should never happen, but... */
        data.mainName = typeName;/*from  w  ww  .  j  av a2 s .c o  m*/
        return data;
    }
    String methodOrPropertyPart = null;
    if (splitted.length == 1) {
        data.mainName = null;
        methodOrPropertyPart = splitted[0];
    } else {
        data.mainName = splitted[0];
        methodOrPropertyPart = splitted[1];
    }

    if (methodOrPropertyPart == null) {
        return data;
    }
    if (methodOrPropertyPart.indexOf("(") == -1) {
        data.subName = methodOrPropertyPart; // property...
        return data;
    }
    return handleMethod(data, methodOrPropertyPart);
}