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

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

Introduction

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

Prototype

public static String join(final Iterable<?> iterable, final String separator) 

Source Link

Document

Joins the elements of the provided Iterable into a single String containing the provided elements.

No delimiter is added before or after the list.

Usage

From source file:com.synopsys.integration.log.BufferedIntLogger.java

public String getOutputString(final LogLevel level) {
    return StringUtils.trimToNull(StringUtils.join(getOutputList(level), '\n'));
}

From source file:com.techcavern.wavetact.eventListeners.PrivMsgListener.java

@Override
public void onPrivateMessage(PrivateMessageEvent event) throws Exception {
    class process implements Runnable {
        public void run() {
            String[] message = StringUtils.split(Colors.removeFormatting(event.getMessage()), " ");
            String commandchar = IRCUtils.getCommandChar(event.getBot(), null);
            String privcommand = message[0].toLowerCase();
            IRCUtils.sendLogChanMsg(event.getBot(),
                    "[PM] " + IRCUtils.noPing(event.getUser().getNick()) + "!" + event.getUser().getLogin()
                            + "@" + event.getUser().getHostname() + ": " + event.getMessage());
            if (commandchar != null)
                privcommand = StringUtils.replaceOnce(privcommand, commandchar, "");
            IRCCommand Command = IRCUtils.getCommand(privcommand,
                    IRCUtils.getNetworkNameByNetwork(event.getBot()), null);
            message = ArrayUtils.remove(message, 0);
            if (Command != null) {
                String logmsg = StringUtils.join(message, " ");
                if (Command.getChannelRequired()) {
                    Channel channel = null;
                    String prefix = null;
                    if (message.length > 0) {
                        prefix = IRCUtils.getPrefix(event.getBot(), message[0]);
                        if (!prefix.isEmpty())
                            channel = IRCUtils.getChannelbyName(event.getBot(), message[0].replace(prefix, ""));
                        else
                            channel = IRCUtils.getChannelbyName(event.getBot(), message[0]);
                        message = ArrayUtils.remove(message, 0);
                    }//from   w ww .  ja va 2  s.c  om
                    if (channel != null) {
                        int userPermLevel = PermUtils.getPermLevel(event.getBot(), event.getUser().getNick(),
                                channel);
                        if (userPermLevel >= Command.getPermLevel()) {
                            try {
                                Command.onCommand(privcommand, event.getUser(), event.getBot(), prefix, channel,
                                        true, userPermLevel, message);
                            } catch (Exception e) {
                                IRCUtils.sendError(event.getUser(), event.getBot(), null,
                                        "Failed to execute command, please make sure you are using the correct syntax ("
                                                + Command.getSyntax() + ")",
                                        "");
                                e.printStackTrace();
                            }
                        } else {
                            IRCUtils.sendError(event.getUser(), event.getBot(), null, "Permission denied", "");
                        }
                    } else {
                        IRCUtils.sendError(event.getUser(), event.getBot(), null,
                                "Please specify channel as argument #1 in front of all the other arguments",
                                "");
                    }
                } else {
                    int userPermLevel = PermUtils.getPermLevel(event.getBot(), event.getUser().getNick(), null);
                    if (Command.getPermLevel() == 0) {
                        try {
                            Command.onCommand(privcommand, event.getUser(), event.getBot(), null, null, true,
                                    userPermLevel, message);
                        } catch (Exception e) {
                            IRCUtils.sendError(event.getUser(), event.getBot(), null,
                                    "Failed to execute command, please make sure you are using the correct syntax ("
                                            + Command.getSyntax() + ")",
                                    "");
                            e.printStackTrace();
                        }
                    } else if (Command.getPermLevel() <= 5 && userPermLevel >= 1) {
                        try {
                            Command.onCommand(privcommand, event.getUser(), event.getBot(), null, null, true,
                                    userPermLevel, message);
                        } catch (Exception e) {
                            IRCUtils.sendError(event.getUser(), event.getBot(), null,
                                    "Failed to execute command, please make sure you are using the correct syntax ("
                                            + Command.getSyntax() + ")",
                                    "");
                            e.printStackTrace();
                        }
                    } else {
                        if (userPermLevel >= Command.getPermLevel()) {
                            try {
                                Command.onCommand(privcommand, event.getUser(), event.getBot(), null, null,
                                        true, userPermLevel, message);
                            } catch (Exception e) {
                                IRCUtils.sendError(event.getUser(), event.getBot(), null,
                                        "Failed to execute command, please make sure you are using the correct syntax ("
                                                + Command.getSyntax() + ")",
                                        "");
                                e.printStackTrace();
                            }
                        } else {
                            IRCUtils.sendError(event.getUser(), event.getBot(), null, "Permission denied", "");
                        }
                    }
                }
            }
        }

    }
    Registry.threadPool.execute(new process());
}

From source file:com.thoughtworks.go.domain.Matcher.java

public String toString() {
    return StringUtils.join(matchers, ',');
}

From source file:com.blackducksoftware.integration.hub.api.item.HubItem.java

public String getLink(final String linkRel) throws UnexpectedHubResponseException {
    final List<String> links = getLinks(linkRel);
    if (links.size() != 1) {
        final String combinedLinks = StringUtils.join(links, ", ");
        throw new UnexpectedHubResponseException(
                String.format("1 link was expected, but found %s: %s", links.size(), combinedLinks));
    }/*from   w w w.j a v a2s .  c om*/

    return links.get(0);
}

From source file:com.lyncode.jtwig.tree.expressions.OperationBinary.java

public String toString() {
    List<String> results = new ArrayList<String>();
    if (!operands.isEmpty()) {
        results.add(getDescription(0));//from  w ww.j a  v a  2s. co  m
        for (int i = 1; i < operands.size(); i++) {
            results.add(operators.get(i - 1).toString());
            results.add(getDescription(i));
        }
    } else
        return "Binary operation without operands";

    return StringUtils.join(results, " ");
}

From source file:com.puppycrawl.tools.checkstyle.api.FullIdent.java

/**
 * Gets the text.
 * @return the text
 */
public String getText() {
    return StringUtils.join(elements, "");
}

From source file:io.cloudex.framework.partition.entities.PartitionTest.java

/**
 * Test method for {@link io.cloudex.framework.partition.entities.Partition#joinPartitionItems(java.util.List)}.
 *//*from   ww w .  j a  va 2 s. co m*/
@Test
public void testJoinPartitionItems() {
    assertEquals(5, bins.size());

    List<String> parts = Partition.joinPartitionItems(bins);

    int i = 0;
    for (Partition bin : bins) {
        List<String> joined = new ArrayList<>();

        for (Item item : bin.getItems()) {
            joined.add(item.getKey());
        }

        assertEquals(parts.get(i), StringUtils.join(joined, ','));

        i++;

    }
}

From source file:com.mycsense.carbondb.domain.Dimension.java

public String toString() {
    return StringUtils.join(keywords, "+");
}

From source file:eu.dety.burp.joseph.utilities.Decoder.java

/**
 * Join separate parts to JOSE value//from   w w w .j a  v  a  2s. co  m
 * 
 * @param input
 *            string array of JOSE values in compact serialization
 * @return single string with concatenated components
 */
public static String concatComponents(String[] input) {
    return StringUtils.join(input, ".");
}

From source file:jongo.sql.DynamicFinder.java

/**
 * Creates a dynamic finder for the given arguments.
 * @param resource the resource where to apply the statement
 * @param query the query to parse//  w  ww  .j a v a 2 s.  com
 * @param values the values for the query
 * @return a DynamicFinder
 * @throws JongoBadRequestException if we're unable to parse the query or values.
 */
public static DynamicFinder valueOf(String resource, final String query, final String... values)
        throws JongoBadRequestException {
    l.debug("Generating dynamic finder for " + query + " with values: [ " + StringUtils.join(values, ",")
            + "]");
    String str = query;
    String cmd = null;
    if (str.contains(FINDBY)) {
        str = str.substring(FINDBY.length());
        cmd = FINDBY;
    } else if (str.contains(FINDALLBY)) {
        str = str.substring(FINDALLBY.length());
        cmd = FINDALLBY;
    } else {
        throw new JongoBadRequestException("Invalid Command " + str, resource);
    }

    String[] strs = JongoUtils.splitCamelCase(str).split("\\ ");
    List<String> columns = new ArrayList<String>();
    List<String> ops = new ArrayList<String>();
    for (String word : strs) {
        if (!Operator.keywords().contains(word)) {
            columns.add(word.toLowerCase());
        } else {
            ops.add(word);
        }
    }
    List<Operator> operators = new ArrayList<Operator>();
    String tmp = "";
    for (int i = 0; i < ops.size(); i++) {
        tmp += ops.get(i);
        try {
            Operator op = Operator.valueOf(tmp.toUpperCase());
            if ((op == Operator.GREATERTHAN || op == Operator.LESSTHAN) && ((i + 1) < ops.size())) {
                Operator ope = Operator.valueOf(ops.get(i + 1).toUpperCase());
                if (ope == Operator.EQUALS) {
                    op = Operator.valueOf(tmp.toUpperCase() + "EQUALS");
                    ops.remove(i + 1);
                }
            }
            operators.add(op);
            tmp = "";
        } catch (IllegalArgumentException e) {
        }
    }

    DynamicFinder finder = null;
    if (operators.isEmpty() && ops.isEmpty()) {
        finder = new DynamicFinder(resource, cmd, columns.get(0));
    } else if (operators.isEmpty() && !ops.isEmpty()) {
        throw new JongoBadRequestException("Invalid Operator", resource);
    } else {
        if (columns.size() == 1) {
            finder = new DynamicFinder(resource, cmd, columns.get(0), operators.get(0));
        } else if (columns.size() == 2) {
            if (operators.size() == 1) {
                finder = new DynamicFinder(resource, cmd, columns.get(0), operators.get(0), columns.get(1));
            } else if (operators.size() == 2) {
                finder = new DynamicFinder(resource, cmd, columns.get(0), operators.get(0), columns.get(1),
                        operators.get(1));
            } else if (operators.size() == 3) {
                finder = new DynamicFinder(resource, cmd, columns.get(0), operators.get(0), operators.get(1),
                        columns.get(1), operators.get(2));
            } else {
                throw new JongoBadRequestException("Too many operators: " + operators.size(), resource);
            }

        } else {
            throw new JongoBadRequestException("Too many columns: " + columns.size(), resource);
        }
    }
    l.debug(finder.getSql());
    return finder;
}