List of usage examples for org.apache.commons.lang StringUtils join
public static String join(Collection<?> collection, String separator)
Joins the elements of the provided Collection
into a single String containing the provided elements.
From source file:com.nuxeo.intranet.jenkins.web.JenkinsJobsActions.java
/** * Converts a job comment to HTML and parses JIRA issues to turn them into * links.//from w w w . j av a2s.c om * * @param jiraUrl TODO */ public String getConvertedJobComment(String toConvert, String jiraURL, String[] jiraProjects) { if (toConvert == null) { return null; } if (StringUtils.isBlank(jiraURL) || jiraProjects == null || jiraProjects.length == 0) { toConvert = toConvert.replace("\n", "<br />\n"); return toConvert; } String res = ""; String regexp = "\\b(" + StringUtils.join(jiraProjects, "|") + ")-\\d+\\b"; Pattern pattern = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE); Matcher m = pattern.matcher(toConvert); int lastIndex = 0; boolean done = false; while (m.find()) { String jiraIssue = m.group(0); res += toConvert.substring(lastIndex, m.start()) + getJiraUrlTag(jiraURL, jiraIssue); lastIndex = m.end(); done = true; } if (done) { res += toConvert.substring(lastIndex); } else { res = toConvert; } res = res.replace("\n", "<br />\n"); return res; }
From source file:com.conversantmedia.mapreduce.tool.RunJobTest.java
@Test public void testScanPackages_Resource() { String packages = "package1,package2,package3"; try {/* w w w.j a v a2s. co m*/ String[] result = RunJob.getBasePackagesToScanForDrivers(); assertNotNull(result); assertThat(result.length, equalTo(3)); assertThat(StringUtils.join(result, ","), equalTo(packages)); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:com.microsoft.azure.shortcuts.services.samples.NetworksSample.java
public static void test(Azure azure) throws Exception { String networkName;// www . j ava 2 s. c o m Network network; // Create a network with multiple subnets networkName = "net" + String.valueOf(System.currentTimeMillis()); System.out.println(String.format("Creating virtual network named '%s'...", networkName)); azure.networks().define(networkName).withRegion("West US").withAddressSpace("10.0.0.0/28") .withSubnet("Foo", "10.0.0.0/29").withSubnet("Bar", "10.0.0.8/29").create(); // List the virtual networks List<String> virtualNetworkNames = azure.networks().names(); System.out.println("Available virtual networks: " + StringUtils.join(virtualNetworkNames, ", ")); // Get created virtual network network = azure.networks(networkName); printNetwork(network); // Delete the newly created virtual network System.out.println(String.format("Deleting virtual network named '%s'...", network.id())); azure.networks().delete(network.id()); // Create network with default subnet networkName = "net" + String.valueOf(System.currentTimeMillis()); System.out.println(String.format("Creating virtual network named '%s'...", networkName)); azure.networks().define(networkName).withRegion("West US").withAddressSpace("10.0.0.0/29").create(); // List the virtual networks virtualNetworkNames = azure.networks().names(); System.out.println("Available virtual networks: " + StringUtils.join(virtualNetworkNames, ", ")); // Get created virtual network network = azure.networks(networkName); printNetwork(network); // Delete the newly created virtual network System.out.println(String.format("Deleting virtual network named '%s'...", network.id())); azure.networks().delete(network.id()); }
From source file:de.tudarmstadt.ukp.dkpro.spelling.experiments.core.util.MeasureConfig.java
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(resourceClass.getSimpleName()); sb.append("-"); sb.append(StringUtils.join(configParameters, "-")); return sb.toString(); }
From source file:gov.nih.nci.cabig.caaers.dao.query.AdverseEventQuery.java
public AdverseEventQuery(String... selections) { super("select distinct " + AE_ALIAS + ", " + StringUtils.join(selections, ", ") + " from AdverseEvent " + AE_ALIAS);// w w w . java 2 s . c om }
From source file:edu.harvard.iq.dataverse.mydata.SolrQueryFormatter.java
/** * * @param sliceOfIds/*from w w w. ja v a 2s.c o m*/ * @param paramName * @return */ private String formatIdsForSolrClause(List<Long> sliceOfIds, String paramName, String dvObjectType) { //='entityId'): if (paramName == null) { throw new NullPointerException("paramName cannot be null"); } if (sliceOfIds == null) { throw new NullPointerException("sliceOfIds cannot be null"); } if (sliceOfIds.isEmpty()) { throw new IllegalStateException("sliceOfIds must have at least 1 value"); } List<String> idList = new ArrayList<>(); for (Long id : sliceOfIds) { if (id != null) { idList.add("" + id); } } String orClause = StringUtils.join(idList, " "); String qPart = "(" + paramName + ":(" + orClause + "))"; if (dvObjectType != null) { qPart = "(" + paramName + ":(" + orClause + ") AND " + SearchFields.TYPE + ":(" + dvObjectType + "))"; //valStr; } return qPart; }
From source file:com.stratio.explorer.converters.PropertiesToStringConverter.java
private String deleteHeaderLine(String string) { String[] strings = string.split("\\n"); List<String> withOutHeader = Arrays.asList(Arrays.copyOfRange(strings, 1, strings.length)); Collections.reverse(withOutHeader); return StringUtils.join(withOutHeader, lineSeparator); }
From source file:com.aliyun.odps.mapred.bridge.LotTaskUDTF.java
public LotTaskUDTF() { URL url = this.getClass().getClassLoader().getResource("jobconf.xml"); if (url == null) { URL[] urls = ((URLClassLoader) this.getClass().getClassLoader()).getURLs(); throw new RuntimeException( "Job configure file jobconf.xml not found. Classpath:" + StringUtils.join(urls, ":")); }//from ww w . j av a2s . c o m conf = new BridgeJobConf(false); conf.addResource("jobconf.xml"); }
From source file:com.ctrip.infosec.rule.rabbitmq.DispatcherMessageSender.java
public void sendToDataDispatcher(RiskFact fact) { Set<DistributionChannel> channels = Configs.getDistributionChannelsByEventPoint(fact.eventPoint); List<String> channelNos = Collections3.extractToList(channels, "channelNo"); channelNos.add(defaultRoutingKey);/*from w ww. jav a 2s . co m*/ String routingKey = "." + StringUtils.join(channelNos, ".") + "."; logger.info(SarsMonitorContext.getLogPrefix() + "routingKey: " + routingKey); boolean withScene = Constants.eventPointsWithScene.contains(fact.eventPoint); if (withScene) { RiskFact factCopy = BeanMapper.copy(fact, RiskFact.class); if (!factCopy.resultsGroupByScene.isEmpty()) { Map<String, Object> finalResult = Maps.newHashMap(); finalResult.put(Constants.riskLevel, 0); finalResult.put(Constants.riskMessage, "PASS"); for (Map<String, Object> rs : factCopy.resultsGroupByScene.values()) { finalResult = compareAndReturn(finalResult, rs); } factCopy.setFinalResult(Maps.newHashMap(finalResult)); factCopy.finalResult.remove(Constants.async); factCopy.finalResult.remove(Constants.timeUsage); } // template.convertAndSend(routingKey, JSON.toJSONString(factCopy)); template.convertAndSend(defaultRoutingKey, JSON.toJSONString(factCopy)); } else { // template.convertAndSend(routingKey, JSON.toJSONString(fact)); template.convertAndSend(defaultRoutingKey, JSON.toJSONString(fact)); } }
From source file:eu.smartfp7.foursquare.utils.Settings.java
protected Settings() { // We load the settings file and parse its JSON only once. try {//w w w . j a v a 2 s. c om JsonParser parser = new JsonParser(); this.settings_json = parser .parse(StringUtils .join(Files.readAllLines(Paths.get("etc/settings.json"), StandardCharsets.UTF_8), " ")) .getAsJsonObject(); } catch (IOException e) { e.printStackTrace(); } }