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.jaeksoft.searchlib.renderer.plugin.AuthPluginHttpHeader.java

@Override
public User getUser(Renderer renderer, HttpServletRequest request) throws IOException {

    String remoteUser = request.getRemoteUser();
    if (remoteUser == null)
        remoteUser = request.getHeader("X-OSS-REMOTE-USER");
    if (StringUtils.isEmpty(remoteUser))
        throw new AuthException("No user");
    String[] groups = null;// www .ja  v  a2 s . co  m
    String remoteGroups = request.getHeader("X-OSS-REMOTE-GROUPS");
    if (remoteGroups != null)
        groups = StringUtils.split(remoteGroups, ',');
    User user = new User(remoteUser, remoteUser, null, groups);
    Logging.info(
            "USER authenticated: " + user.userId + " Groups count: " + (groups == null ? 0 : groups.length));
    return user;
}

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

@ResponseBody
@RequestMapping(value = "doAllocateRs", produces = MediaType.APPLICATION_JSON_VALUE)
public RetMsg doAllocateRs(String roleId, 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  ww . j av  a  2s .  c  o m
    boolean ret = resourceService.updateResourceRole(Integer.parseInt(roleId), list);
    if (ret) {
        return RetMsg.getDefault();
    }
    return RetMsg.newInstance(222, "ERROR");
}

From source file:com.erudika.para.utils.filters.FieldFilter.java

@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
        throws IOException {
    if (responseContext.getEntity() != null) {
        String[] sarr = StringUtils.split(request.getParameter("select"), ",");
        List<String> fields = sarr == null ? new ArrayList<String>(0) : Arrays.asList(sarr);
        filterObject(fields, responseContext.getEntity());
    }/*from w  w  w.  j a v a 2s  . c  o  m*/
}

From source file:edu.taru.common.utils.Reflections.java

public static void invokeSetter(Object obj, String propertyName, Class<?> parameterTypes, Object value)
        throws InstantiationException, IllegalAccessException {
    Object object = obj;// w w w  . j  av a2s  .  c  om
    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[] {});
            if (null == object) {
                object = parameterTypes.newInstance();
            }
        } else {
            String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
            invokeMethodByName(object, setterMethodName, new Object[] { value });
        }
    }
}

From source file:io.github.moosbusch.lumpi.gui.impl.Expression.java

private void parseExpression(String expr) {
    clear();//from w ww  . j a  v a 2s.  c o  m
    if (StringUtils.isNotBlank(expr)) {
        String[] exprTokens = StringUtils.split(LumpiUtil.requireNotBlank(expr), getSeparatorChar());
        for (String exprToken : exprTokens) {
            add(StringUtils.deleteWhitespace(exprToken));
        }
    }
}

From source file:com.techcavern.wavetact.ircCommands.fun.Roll.java

@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel,
        boolean isPrivate, int userPermLevel, String... args) throws Exception {
    int x = 1;/*from w  w  w. ja  va2s  . c  o m*/
    try {
        x = Integer.parseInt(args[0]);
        args = ArrayUtils.remove(args, 0);
    } catch (NumberFormatException e) {
    }
    if (x > 50) {
        IRCUtils.sendError(user, network, channel, "You may not roll the dice more than 50 times", prefix);
        return;
    } else if (x <= 0) {
        IRCUtils.sendError(user, network, channel, "I cannot roll the dice that amount of times", prefix);
        IRCUtils.sendError(user, network, channel, "I cannot roll the dice that amount of times", prefix);
        return;
    }
    String[] dice = StringUtils.split(args[0], "d");
    if (Integer.parseInt(dice[0]) > 100) {
        IRCUtils.sendError(user, network, channel, "You may not roll more than 100 dice at a time", prefix);
    } else if (Integer.parseInt(dice[1]) > 100) {
        IRCUtils.sendError(user, network, channel, "You may not roll more than 100 sided dice", prefix);
    } else if (Integer.parseInt(dice[0]) <= 0) {
        IRCUtils.sendError(user, network, channel, "I cannot find that amount of dice", prefix);
    } else if (Integer.parseInt(dice[1]) <= 0) {
        IRCUtils.sendError(user, network, channel, "I cannot find dice with that amount of sides", prefix);
    } else {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < x; i++) {
            int b = 0;
            for (int j = 0; j < Integer.parseInt(dice[0]); j++) {
                {
                    b += Registry.randNum.nextInt(Integer.parseInt(dice[1]) + 1);
                }
            }
            list.add(b);
        }
        IRCUtils.sendMessage(user, network, channel, StringUtils.join(list, ", "), prefix);
    }
}

From source file:io.wcm.caravan.io.http.impl.CaravanHttpHelper.java

/**
 * Constructs a Map from a multi-value header (i.e. one that can have multiple values that either split up into
 * multiple lines with the same name, or given as a comma-separated list of values in a single header line)
 * For example, see the following header:
 *
 * <pre>/* ww w .  ja v  a  2 s .co m*/
 * Cache-Control: public, max-age=120
 * </pre>
 *
 * That will return a map with two entries: ("public" -&gt; "true", "max-age" -&gt; "120")
 * The following header will result in the same map.
 *
 * <pre>
 * Cache-Control: public
 * Cache-Control: max-age=120
 * </pre>
 * @param header the collection of header values (one entry for each line)
 * @return Header map
 */
public static Map<String, String> convertMultiValueHeaderToMap(final Collection<String> header) {
    // we use linked hash map, because the order of entries is important
    Map<String, String> headerMap = new LinkedHashMap<>();
    for (String line : header) {
        String[] tokens = StringUtils.split(line, ',');
        for (String token : tokens) {
            String[] keyValue = StringUtils.split(token, '=');
            headerMap.put(StringUtils.trim(keyValue[0]),
                    keyValue.length == 1 ? "true" : StringUtils.trim(keyValue[1]));
        }
    }
    return headerMap;
}

From source file:com.thruzero.common.core.support.ValueTransformer.java

public String[] getStringArrayValue() {
    return value == null ? null : StringUtils.split(value.toString(), "|");
}

From source file:io.stallion.users.OAuthEndpoints.java

@GET
@Path("/auth")
@Produces("text/html")
@MinRole(Role.CONTACT)//from w w w. j  av a2s. com
public Object authScreen(@QueryParam("client_id") String clientFullId,
        @QueryParam("scopes") String scopesString) {
    String[] scopes = StringUtils.split(scopesString, ",");
    String description = "";
    Map<String, String> descriptionMap = Settings.instance().getoAuth().getScopeDescriptions();
    for (int x = 0; x < scopes.length; x++) {
        String scope = scopes[x];
        String s = or(descriptionMap.getOrDefault(scope, scope), scope);
        if (scopes.length == 1) {
            description = s;
        } else if (scopes.length == 2) {
            if (x == 0) {
                description += s;
            } else {
                description += " and " + s;
            }
        } else if (x + 1 == scopes.length) {
            description += " and " + s;
        } else {
            description += "," + s;
        }
    }
    Map<String, Object> ctx = map(val("clientId", clientFullId));
    ctx.put("client", OAuthClientController.instance().clientForFullId(clientFullId));
    ctx.put("scopesDescription", description);
    ctx.put("scopes", set(scopes));
    String html = TemplateRenderer.instance().renderTemplate("stallion:public/oauth.jinja");
    return html;
}

From source file:com.pamarin.game24.Equations.java

private String toEquation(String number, String operator, String bracket) {
    String[] numbers = StringUtils.split(number, ":");
    String[] opers = StringUtils.split(operator, ":");

    return bracket.replace("A", numbers[0]).replace("B", numbers[1]).replace("C", numbers[2])
            .replace("D", numbers[3]).replace("x", opers[0]).replace("y", opers[1]).replace("z", opers[2]);
}