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:$.Collections3.java
/** * ?Collection(toString())String, separator *//*from w w w . j av a2s. c o m*/ public static String convertToString(final Collection collection, final String separator) { return StringUtils.join(collection, separator); }
From source file:foam.lib.parse.ErrorReportingPStream.java
public String getMessage() { // check if err is valid and print the char, if not print EOF String invalid = (errStream.valid()) ? String.valueOf(errStream.head()) : "EOF"; // get a list of valid characters TrapPStream trap = new TrapPStream(this); for (int i = 0; i <= 255; i++) { trap.setHead((char) i); trap.apply(errParser, errContext); }/*from ww w . ja v a 2s .c om*/ return "Invalid character '" + invalid + "' found at " + errStream.pos_ + "\n" + "Valid characters include: " + StringUtils.join(validCharacters, ","); }
From source file:com.datatorrent.lib.io.fs.FileSplitterInputTest.java
static Set<String> createData(String dataDirectory) throws IOException { Set<String> filePaths = Sets.newHashSet(); FileContext.getLocalFSFileContext().delete(new Path(new File(dataDirectory).getAbsolutePath()), true); HashSet<String> allLines = Sets.newHashSet(); for (int file = 0; file < 12; file++) { HashSet<String> lines = Sets.newHashSet(); for (int line = 0; line < 2; line++) { //padding 0 to file number so every file has 6 blocks. lines.add("f" + String.format("%02d", file) + "l" + line); }/*from w w w. j a v a 2 s . co m*/ allLines.addAll(lines); File created = new File(dataDirectory, "file" + file + ".txt"); filePaths.add(created.getAbsolutePath()); FileUtils.write(created, StringUtils.join(lines, '\n')); } return filePaths; }
From source file:com.aol.one.patch.PathTokens.java
public String getPathSansFirstToken() { if (this.size() < 1) { return null; }/* www . j av a 2 s .co m*/ return SLASH + StringUtils.join(this.listIterator(1), SLASH); }
From source file:annis.sqlgen.annopool.ApAnnotateSqlGenerator.java
@Override public String fromClause(QueryData queryData, List<QueryNode> alternative, String indent) { TableAccessStrategy tas = createTableAccessStrategy(); List<Long> corpusList = queryData.getCorpusList(); StringBuilder sb = new StringBuilder(); sb.append(indent).append("solutions,\n"); sb.append(indent).append(TABSTOP);/*w ww . j av a 2 s.com*/ // really ugly sb.append(getTableJoinsInFromClauseSqlGenerator().fromClauseForNode(null, true)); sb.append("\n"); sb.append(indent).append(TABSTOP); sb.append("LEFT OUTER JOIN annotation_pool AS node_anno ON (") .append(tas.aliasedColumn(NODE_TABLE, "node_anno_ref")).append(" = node_anno.id AND ") .append(tas.aliasedColumn(NODE_TABLE, "toplevel_corpus")) .append(" = node_anno.toplevel_corpus AND node_anno.toplevel_corpus IN (") .append(StringUtils.join(corpusList, ", ")).append("))"); sb.append("\n"); sb.append(indent).append(TABSTOP); sb.append("LEFT OUTER JOIN annotation_pool AS edge_anno ON (") .append(tas.aliasedColumn(RANK_TABLE, "edge_anno_ref")).append(" = edge_anno.id AND ") .append(tas.aliasedColumn(RANK_TABLE, "toplevel_corpus")) .append(" = edge_anno.toplevel_corpus AND " + "edge_anno.toplevel_corpus IN (") .append(StringUtils.join(corpusList, ", ")).append("))"); sb.append(",\n"); sb.append(indent).append(TABSTOP); sb.append(TableAccessStrategy.CORPUS_TABLE); return sb.toString(); }
From source file:annis.gui.controller.FrequencyBackgroundJob.java
private FrequencyTable loadBeans() { FrequencyTable result = new FrequencyTable(); WebResource annisResource = Helper.getAnnisWebResource(); try {//from ww w.ja va 2 s .co m annisResource = annisResource.path("query").path("search").path("frequency") .queryParam("q", Helper.encodeJersey(query.getQuery())) .queryParam("corpora", StringUtils.join(query.getCorpora(), ",")) .queryParam("fields", query.getFrequencyDefinition().toString()); result = annisResource.get(FrequencyTable.class); } catch (UniformInterfaceException ex) { String message; if (ex.getResponse().getStatus() == 400) { message = ex.getResponse().getEntity(String.class); } else if (ex.getResponse().getStatus() == 504) { message = "Timeout: query exeuction took too long"; } else { message = "unknown error: " + ex; log.error(ex.getResponse().getEntity(String.class), ex); } Notification.show(message, Notification.Type.WARNING_MESSAGE); } catch (ClientHandlerException ex) { log.error("could not execute REST call to query frequency", ex); } return result; }
From source file:com.yahoo.validatar.report.junit.JUnitFormatter.java
/** * {@inheritDoc}/*from www .j ava2 s . c om*/ * Writes out the report for the given testSuites in the JUnit XML format. */ @Override public void writeReport(List<TestSuite> testSuites) throws IOException { Document document = DocumentHelper.createDocument(); Element testSuitesRoot = document.addElement("testsuites"); // Output for each test suite for (TestSuite testSuite : testSuites) { Element testSuiteRoot = testSuitesRoot.addElement("testsuite") .addAttribute("tests", Integer.toString(testSuite.queries.size() + testSuite.tests.size())) .addAttribute("name", testSuite.name); for (Query query : testSuite.queries) { Element queryNode = testSuiteRoot.addElement("testcase").addAttribute("name", query.name); if (query.failed()) { String failureMessage = StringUtils.join(query.getMessages(), ", "); queryNode.addElement("failed").addText(failureMessage); } } for (Test test : testSuite.tests) { Element testNode = testSuiteRoot.addElement("testcase").addAttribute("name", test.name); if (test.failed()) { String failedAsserts = StringUtils.join(test.getMessages(), ", "); String failureMessage = "Description: " + test.description + ";\n" + "Failed asserts: " + failedAsserts + "\n"; testNode.addElement("failed").addText(failureMessage); } } } OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(new FileWriter(outputFile), format); writer.write(document); writer.close(); }
From source file:com.sonicle.webtop.contacts.bol.VListRecipient.java
@Override public String getRecipient() { String recipient = super.getRecipient(); Integer rcid = getRecipientContactId(); if (rcid != null && rcid > 0) { String email = LangUtils.coalesceStrings(workEmail, homeEmail, otherEmail); if (email != null) { String name = StringUtils.join(new String[] { firstname, lastname }, " "); if (!StringUtils.isEmpty(name)) email = name + " <" + email + ">"; recipient = email;/*from w w w . j av a2s.c om*/ } } return recipient; }
From source file:com.creditcloud.ump.model.ump.base.BaseRequest.java
public String chkString() { Map<String, String> values = MessageUtils.getFieldValuesMap(this); Set<String> sets = new TreeSet<>(); for (String key : values.keySet()) { String value = values.get(key); if (!key.equals("sign") && !key.equals("sign_type")) { // skip sign and sign_type field, they are not in checksum string if (value != null) { String theValue = key.equals("service") ? value.toLowerCase() : value; sets.add(key + "=" + theValue); }/*from w w w . j a va2 s. c o m*/ } } return StringUtils.join(sets, "&"); }
From source file:com.njmd.framework.utils.memcached.SpyMemcachedClient.java
/** * GetBulk, ??.//from w w w. ja v a 2s.com */ @SuppressWarnings("unchecked") public <T> Map<String, T> getBulk(Collection<String> keys) { try { return (Map<String, T>) memcachedClient.getBulk(keys); } catch (RuntimeException e) { handleException(e, StringUtils.join(keys, ",")); return null; } }