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.profitsoftware.vaadin.query.matcher.MatchOr.java

@Override
public String toString() {
    return "or(" + StringUtils.join(matcher, ",") + ")";
}

From source file:com.liferay.blade.cli.GradleCommand.java

public void execute() throws Exception {
    String gradleCommand = StringUtils.join(_options._arguments(), " ");

    GradleExec gradleExec = new GradleExec(_blade);

    gradleExec.executeGradleCommand(gradleCommand);
}

From source file:com.ibm.watson.developer_cloud.util.DateDeserializerTest.java

/**
 * Test deserialize.//www.j a  v a  2s .c o  m
 */
@Test
public void testDeserialize() {
    String[] dateStrings = { "2016-06-20T04:25:16.218+0000", "2016-06-20T04:25:16", "2016-06-20T04:25:16.218Z",
            "2015-05-28T18:01:57Z", "2016-06-20T04:25:16.218+0000", "1478097789", "1478097789000" };

    String jsonStr = "[\"" + StringUtils.join(dateStrings, "\",\"") + "\"]";
    JsonParser parser = new JsonParser();
    JsonElement element = parser.parse(jsonStr);
    DateDeserializer deserializer = new DateDeserializer();
    for (int i = 0; i < dateStrings.length; i++) {
        System.out.println(deserializer.deserialize(element.getAsJsonArray().get(i), null, null));
        assertTrue(deserializer.deserialize(element.getAsJsonArray().get(i), null, null) != null);
    }
}

From source file:at.co.federmann.gtd.domain.Priority.java

public static Priority resolvePriority(Integer id) {
    if (id == null) {
        return null;
    }/*from   w w  w.j ava2s.c o m*/
    for (Priority priority : Priority.values()) {
        if (id.equals(priority.id)) {
            return priority;
        }
    }
    throw new IllegalArgumentException(StringUtils.join("No matching priority found for id ", id));
}

From source file:com.profitsoftware.vaadin.query.matcher.MatchAnd.java

@Override
public String toString() {
    return "and(" + StringUtils.join(matchers, ",") + ")";
}

From source file:com.technophobia.substeps.model.Util.java

public static String[] getArgs(final String patternString, final String sourceString,
        final String[] keywordPrecedence) {

    log.debug("Util getArgs String[] with pattern: " + patternString + " and sourceStr: " + sourceString);

    String[] rtn = null;/*from w w w  .  ja v a  2  s .c o m*/

    ArrayList<String> argsList = null;

    String patternCopy = new String(patternString);
    if (keywordPrecedence != null && StringUtils.startsWithAny(patternString, keywordPrecedence)) {
        //
        for (String s : keywordPrecedence) {

            patternCopy = StringUtils.removeStart(patternCopy, s);
        }

        patternCopy = "(?:" + StringUtils.join(keywordPrecedence, "|") + ")" + patternCopy;
    }

    final Pattern pattern = Pattern.compile(patternCopy);
    final Matcher matcher = pattern.matcher(sourceString);

    final int groupCount = matcher.groupCount();

    // TODO - this doesn't work if we're not doing strict matching
    if (matcher.find()) {

        for (int i = 1; i <= groupCount; i++) {
            final String arg = matcher.group(i);

            if (arg != null) {
                if (argsList == null) {
                    argsList = new ArrayList<String>();
                }
                argsList.add(arg);
            }
        }
    }

    if (argsList != null) {
        rtn = argsList.toArray(new String[argsList.size()]);

        if (log.isDebugEnabled()) {

            final StringBuilder buf = new StringBuilder();
            buf.append("returning args: ");

            for (final String s : argsList) {

                buf.append("[").append(s).append("] ");
            }

            log.debug(buf.toString());
        }

    }

    return rtn;
}

From source file:KeywordTester.java

public KeywordTester(List<ValidUser> users, String outputDirectory, boolean addUsernameAsKeyword,
        boolean stagger, long runDuration, MongoClient mongoClient, int iteration, String... keywords)
        throws InterruptedException {

    this.outputDirectory = outputDirectory;
    String directory = StringUtils.join(keywords, "_").replace(" ", "_") + "_"
            + String.valueOf(addUsernameAsKeyword) + "_" + String.valueOf(stagger) + "_"
            + String.valueOf(iteration);

    File theDir = new File(outputDirectory + directory);
    if (!theDir.exists()) {
        System.out.println("creating directory: " + directory);
        boolean result = theDir.mkdir();

        if (result) {
            System.out.println("DIR created");
        }/*w  w  w .  ja  va  2 s. c  o  m*/
    }
    for (ValidUser u : users) {
        DB db = mongoClient.getDB(u.name);
        samplers.add(new KeywordSampler(u, addUsernameAsKeyword, db, outputDirectory, directory, keywords));
    }

    for (KeywordSampler k : samplers) {
        //Tried staggering runtimes.  Didn't affect anything in any obvious way
        if (stagger) {
            Thread.sleep(150);
        }
        k.start();
    }
    Thread.sleep(runDuration);
    for (KeywordSampler k : samplers) {
        System.out.println("stopping");
        k.stop();
    }
}

From source file:com.lyncode.jtwig.parser.error.ErrorExplainer.java

public String explain(InvalidInputError error) {
    ErrorInfo known = findKnownError(error.getFailedMatchers());
    if (known == null)
        return "Unknown Error";
    else {/*  ww w . jav  a  2  s  .  c om*/
        switch (known.getKnownError()) {
        case Keyword:
            return "Expecting one of keywords (" + StringUtils.join(JtwigKeyword.keywords(), ", ") + ")";
        case SpecificKeyword:
            return specificKeyword(known.getChild().element.matcher.getLabel());
        }
        throw new RuntimeException("Expecting explanation");
    }
}

From source file:hydrograph.engine.cascading.scheme.hive.parquet.HiveParquetSchemeHelper.java

public static Properties getTableProperties(HiveTableDescriptor hiveTableDescriptor) {

    Properties properties = new Properties();
    String columns = StringUtils.join(hiveTableDescriptor.getColumnNames(), ",");
    String columnTypes = StringUtils.join(hiveTableDescriptor.getColumnTypes(), ":");
    properties.put(COLUMNS, columns);/*from ww  w.  j  av a  2s  .c om*/
    properties.put(COLUMNS_TYPES, columnTypes);
    return properties;
}

From source file:jease.cms.web.content.editor.property.LinesPropertyEditor.java

public void setProperty(LinesProperty property) {
    this.property = property;
    setValue(StringUtils.join(property.getValue(), "\n"));
}