List of usage examples for org.apache.commons.lang StringUtils split
public static String[] split(String str)
Splits the provided text into an array, using whitespace as the separator.
From source file:com.jnj.b2b.storefront.util.MetaSanitizerUtil.java
/** * Takes a string of words, removes duplicates and returns a comma separated list of keywords as a String * /*from w ww . j av a2 s . c o m*/ * @param keywords * Keywords to be sanitized * @return String of comma separated keywords */ public static String sanitizeKeywords(final String keywords) { final String clean = (StringUtils.isNotEmpty(keywords) ? Jsoup.parse(keywords).text() : ""); // Clean html final String[] words = StringUtils.split(clean.replace("\"", "")); // Clean quotes // Remove duplicates final StringBuffer noDupes = new StringBuffer(); for (final String word : words) { if (noDupes.indexOf(word) == -1) { noDupes.append(word).append(','); } } if (noDupes.length() > 0) { noDupes.deleteCharAt(noDupes.length() - 1); } return noDupes.toString(); }
From source file:com.exxonmobile.ace.hybris.storefront.util.MetaSanitizerUtil.java
/** * Takes a string of words, removes duplicates and returns a comma separated list of keywords as a String * /*from w ww .j ava 2 s.c om*/ * @param keywords * Keywords to be sanitized * @return String of comma separated keywords */ public static String sanitizeKeywords(final String keywords) { final String clean = (StringUtils.isNotEmpty(keywords) ? Jsoup.parse(keywords).text() : ""); // Clean html final String[] words = StringUtils.split(clean.replace("\"", "")); // Clean quotes // Remove duplicates String noDupes = ""; for (final String word : words) { if (!noDupes.contains(word)) { noDupes += word + ','; } } if (!noDupes.isEmpty()) { noDupes = noDupes.substring(0, noDupes.length() - 1); } return noDupes; }
From source file:marytts.server.MaryProperties.java
public static List<String> getList(String propName) { assert propName.endsWith(".list"); List<String> vals = new ArrayList<String>(); // First, anything from system properties: String val = System.getProperty(propName); if (val != null) { vals.addAll(Arrays.asList(StringUtils.split(val))); }/* ww w.j a va 2 s. c o m*/ // Then, anything from the configs: for (MaryConfig mc : MaryConfig.getConfigs()) { vals.addAll(mc.getList(propName)); } return vals; }
From source file:gov.nih.nci.cabig.caaers.dao.query.InvestigatorQuery.java
public void filterByName(final String name) { String[] searchFields = StringUtils.split(name); int i = 0;/*from w w w . j a va2 s. c om*/ if (searchFields != null) { for (String searchField : searchFields) { String searchString = "%" + StringUtils.lowerCase(searchField) + "%"; String firstNameKey = "FIRST_NAME_" + i; String lastNameKey = "LAST_NAME_" + i; String middleNameKey = "MIDDLE_NAME_" + i; andWhere(String.format( "(lower(i.firstName) LIKE :%s OR lower(i.lastName) LIKE :%s OR lower(i.middleName) LIKE :%s)", firstNameKey, lastNameKey, middleNameKey)); setParameter(firstNameKey, searchString); setParameter(lastNameKey, searchString); setParameter(middleNameKey, searchString); i++; } } }
From source file:gov.nih.nci.cabig.caaers.dao.query.SiteResearchStaffQuery.java
public void filterByName(final String name) { String[] searchFields = StringUtils.split(name); int i = 0;/*from w w w. ja v a 2s. co m*/ if (searchFields != null) { for (String searchField : searchFields) { String searchString = "%" + StringUtils.lowerCase(searchField) + "%"; String firstNameKey = "FIRST_NAME_" + i; String lastNameKey = "LAST_NAME_" + i; String middleNameKey = "MIDDLE_NAME_" + i; andWhere(String.format( "(lower(rs.firstName) LIKE :%s OR lower(rs.lastName) LIKE :%s OR lower(rs.middleName) LIKE :%s)", firstNameKey, lastNameKey, middleNameKey)); setParameter(firstNameKey, searchString); setParameter(lastNameKey, searchString); setParameter(middleNameKey, searchString); i++; } } }
From source file:com.opengamma.install.launch.MainRunner.java
protected String[] getParameters(String args) { s_logger.debug("processing args [{}]", args); args = StringUtils.trimToNull(args); final String[] tokens = StringUtils.split(args); String[] result = null;//from w w w . j av a 2 s .com if (tokens != null) { List<String> argList = Lists.newArrayList(); StringBuilder strBuilder = new StringBuilder(); for (String token : tokens) { boolean processed = false; if (token.startsWith("'")) { strBuilder.append(token); processed = true; } if (token.endsWith("'")) { if (strBuilder.length() != 0) { if (!processed) { strBuilder.append(" ").append(token); } argList.add(strBuilder.substring(1, strBuilder.length() - 1)); } else { argList.add(token); } strBuilder = new StringBuilder(); processed = true; } if (!processed) { if (strBuilder.length() == 0) { argList.add(token); } else { strBuilder.append(" ").append(token); } } } if (strBuilder.length() != 0) { argList.addAll(Arrays.asList(StringUtils.split(strBuilder.toString()))); } result = argList.toArray(new String[] {}); } s_logger.debug("processed args {}", ArrayUtils.toString(result)); return result; }
From source file:net.sf.jtmt.summarizers.SummaryAnalyzer.java
/** * Instantiates a new summary analyzer./*from w ww.j a va 2s. co m*/ * * @throws IOException Signals that an I/O exception has occurred. */ public SummaryAnalyzer() throws IOException { String[] stopwords = filterComments(StringUtils.split(FileUtils.readFileToString( new File(getClass().getResource("/resources/jtmt/stopwords.txt").getFile()), "UTF-8"))); this.stopset = StopFilter.makeStopSet(stopwords, true); }
From source file:dk.dma.ais.virtualnet.transponder.StreamTime.java
public String createPstt() { lastSent = System.currentTimeMillis(); String dateStr = DATEFORMAT.format(new Date(getTime())); String[] dateParts = StringUtils.split(dateStr); String sentence = String.format("$PSTT,10A,%s,%s", dateParts[0], dateParts[1]); String checksum = "00"; try {/*ww w. j a v a2 s. c o m*/ checksum = Sentence.getStringChecksum(Sentence.getChecksum(sentence)); } catch (SentenceException e) { e.printStackTrace(); } return sentence + "*" + checksum; }
From source file:acromusashi.stream.example.bolt.SplitSentenceBolt.java
/** * {@inheritDoc}//www . ja v a2s . c o m */ @Override public void execute(Tuple input) { // ????? String sentence = input.getStringByField("message"); String[] words = StringUtils.split(sentence); // ????Tuple????Bolt??? for (String targetWord : words) { getCollector().emit(new Values(targetWord.toLowerCase())); } }
From source file:com.hs.mail.imap.schedule.MessageExpunger.java
private Map<String, Date> getExpungeCriteria(String prop) { String[] tokens = StringUtils.split(prop); int sz = tokens.length / 2; if (sz > 0) { Map<String, Date> criteria = new HashMap<String, Date>(sz); for (int i = 0; i < tokens.length / 2; i++) { Date base = ScheduleUtils.getDateBefore(tokens[i + 1]); if (base != null) { criteria.put(tokens[i], base); }//from ww w . j a v a 2 s .c o m } return criteria; } return null; }