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.pokercompany.stringcalc.StringCalculator.java

public int add(String numbers) throws Exception {
    if (numbers == null) {
        throw new NullPointerException();
    }//from  w  w w .  j  a  v  a2 s  . c o m

    if (numbers.equals("")) {
        return 0;
    }

    if (!numbers.matches("-?[0-9]+([" + separator + "]-?[0-9]+)*[" + separator + "]?")) {
        throw new NumberFormatException("Bad character(s) in input string: " + numbers);
    }

    List<String> numbersList = Arrays.asList(numbers.split("(?<!\\" + separator + ")[" + separator + "]"));
    List<String> negativeNumbers = StringCalcUtil.getListWherePatternMatches(numbersList, "[-][0-9]+");

    if (negativeNumbers.size() > 0) {
        throw new Exception("Negative not allowed: " + StringUtils.join(negativeNumbers.iterator(), ","));
    }

    int sum = 0;
    for (String stringNumber : numbersList) {
        sum += Integer.valueOf(stringNumber);
    }

    return sum;
}

From source file:com.siemens.scr.avt.ad.api.PersistentObjectNotFoundException.java

public PersistentObjectNotFoundException(Class<?> objType, String[] paramTypes, Object[] params,
        Throwable cause) {//from w ww. j  av  a2  s  .c  o m
    this(objType + " with parameters <" + StringUtils.join(paramTypes, LIST_DELIMITER) + ">=("
            + StringUtils.join(params, LIST_DELIMITER) + ") is not found!", cause);
}

From source file:com.stratio.explorer.cassandra.dto.RowsDTO.java

/**
 * Transform rowData to DTO with line separator
 * @param rows rowData to DTO./*from  w  ww. j  ava 2  s .c  o  m*/
 * @return DTO
 */
public String toDTO(List<RowData> rows) {
    List<String> list = new ArrayList<>();
    for (RowData row : rows) {
        list.add(cellDto(row.cells()));
    }
    return StringUtils.join(list, System.getProperty("line.separator"));
}

From source file:eu.uqasar.model.TagsBridge.java

@SuppressWarnings("unchecked")
@Override/*from w  ww . ja  v  a 2s.c  om*/
public String objectToString(Object object) {
    if (object instanceof String) {
        return (String) object;
    } else if (object instanceof Collection) {
        List<String> tags = (List<String>) object;
        return StringUtils.join(tags, ',');
    }
    return null;
}

From source file:ezbake.warehaus.WarehausUtils.java

public static String getAuthsListFromToken(EzSecurityToken token) {
    ezbake.base.thrift.Authorizations auths = token.getAuthorizations();
    Set<String> formalAuths = auths.isSetFormalAuthorizations() ? auths.getFormalAuthorizations()
            : Sets.<String>newHashSet();
    Set<String> externalCommunities = auths.isSetExternalCommunityAuthorizations()
            ? auths.getExternalCommunityAuthorizations()
            : Sets.<String>newHashSet();
    Set<String> allAuths = Sets.union(formalAuths, externalCommunities);
    return StringUtils.join(allAuths, ",");
}

From source file:br.com.ingenieux.mojo.simpledb.DeleteDomainsMojo.java

@Override
protected Object executeInternal() throws Exception {
    if (getLog().isInfoEnabled())
        getLog().info("Deleting Domains: " + StringUtils.join(domainsCollection, ", "));

    for (String domain : domainsCollection) {
        if (getLog().isInfoEnabled())
            getLog().info(" * " + domain);

        getService().deleteDomain(new DeleteDomainRequest(domain));
    }//w w  w .ja v  a  2s . c  om

    return null;
}

From source file:net.sf.sze.constraints.ValidVariableTextCheck.java

@Override
public Map<String, String> createMessageVariables() {
    final Map<String, String> messageVariables = new HashMap<String, String>();
    messageVariables.put("illegalVariable", StringUtils.join(illegalVariables, ", "));
    messageVariables.put("allowedVariable", StringUtils.join(VariableUtility.VARIABLE_NAMES, ", "));
    return messageVariables;
}

From source file:com.liferay.jenkins.tools.BeforeTimestampMatcher.java

public BeforeTimestampMatcher(String[] optionValues) throws IllegalArgumentException {

    this(StringUtils.join(optionValues, ' '));
}

From source file:com.liferay.jenkins.tools.AfterTimestampMatcher.java

public AfterTimestampMatcher(String[] optionValues) throws IllegalArgumentException {

    this(StringUtils.join(optionValues, ' '));
}

From source file:com.wavemaker.tools.project.upgrade.RemoveObsoleteFilesUpgradeTask.java

@Override
public void doUpgrade(Project project, UpgradeInfo upgradeInfo) {
    for (String file : this.files) {
        project.getRootFolder().getFile(file).delete();
    }//ww  w.ja v  a  2 s .  c  o m
    upgradeInfo.addMessage("Removed obsolete files: " + StringUtils.join(this.files, ", "));
}