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:com.vrem.wifianalyzer.wifi.channelavailable.ChannelAvailableAdapterTest.java
@Test public void testGetView() throws Exception { // setup/*from w ww .j a va2s . c om*/ Resources resources = mainActivity.getResources(); String wiFiBand2 = resources.getString(WiFiBand.GHZ2.getTextResource()); String wiFiBand5 = resources.getString(WiFiBand.GHZ5.getTextResource()); String expected = wiFiChannelCountry.getCountryCode() + " - " + wiFiChannelCountry.getCountryName(); String expected_GHZ_2 = StringUtils.join(wiFiChannelCountry.getChannelsGHZ2().toArray(), ","); String expected_GHZ_5 = StringUtils.join(wiFiChannelCountry.getChannelsGHZ5().toArray(), ","); // execute View actual = fixture.getView(0, null, null); // validate assertNotNull(actual); assertEquals(expected, ((TextView) actual.findViewById(R.id.channel_available_country)).getText()); assertEquals(wiFiBand2 + " : ", ((TextView) actual.findViewById(R.id.channel_available_title_ghz_2)).getText()); assertEquals(expected_GHZ_2, ((TextView) actual.findViewById(R.id.channel_available_ghz_2)).getText()); assertEquals(wiFiBand5 + " : ", ((TextView) actual.findViewById(R.id.channel_available_title_ghz_5)).getText()); assertEquals(expected_GHZ_5, ((TextView) actual.findViewById(R.id.channel_available_ghz_5)).getText()); }
From source file:ddf.catalog.transformer.csv.common.MetacardIterator.java
/** {@inheritDoc} */ @Override/* ww w .j a va 2 s. c o m*/ public Serializable next() { if (!this.hasNext()) { throw new NoSuchElementException(); } AttributeDescriptor attributeDescriptor = this.attributeDescriptorList.get(index); Attribute attribute = metacard.getAttribute(attributeDescriptor.getName()); index++; if (attribute != null) { if (attributeDescriptor.isMultiValued()) { return StringUtils.join(attribute.getValues(), MULTIVALUE_DELIMITER); } else { return attribute.getValue(); } } return ""; }
From source file:de.uni.bremen.monty.moco.codegeneration.identifier.ArrayConstant.java
@Override public String getName() { return " [ " + StringUtils.join(arguments, ", ") + " ]"; }
From source file:com.connio.sdk.request.account.AccountReadRequest.java
@Override protected Request request() { final Map<String, String> filter = new HashMap<>(); if (StringUtils.isNotBlank(email)) filter.put("email", email); if (StringUtils.isNotBlank(name)) filter.put("name", name); if (status != null) filter.put("status", status.value()); if (tags != null && tags.size() > 0) filter.put("tags", StringUtils.join(tags, ",")); filter.putAll(getPaginationParameters()); return Request.get("accounts", filter); }
From source file:com.thoughtworks.go.util.LogFixture.java
public String getLog() { return StringUtils.join(getFormattedMessages(), ", "); }
From source file:de.uni.bremen.monty.moco.codegeneration.identifier.StructConstant.java
@Override public String getName() { return " { " + StringUtils.join(arguments, ", ") + " }"; }
From source file:io.seldon.importer.articles.dynamicextractors.CategoryFromKeywordsDynamicExtractor.java
@Override public String extract(AttributeDetail attributeDetail, String url, Document articleDoc) throws Exception { String attrib_value = null;/* w w w. j a v a 2s. c om*/ String[] tags = null; if ((attributeDetail.extractor_args != null) && (attributeDetail.extractor_args.size() >= 3)) { String cssSelector = attributeDetail.extractor_args.get(0); Element element = articleDoc.select(cssSelector).first(); if (StringUtils.isNotBlank(cssSelector)) { String value_name = attributeDetail.extractor_args.get(1); if (element != null && element.attr(value_name) != null) { String rawList = element.attr(value_name); if (StringUtils.isNotBlank(rawList)) { tags = rawList.split(","); for (int i = 0; i < tags.length; i++) { tags[i] = tags[i].trim().toLowerCase(); } attrib_value = StringUtils.join(tags, ','); } } } } if (StringUtils.isNotBlank(attrib_value)) { String[] categories = attributeDetail.extractor_args.get(2).split(","); for (String category : categories) { for (String tag : tags) if (category.equals(tag)) return tag; } } return null; }
From source file:com.xpn.xwiki.objects.ListProperty.java
@Override public String toText() { if ((getList() instanceof PersistentCollection) && (!((PersistentCollection) getList()).wasInitialized())) { return ""; }//from www .ja va 2s . c o m return StringUtils.join(getList().toArray(), " "); }
From source file:com.moscona.dataSpace.ExportHelper.java
public void csvExport(DataFrame df, String fileName, boolean includeMetaData) throws FileNotFoundException, DataSpaceException { // FIXME exports sorted and label columns twice - once populated and once not - the populated ones are the wrong ones PrintStream out = new PrintStream(new File(fileName)); try {/*from w w w . j a v a 2 s . c om*/ ArrayList<String> labels = new ArrayList<String>(); ArrayList<String> sorted = new ArrayList<String>(); for (String col : df.getColumnNames()) { if (df.isLabel(col)) { labels.add(col); } if (df.get(col).isSorted()) { sorted.add(col); } } if (includeMetaData) { csvOut(out, "name", df.getName()); csvOut(out, "description", df.getDescription()); csvOut(out, "row ID", df.getRowId()); csvOut(out, "sort column", df.getSortColumn()); Collections.sort(labels); Collections.sort(sorted); out.println(excelQuote("label columns") + "," + StringUtils.join(labels, ",")); out.println(excelQuote("sorted columns") + "," + StringUtils.join(sorted, ",")); out.println(); } ArrayList<String> columns = new ArrayList<String>(); ArrayList<String> remaining = new ArrayList<String>(df.getColumnNames()); if (df.getRowId() != null) { // make first column the row ID String rowId = df.getRowId(); columns.add(rowId); remaining.remove(rowId); } // add all the sorted columns columns.addAll(sorted); remaining.removeAll(sorted); remaining.removeAll(labels); // those will come in last Collections.sort(remaining); columns.addAll(remaining); columns.addAll(labels); out.println(StringUtils.join(columns, ",")); IVectorIterator<Map<String, IScalar>> iterator = df.iterator(); while (iterator.hasNext()) { Map<String, IScalar> row = iterator.next(); ArrayList<String> values = new ArrayList<String>(); for (String col : columns) { values.add(toCsvString(row.get(col))); } out.println(StringUtils.join(values, ",")); } } finally { out.close(); } }
From source file:net.ae97.pokebot.extensions.scrolls.BadgeRanks.java
private synchronized void sync() { if (lastUpdate + (1000 * 60 * 60 * 24) > System.currentTimeMillis()) { return;/*from w ww .jav a2 s . co m*/ } try { URL url = new URL(syncURL); List<String> lines = new LinkedList<>(); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "PokeBot - " + PokeBot.VERSION); conn.connect(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()))) { String line; while ((line = reader.readLine()) != null) { lines.add(line); } } JsonParser parser = new JsonParser(); JsonElement element = parser.parse(StringUtils.join(lines, "\n")); JsonObject obj = element.getAsJsonObject(); String result = obj.get("msg").getAsString(); if (!result.equalsIgnoreCase("success")) { throw new IOException("API replied with error"); } JsonArray dataObject = obj.get("data").getAsJsonArray(); synchronized (ranks) { ranks.clear(); for (int i = 0; i < dataObject.size(); i++) { JsonObject rank = dataObject.get(i).getAsJsonObject(); ranks.put(rank.get("id").getAsString(), rank.get("name").getAsString()); } ranks.put("-1", "No badge"); } lastUpdate = System.currentTimeMillis(); } catch (IOException | JsonSyntaxException ex) { extension.getLogger().log(Level.SEVERE, "Error on syncing badge ranks", ex); lastUpdate = -1; } }