List of usage examples for org.apache.commons.lang3 StringUtils join
public static String join(final Iterable<?> iterable, final String separator)
Joins the elements of the provided Iterable into a single String containing the provided elements.
No delimiter is added before or after the list.
From source file:io.wcm.caravan.pipeline.extensions.hal.filter.HalResourceFilters.java
/** * Executes all predicates and combines the result by logical {@code and}. If there are negative predicate results, * remaining predicates will not get executed. * @param predicates Predicates to check * @return True if all predicates return true *///ww w . j a v a 2 s . c om public static HalResourcePredicate all(HalResourcePredicate... predicates) { return new HalResourcePredicate() { @Override public boolean apply(HalPath halPath, HalResource hal) { for (HalResourcePredicate predicate : predicates) { if (!predicate.apply(halPath, hal)) { return false; } } return true; } @Override public String getId() { List<String> ids = Stream.of(predicates).map(matcher -> matcher.getId()) .collect(java.util.stream.Collectors.toList()); return "ALL(" + StringUtils.join(ids, '+') + ")"; } }; }
From source file:cc.recommenders.utils.parser.MavenVersionParser.java
private static void consumeDelimiter(final StringTokenizer st, final String... allowedDelimiters) { final String delimiter = st.nextToken(); for (final String allowedDelimiter : allowedDelimiters) { if (delimiter.equals(allowedDelimiter)) { return; }/*from w ww . jav a 2 s. c om*/ } Throws.throwIllegalArgumentException("Unexpected delimiter '%s'; Expected delimiters '%s'", delimiter, StringUtils.join(allowedDelimiters, "','")); }
From source file:forestry.arboriculture.commands.CommandTreeSpawn.java
@Override public final void processSubCommand(ICommandSender sender, String[] arguments) { if (arguments.length < 1 || arguments.length > 2) { printHelp(sender);/* w w w .j a v a 2s . c o m*/ return; } EntityPlayer player; String treeName; try { player = CommandHelpers.getPlayer(sender, arguments[arguments.length - 1]); String[] argumentsWithoutPlayer = new String[arguments.length - 1]; System.arraycopy(arguments, 0, argumentsWithoutPlayer, 0, arguments.length - 1); treeName = StringUtils.join(argumentsWithoutPlayer, " "); } catch (PlayerNotFoundException e) { player = CommandHelpers.getPlayer(sender, sender.getCommandSenderName()); treeName = StringUtils.join(arguments, " "); } boolean success = treeSpawner.spawn(sender, treeName, player); if (!success) printHelp(sender); }
From source file:com.nesscomputing.migratory.migration.sql.SqlScriptSmallTest.java
@Test public void stripSqlCommentsSingleLineComment() { lines.add("--select * from table;"); sqlScript = new SqlScript(StringUtils.join(lines, "\n")); final Collection<SqlStatement> statements = sqlScript.getSqlStatements(); Assert.assertNotNull(statements);/*from w w w. ja v a2 s .com*/ Assert.assertEquals(0, statements.size()); }
From source file:com.nestedbird.modules.sitemap.SitemapEntity.java
public String generate() { // @formatter:off return StringUtils.join(new String[] { "<url>", "<loc>" + externalUrl + StringEscapeUtils.escapeXml11(relativeUrl) + "</loc>", "<lastmod>" + StringEscapeUtils.escapeXml11(lastModified.toString()) + "</lastmod>", "<changefreq>" + changeFrequency + "</changefreq>", "<priority>" + priority + "</priority>", "</url>" }, ""); // @formatter:on }
From source file:br.usp.poli.lta.cereda.wirth2ape.structure.Stack.java
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Pilha: ["); if (isEmpty()) { sb.append("vazia"); } else {/*w w w . ja v a 2 s . c o m*/ sb.append(StringUtils.join(list, ", ")); } sb.append("]"); return sb.toString(); }
From source file:com.lexicalintelligence.admin.remove.RemoveRequest.java
public RemoveResponse execute() { List<BasicNameValuePair> params = Collections .singletonList(new BasicNameValuePair(getName(), StringUtils.join(items, ","))); RemoveResponse removeResponse;//from w w w. ja v a 2 s. co m Reader reader = null; try { HttpResponse response = client.getHttpClient().execute(new HttpGet(client.getUrl() + PATH + getPath() + "?" + URLEncodedUtils.format(params, StandardCharsets.UTF_8))); reader = new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8); removeResponse = new RemoveResponse(Boolean.valueOf(IOUtils.toString(reader))); } catch (Exception e) { removeResponse = new RemoveResponse(false); log.error(e); } finally { try { reader.close(); } catch (Exception e) { log.error(e); } } return removeResponse; }
From source file:com.romeikat.datamessie.core.base.ui.component.DocumentsFilter.java
private static String generateDocumentsString(final Collection<Long> documentIds) { if (documentIds == null || documentIds.isEmpty()) { return null; }//from w ww. j av a 2s. com final String documentsString = StringUtils.join(documentIds, " "); return documentsString; }
From source file:eu.delving.x3ml.TestDoubleJoin.java
@Test public void testDoubleJoin() { X3MLEngine engine = engine("/double_join/doublejoin.x3ml"); Generator policy = X3MLGeneratorPolicy.load(resource("/coin_a/00-generator-policy.xml"), X3MLGeneratorPolicy.createUUIDSource(2)); X3MLEngine.Output output = engine.execute(document("/double_join/doubleinput.xml"), policy); String[] mappingResult = output.toStringArray(); // output.writeXML(System.out); String[] expectedResult = xmlToNTriples("/double_join/double_result.xml"); List<String> diff = compareNTriples(expectedResult, mappingResult); assertTrue("\nLINES:" + diff.size() + "\n" + StringUtils.join(diff, "\n") + "\n", errorFree(diff)); }
From source file:com.threewks.thundr.bind.TestBindTo.java
public <T extends String> Object methodGenericArray(T[] argument1) { return StringUtils.join(argument1, ":"); }