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.ethlo.geodata.util.ResourceUtil.java

public Map.Entry<Date, File> fetchResource(DataType dataType, String urlStr) throws IOException {
    final String[] urlParts = StringUtils.split(urlStr, "|");
    if (urlParts[0].endsWith(".zip")) {
        return fetchZip(dataType, urlParts[0], urlParts[1]);
    } else {//  ww  w . j a va2  s.c o  m
        return fetch(dataType, urlStr);
    }
}

From source file:com.eryansky.common.orm.core.PageRequest.java

/**
 * ???./*from w w w .  j a v  a2s  . com*/
 *
 * @param orderDir ?descasc,?','.
 */
public void setOrderDir(final String orderDir) {
    String lowcaseOrderDir = StringUtils.lowerCase(orderDir);

    //order?
    String[] orderDirs = StringUtils.split(lowcaseOrderDir, ',');

    if (ArrayUtils.isEmpty(orderDirs)) {
        return;
    }

    for (String orderDirStr : orderDirs) {
        if (!StringUtils.equals(Sort.DESC, orderDirStr) && !StringUtils.equals(Sort.ASC, orderDirStr)) {
            throw new IllegalArgumentException("??" + orderDirStr + "??");
        }
    }

    this.orderDir = lowcaseOrderDir;
}

From source file:net.ontopia.topicmaps.query.impl.basic.JavaModule.java

protected Map parseParameters(String parameters) {
    Map result = new HashMap();
    if (parameters != null) {
        String[] tokens = StringUtils.split(parameters, "&");
        for (int i = 0; i < tokens.length; i++) {
            String[] vals = StringUtils.split(tokens[i], "=");
            result.put(vals[0], vals[1]);
        }//from w ww  . j  a  v  a 2 s  . com
    }
    return result;
}

From source file:com.nesscomputing.quartz.NessQuartzModule.java

private void configureJobs(final Configuration jobConfig) {
    for (Iterator<?> it = jobConfig.getKeys(); it.hasNext();) {
        final String key = it.next().toString();
        final String[] keys = StringUtils.split(key, ".");
        if (keys.length != 2) {
            LOG.warn("Ignore invalid key %s", key);
            continue;
        }/*  w w  w  .ja  va  2s  . c  o m*/
        if ("class".equals(keys[1])) {
            configureJob(keys[0], jobConfig.subset(keys[0]));
        }
    }
}

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

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

From source file:com.mobogenie.pay.auth.controller.RoleController.java

@ResponseBody
@RequestMapping(value = "doAllocateRole", produces = MediaType.APPLICATION_JSON_VALUE)
public RetMsg doAllocateRole(Integer userid, String ids) {
    String[] idArray = StringUtils.split(ids, ",");
    List<Integer> list = Lists.newArrayList();
    for (int i = 0; i < idArray.length; i++) {
        list.add(Integer.parseInt(idArray[i]));
    }//from  w  w w.j ava 2  s.c  o  m
    boolean ret = roleService.addRoleUser(userid, list);
    if (ret) {
        return RetMsg.getDefault();
    }
    return RetMsg.newInstance(222, "ERROR");
}

From source file:com.creditcloud.ump.model.ump.utils.MessageUtils.java

public static List<UmpAgreementResult> parseAgreementList(String agreementList) {
    if (StringUtils.isEmpty(agreementList)) {
        return Collections.EMPTY_LIST;
    }// w w w  .  j  a v a 2  s.  co m

    String[] agreementStrList = StringUtils.split(agreementList, '|');
    List<UmpAgreementResult> results = new ArrayList<>(agreementStrList.length);
    for (String agreement : agreementStrList) {
        String[] args = StringUtils.split(agreement, ',');
        if (args.length < 2) {
            String errMsg = String.format("wrong format in ump agreement list:%s, ignore", agreement);
            logger.log(Level.SEVERE, errMsg);
            continue;
        }
        UmpAgreementType type = UmpAgreementType.valueOf(args[0]);
        String code = args[1];
        String msg = null;
        if (args.length > 2) {
            msg = args[2];
        }
        results.add(new UmpAgreementResult(type, code, msg));
    }

    return results;
}

From source file:czlab.xlib.CU.java

public static String[] splitNull(String s) {
    return StringUtils.split(nsb(s), "\u0000");
}

From source file:common.util.PropertyFilter.java

/**
 * @param filterName/*from  w  w  w . j av a 2s . c  o m*/
 * @param value
 */
public PropertyFilter(final String filterName, final String value) {

    String matchTypeStr;
    String matchPattenCode = LikeMatchPatten.ALL.toString();
    String matchTypeCode;
    String propertyTypeCode;

    if (filterName.contains("LIKE") && filterName.charAt(0) != 'L') {
        matchTypeStr = StringUtils.substringBefore(filterName, PARAM_PREFIX);
        matchPattenCode = StringUtils.substring(matchTypeStr, 0, 1);
        matchTypeCode = StringUtils.substring(matchTypeStr, 1, matchTypeStr.length() - 1);
        propertyTypeCode = StringUtils.substring(matchTypeStr, matchTypeStr.length() - 1,
                matchTypeStr.length());
    } else {
        matchTypeStr = StringUtils.substringBefore(filterName, PARAM_PREFIX);
        matchTypeCode = StringUtils.substring(matchTypeStr, 0, matchTypeStr.length() - 1);
        propertyTypeCode = StringUtils.substring(matchTypeStr, matchTypeStr.length() - 1,
                matchTypeStr.length());
    }

    try {
        matchType = Enum.valueOf(MatchType.class, matchTypeCode);
        likeMatchPatten = Enum.valueOf(LikeMatchPatten.class, matchPattenCode);
    } catch (RuntimeException e) {
        throw new IllegalArgumentException("filter name: " + filterName
                + "Not prepared in accordance with rules, not get more types of property.", e);
    }

    try {
        propertyType = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue();
    } catch (RuntimeException e) {
        throw new IllegalArgumentException("filter name: " + filterName
                + "Not prepared in accordance with the rules, attribute value types can not be.", e);
    }

    String propertyNameStr = StringUtils.substringAfter(filterName, PARAM_PREFIX);
    propertyNames = StringUtils.split(propertyNameStr, PropertyFilter.OR_SEPARATOR);

    Validate.isTrue(propertyNames.length > 0, "filter name: " + filterName
            + "Not prepared in accordance with the rules, property names can not be.");

    this.propertyValue = ConvertUtils.convert(value, propertyType);
}

From source file:com.link_intersystems.lang.reflect.Package2.java

/**
 * Returns the name of only this package, not the full package name.
 *
 * @return the name of only this package, not the full package name.
 * @since 1.2.0.0/*from   www  .j av  a  2s.co  m*/
 */
public String getSimpleName() {
    String packageName = getName();
    String[] packageFragmentNames = StringUtils.split(packageName, '.');
    String simpleName = null;
    simpleName = ((String[]) ArrayUtils.subarray(packageFragmentNames, packageFragmentNames.length - 1,
            packageFragmentNames.length))[0];
    return simpleName;
}