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.pureinfo.srm.srm2rpms.action.BuildAction.java
public ActionForward executeAction() throws PureException { //why@2006-12-27 final String sItemFlags = StringUtils.join(request.getParameterValues("data"), ','); logger.debug("data=" + sItemFlags); if (!BuildInfo.isRunning()) { BuildInfo.setRunning(true);//w ww . j av a 2 s.c om new Thread(new Runnable() { public void run() { try { SRM2RPMSImporter.run(sItemFlags); BuildInfo.setSuccess(true); BuildInfo.setUpdateTime(new Date()); BuildInfo.setUpdated(true); BuildInfo.setRunning(false); } catch (Exception e) { try { BuildInfo.setSuccess(false); BuildInfo.setUpdateTime(new Date()); logger.error("build error", e); BuildInfo.setRunning(false); } catch (Exception ex) { logger.error("print error", ex); } } } }).start(); } request.setAttribute("data", sItemFlags); return mapping.findForward("success"); }
From source file:com.dubture.composer.ui.editor.composer.LicenseContentAdapter.java
@Override public void setControlContents(Control control, String text, int cursorPosition) { String id = text.replaceAll(".+\\((.+)\\)$", "$1"); String val = ((Text) control).getText(); String[] chunks = val.split(","); chunks[chunks.length - 1] = id;/*from w w w. ja v a2s .c o m*/ val = StringUtils.join(chunks, ", "); cursorPosition = val.length(); ((Text) control).setText(val); ((Text) control).setSelection(cursorPosition, cursorPosition); }
From source file:edu.vt.vbi.patric.common.FASTAHelper.java
public static String getFASTASequence(PortletRequest request, List<String> featureIds, String type) throws IOException { StringBuilder fasta = new StringBuilder(); SolrQuery query = new SolrQuery("feature_id:(" + StringUtils.join(featureIds, " OR ") + ")"); query.setFields(/*from w w w . ja v a 2 s. c om*/ "feature_id,patric_id,alt_locus_tag,refseq_locus_tag,annotation,gi,product,genome_id,genome_name,na_sequence,aa_sequence"); query.setRows(featureIds.size()); DataApiHandler dataApi = new DataApiHandler(request); LOGGER.trace("getFASTASequence: [{}] {}", SolrCore.FEATURE.getSolrCoreName(), query); String apiResponse = dataApi.solrQuery(SolrCore.FEATURE, query); Map resp = jsonReader.readValue(apiResponse); Map respBody = (Map) resp.get("response"); List<GenomeFeature> features = dataApi.bindDocuments((List<Map>) respBody.get("docs"), GenomeFeature.class); for (GenomeFeature feature : features) { if (type.equals("dna") || type.equals("both")) { fasta.append(">"); if (feature.getAnnotation().equals("PATRIC")) { if (feature.hasPatricId()) { fasta.append(feature.getPatricId()).append("|"); } } else if (feature.getAnnotation().equals("RefSeq")) { if (feature.getGi() > 0) { fasta.append("gi|").append(feature.getGi()).append("|"); } } if (feature.hasRefseqLocusTag()) { fasta.append(feature.getRefseqLocusTag()).append("|"); } if (feature.hasAltLocusTag()) { fasta.append(feature.getAltLocusTag()).append("|"); } if (feature.hasProduct()) { fasta.append(" ").append(feature.getProduct()); } fasta.append(" [").append(feature.getGenomeName()).append(" | ").append(feature.getGenomeId()) .append("]"); fasta.append("\n"); if (feature.hasNaSequence()) { fasta.append(StringHelper.chunk_split(feature.getNaSequence(), 60, "\n")); } } if (type.equals("protein") || type.equals("both")) { fasta.append(">"); if (feature.getAnnotation().equals("PATRIC")) { if (feature.hasPatricId()) { fasta.append(feature.getPatricId()).append("|"); } } else if (feature.getAnnotation().equals("RefSeq")) { if (feature.getGi() > 0) { fasta.append("gi|").append(feature.getGi()).append("|"); } } if (feature.hasRefseqLocusTag()) { fasta.append(feature.getRefseqLocusTag()).append("|"); } if (feature.hasAltLocusTag()) { fasta.append(feature.getAltLocusTag()).append("|"); } if (feature.hasProduct()) { fasta.append(" ").append(feature.getProduct()); } fasta.append(" [").append(feature.getGenomeName()).append(" | ").append(feature.getGenomeId()) .append("]"); fasta.append("\n"); if (feature.hasAaSequence()) { fasta.append(StringHelper.chunk_split(feature.getAaSequence(), 60, "\n")); } } } return fasta.toString(); }
From source file:edu.sampleu.travel.infrastructure.TravelServiceLocator.java
public static synchronized void initialize(boolean test) { if (appContext == null) { final String[] resources; // check if we are running in unit tests, and if so, add the test context resource if (test) { resources = new String[] { STANDARD_CONTEXT, TEST_CONTEXT }; } else {/* w w w .ja v a 2 s.c o m*/ resources = new String[] { STANDARD_CONTEXT }; } LOG.info("Loading contexts: " + StringUtils.join(resources, ", ")); appContext = new ClassPathXmlApplicationContext(resources); } }
From source file:de.dfki.resc28.ole.bootstrap.Util.java
public static Literal toStringLiteral(RuleContext ctx, String separator) { if (ctx != null) { String descr[] = new String[ctx.getPayload().getChildCount()]; for (int i = 0; i < ctx.getPayload().getChildCount(); i++) { descr[i] = ctx.getPayload().getChild(i).getText(); }// www .j a va 2 s . com return ResourceFactory.createTypedLiteral(StringUtils.join(descr, separator), XSDDatatype.XSDstring); } else { return ResourceFactory.createPlainLiteral("Something went wrong!"); } }
From source file:com.baifendian.swordfish.execserver.job.mr.HadoopJarArgsUtil.java
/** * ? <p>/*from w w w .java 2s . c o m*/ * * @return ? */ public static List<String> buildArgs(MrParam param) { List<String> args = new ArrayList<>(); // jar if (StringUtils.isNotEmpty(param.getMainJar().getRes())) { args.add(param.getMainJar().getRes()); } // class if (StringUtils.isNotEmpty(param.getMainClass())) { args.add(param.getMainClass()); } // -D if (param.getDArgs() != null && !param.getDArgs().isEmpty()) { for (String darg : param.getDArgs()) { args.add(String.format("%s%s", HadoopJarArgsConst.D, darg)); } } // -libjars if (param.getLibJars() != null && !param.getLibJars().isEmpty()) { args.add(HadoopJarArgsConst.JARS); args.add(StringUtils.join(param.getLibJars().stream().map(p -> p.getSymbolicRes()).toArray(), ",")); } // -files if (param.getFiles() != null && !param.getFiles().isEmpty()) { args.add(HadoopJarArgsConst.FILES); args.add(StringUtils.join(param.getFiles().stream().map(p -> p.getSymbolicRes()).toArray(), ",")); } // -archives if (param.getArchives() != null && !param.getArchives().isEmpty()) { args.add(HadoopJarArgsConst.ARCHIVES); args.add(StringUtils.join(param.getArchives().stream().map(p -> p.getSymbolicRes()).toArray(), ",")); } // if (StringUtils.isNotEmpty(param.getQueue())) { args.add(String.format("%s%s=%s", HadoopJarArgsConst.D, HadoopJarArgsConst.QUEUE, param.getQueue())); } // ? if (StringUtils.isNotEmpty(param.getArgs())) { args.add(param.getArgs()); } return args; }
From source file:com.dosport.system.utils.ConvertUtils.java
/** * ????(getter), ??.// w ww .jav a 2s. c o m * * @param collection * ???. * @param propertyName * ??????. * @param separator * . */ @SuppressWarnings("rawtypes") public static String convertElementPropertyToString(final Collection collection, final String propertyName, final String separator) { List list = convertElementPropertyToList(collection, propertyName); return StringUtils.join(list, separator); }
From source file:com.swtxml.util.parser.Splitter.java
public String join(Object[] values) { return StringUtils.join(values, preferredSeparator); }
From source file:com.ushahidi.swiftriver.core.solr.util.QueryUtil.java
/** * Given a comma-separated list of search terms; * <code>searchTerms</code>, converts the list to an array * and concatenates the elements using "AND". * //from ww w . j a v a 2s . c o m * If <code>searchTerm</code> comprises of only one string, * no modification takes place * * @param searchTerms * @return */ public static String getQueryString(String searchTerms) { if (searchTerms == null || searchTerms.trim().length() == 0) return "*:*"; List<String> keywordsList = new ArrayList<String>(); // Sanitize the each keyword for (String keyword : searchTerms.split(",")) { if (searchTerms.trim().length() > 1) { keywordsList.add(keyword.trim()); } } String[] keywordsArray = keywordsList.toArray(new String[keywordsList.size()]); return keywordsArray.length == 1 ? searchTerms : StringUtils.join(keywordsArray, " AND "); }
From source file:com.dinochiesa.edgecallouts.util.CalloutUtil.java
public static String getHeaderWithCommas(MessageContext msgCtxt, String headerName) { ArrayList list = msgCtxt.getVariable("request.header." + headerName + ".values"); return StringUtils.join(list, ","); }