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.jslsolucoes.tagria.lib.util.TagUtil.java
public static String localization(JspContext jspContext) { Locale locale = locale(jspContext); List<String> fullLocale = Lists.newArrayList(locale.getLanguage()); if (!StringUtils.isEmpty(locale.getCountry())) { fullLocale.add(locale.getCountry()); }//w ww.jav a 2 s. co m return StringUtils.join(fullLocale, "-"); }
From source file:net.sourceforge.fenixedu.domain.degreeStructure.EctsComparabilityPercentages.java
private double[] extractPercentages(String[] percentages) { try {// w w w . j a v a 2 s . c o m double[] perc = new double[11]; for (int i = 0; i < perc.length; i++) { perc[i] = Double.parseDouble(percentages[i]); } return perc; } catch (NumberFormatException e) { throw new DomainException("error.ects.invalidTable", StringUtils.join(percentages, "<tab>")); } }
From source file:com.netscape.cmstools.tps.token.TokenCLI.java
public static void printToken(TokenData token) { System.out.println(" Token ID: " + token.getID()); if (token.getUserID() != null) System.out.println(" User ID: " + token.getUserID()); if (token.getType() != null) System.out.println(" Type: " + token.getType()); TokenStatusData status = token.getStatus(); if (status != null) System.out.println(" Status: " + status.name); Collection<TokenStatusData> nextStates = token.getNextStates(); if (nextStates != null) { Collection<TokenStatus> names = new ArrayList<TokenStatus>(); for (TokenStatusData nextState : nextStates) { names.add(nextState.name);/*from w w w . ja v a 2 s .com*/ } System.out.println(" Next States: " + StringUtils.join(names, ", ")); } if (token.getAppletID() != null) System.out.println(" Applet ID: " + token.getAppletID()); if (token.getKeyInfo() != null) System.out.println(" Key Info: " + token.getKeyInfo()); if (token.getPolicy() != null) System.out.println(" Policy: " + token.getPolicy()); if (token.getCreateTimestamp() != null) System.out.println(" Date Created: " + token.getCreateTimestamp()); if (token.getModifyTimestamp() != null) System.out.println(" Date Modified: " + token.getModifyTimestamp()); Link link = token.getLink(); if (verbose && link != null) { System.out.println(" Link: " + link.getHref()); } }
From source file:com.github.hexocraft.chestpreview.command.CpCommandRename.java
/** * @param plugin The plugin that this object belong to. */// ww w . j av a 2 s. c o m public CpCommandRename(ChestPreviewPlugin plugin) { super("rename", plugin); this.setAliases(Lists.newArrayList("r")); this.setDescription(StringUtils.join(plugin.messages.cRename, "\n")); this.setPermission(Permissions.ADMIN.toString()); this.addArgument(new CommandArgument<String>("name", ArgTypeString.get(), true)); }
From source file:com.netflix.priam.resources.CassandraConfig.java
@GET @Path("/get_seeds") public Response getSeeds() { try {/*from w ww . jav a 2 s .co m*/ final List<String> seeds = priamServer.getId().getSeeds(); if (!seeds.isEmpty()) return Response.ok(StringUtils.join(seeds, ',')).build(); logger.error("Cannot find the Seeds"); } catch (Exception e) { logger.error("Error while executing get_seeds", e); return Response.serverError().build(); } return Response.status(500).build(); }
From source file:de.thorstenberger.examServer.webapp.form.SystemConfigForm.java
/** * Same contents as {@link #getRadiusMailSuffixes()} but as a single space delimited string. * * @return/* www .j a v a2s . c o m*/ */ public String getRadiusMailSuffixesDelimited() { return StringUtils.join(mailSuffixes, " "); }
From source file:net.lshift.diffa.assets.JstTemplatesPreProcessor.java
public void process(Resource resource, Reader input, Writer output) throws IOException { if (resource.getUri().endsWith(".jst")) { String content = IOUtils.toString(input); String name = removeSuffix(removePrefix(resource.getUri(), "/js/templates/"), ".jst"); output.write("window.JST = (window.JST || {});\n"); output.write(String.format("window.JST['%s'] = _.template(\n", name)); List<String> result = new ArrayList<String>(); for (String l : content.split("\n")) { result.add("\"" + StringEscapeUtils.escapeJava(l) + "\""); }//from w w w . j a v a2s . c o m output.write(StringUtils.join(result.iterator(), " + \n")); output.write(");\n"); } else { IOUtils.copy(input, output); } }
From source file:com.alibaba.otter.shared.arbitrate.impl.zookeeper.ZooKeeperClient.java
private static ZkClientx createClient() { List<String> serveraddrs = getServerAddrs(); return new ZkClientx(StringUtils.join(serveraddrs, ","), sessionTimeout); }
From source file:dkpro.similarity.algorithms.lexical.string.SecondStringComparator_ImplBase.java
@Override public double getSimilarity(Collection<String> s1, Collection<String> s2) throws SimilarityException { if (s1.size() == 0 || s2.size() == 0) { return 0.0; }/*from w w w. j a v a 2 s . co m*/ String concatenatedString1 = StringUtils.join(s1, " "); String concatenatedString2 = StringUtils.join(s2, " "); if (concatenatedString1.length() == 0 || concatenatedString2.length() == 0) { return 0.0; } // find tokens (I know that we already know what the tokens are, but the SecondString implementation needs it that way) StringWrapper wrappedString1 = secondStringMeasureL2.prepare(concatenatedString1); StringWrapper wrappedString2 = secondStringMeasureL2.prepare(concatenatedString2); double distance = secondStringMeasureL2.score(wrappedString1, wrappedString2); return distance; }
From source file:de.tudarmstadt.ukp.dkpro.keyphrases.core.wrapper.BaselineExtractorTest.java
@Ignore @Test/*from w w w . ja v a 2 s. co m*/ public void baselineTest() throws Exception { String testDoc = FileUtils.readFileToString(new File("src/test/resources/keyphrase/extractor/test.txt")); Candidate nounTokens = new Candidate(CandidateType.Token, PosType.N); KeyphraseExtractor_ImplBase positionBaselineExtractor = new PositionBaselineExtractor(); positionBaselineExtractor.setCandidate(nounTokens); String actualKeyphrases = StringUtils.join( keyphraseList2StringList(getTopRankedKeyphrases(positionBaselineExtractor.extract(testDoc), 5)), ","); assertEquals("MPEG,video,rate allocation,rates,bit allocation", actualKeyphrases); }