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

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

Introduction

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

Prototype

public static String join(Collection<?> collection, String separator) 

Source Link

Document

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

Usage

From source file:com.redhat.red.build.koji.model.util.StringListValueBinder.java

@Override
public void generate(XmlRpcListener listener, Object value, Map<Class<?>, Mapping<?>> recipes)
        throws XmlRpcException {
    if (value == null) {
        listener.value(null, ValueType.NIL);
        return;/*from ww  w .j a va2  s  .com*/
    } else if (value instanceof Collection<?>) {
        listener.value(StringUtils.join(((Collection<?>) value), " "), ValueType.STRING);
    } else {
        listener.value(value.toString(), ValueType.STRING);
    }
}

From source file:net.easymfne.displayframes.Localization.java

/**
 * Take an enum name string (e.g. "DIAMOND_SWORD") and transform it into a
 * more displayable format (e.g. "Diamond Sword"). This method is typically
 * used as a fallback when no localized name for an object could be found.
 * /*from w w  w . j a va  2 s  . c om*/
 * @param enumString
 *            String to transform
 * @return Nicely formatted string
 */
protected static String formatEnumString(String enumString) {
    if (enumString == null) {
        return null;
    }
    if (enumString.length() == 0) {
        return "";
    }
    String[] parts = enumString.split("_");
    for (int i = 0; i < parts.length; i++) {
        parts[i] = parts[i].substring(0, 1).toUpperCase() + parts[i].substring(1).toLowerCase();
    }
    return StringUtils.join(parts, " ");
}

From source file:com.aionemu.gameserver.model.templates.mail.MailPart.java

public String getFormattedString(IMailFormatter customFormatter) {
    String result = "";
    IMailFormatter formatter = this;
    if (customFormatter != null) {
        formatter = customFormatter;//from   ww  w . jav a  2  s.c om
    }

    result = getFormattedString(getType());

    String[] paramValues = new String[getParam().size()];
    for (int i = 0; i < getParam().size(); i++) {
        Param param = getParam().get(i);
        paramValues[i] = formatter.getParamValue(param.getId());
    }
    String joinedParams = StringUtils.join(paramValues, ',');
    if (StringUtils.isEmpty(result)) {
        return joinedParams;
    } else if (!StringUtils.isEmpty(joinedParams)) {
        result += "," + joinedParams;
    }

    return result;
}

From source file:com.alibaba.otter.node.etl.common.io.download.impl.aria2c.Aria2cDownload.java

@Override
protected void buildCmd(String cmdPath, String[] params) {
    // //from   w  ww  . j  a  va  2s.  c o  m
    boolean retry = targetFile.exists();
    this.cmd = String.format("%s %s-o %s -d %s -l %s/aria2c.log %s %s", cmdPath, retry ? "-c " : "",
            targetFile.getName(), this.targetDir, this.targetDir,
            StringUtils.join(((params == null) || (params.length == 0)) ? ARIA2C_PARAM : params, ' '), url);
}

From source file:com.comphenix.xp.parser.text.PresetParser.java

@Override
public PresetQuery parse(String text) throws ParsingException {

    if (text.length() == 0)
        // Empty names are not legal in YAML, so this shouldn't be possible 
        throw new IllegalArgumentException("Key must have some characters.");

    Queue<String> tokens = getParameterQueue(text);

    List<String> presetNames = textParsing.parse(tokens);
    List<String> worldNames = textParsing.parse(tokens);

    if (!tokens.isEmpty())
        throw ParsingException.fromFormat("Unknown preset tokens: ", StringUtils.join(tokens, ", "));

    return new PresetQuery(presetNames, worldNames);
}

From source file:ei.ne.ke.cassandra.cql3.template.In.java

/**
 * {@inheritDoc}//from   ww  w .  ja v a2  s.c o m
 */
@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append(identifier);
    sb.append(" ");
    sb.append("IN(");
    sb.append(StringUtils.join(terms, ", "));
    sb.append(")");
    return sb.toString();
}

From source file:com.inmobi.grill.server.IndexResource.java

@GET
@Path("/admin/stack")
@Produces(MediaType.TEXT_PLAIN)/*from w  w w . j  av a2 s .  c om*/
public String getThreadDump() {
    ThreadGroup topThreadGroup = Thread.currentThread().getThreadGroup();

    while (topThreadGroup.getParent() != null) {
        topThreadGroup = topThreadGroup.getParent();
    }
    Thread[] threads = new Thread[topThreadGroup.activeCount()];

    int nr = topThreadGroup.enumerate(threads);
    StringBuilder builder = new StringBuilder();
    builder.append("Total number of threads:").append(nr).append("\n");
    for (int i = 0; i < nr; i++) {
        builder.append(threads[i].getName()).append("\n\tState: ").append(threads[i].getState()).append("\n");
        String stackTrace = StringUtils.join(threads[i].getStackTrace(), "\n");
        builder.append(stackTrace);
        builder.append("\n----------------------\n\n");
    }
    return builder.toString();
}

From source file:com.sap.prd.mobile.ios.mios.CodeSignManager.java

private static ExecResult exec(String[] cmd) throws IOException {
    String cmdStr = StringUtils.join(cmd, " ");
    System.out.println("Invoking " + cmdStr);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos, true, "UTF-8");
    try {/* w w w  . j a  va 2 s. co m*/
        int exitValue = Forker.forkProcess(ps, null, "bash", "-c", cmdStr);
        return new ExecResult(cmdStr, baos.toString("UTF-8"), exitValue);
    } finally {
        ps.close();
    }
}

From source file:com.framework.infrastructure.utils.Collections3.java

/**
 * CollectionString,  separator//from   w w w  .  ja  v a2  s  . c  o m
 */
public static String convertToString(final Collection collection, final String separator) {
    return StringUtils.join(collection, separator);
}

From source file:com.github.hexocraft.chestpreview.command.CpCommandList.java

/**
 * @param plugin The plugin that this object belong to.
 *//*from   w  w  w .j  a  v a2  s .  c om*/
public CpCommandList(ChestPreviewPlugin plugin) {
    super("list", plugin);
    this.setAliases(Lists.newArrayList("l"));
    this.setDescription(StringUtils.join(plugin.messages.cList, "\n"));
    this.setPermission(Permissions.ADMIN.toString());
}