List of usage examples for org.apache.commons.lang StringUtils substringBetween
public static String substringBetween(String str, String open, String close)
Gets the String that is nested in between two Strings.
From source file:feedsplugin.FeedsPlugin.java
private void addFeedKeywords(final SyndFeed feed) { final Iterator<?> iterator = feed.getEntries().iterator(); while (iterator.hasNext()) { final SyndEntry entry = (SyndEntry) iterator.next(); String feedTitle = entry.getTitle(); // index title or parts for (String[] delimiter : TITLE_DELIMITERS) { String titlePart = StringUtils.substringBetween(feedTitle, delimiter[0], delimiter[1]); if (titlePart != null && !titlePart.isEmpty()) { feedTitle = titlePart;//w w w . j av a2 s.c om break; } } addFeedKey(feedTitle, entry, feed); // index description parts SyndContent cont = entry.getDescription(); String desc = null; if (cont != null) { desc = cont.getValue(); } if (desc != null) { for (String[] delimiter : TITLE_DELIMITERS) { if (desc.contains(delimiter[0])) { String[] descParts = StringUtils.substringsBetween(desc, delimiter[0], delimiter[1]); if (descParts != null) { for (String descPart : descParts) { if (!descPart.isEmpty()) { addFeedKey(descPart, entry, feed); } } break; } } } } } }
From source file:com.balero.models.BlogDAO.java
@Transactional public String postTitle(int id) { String postitle = null;//from www .ja v a 2 s. co m Session session = sessionFactory.getCurrentSession(); List<Blog> Blog = session.createQuery("from Blog where id = '" + id + "'").list(); for (Blog obj : Blog) { postitle = obj.getPosttitle(); } String title = null; title = StringUtils.substringBetween(postitle, "<h3>", "</h3>"); if (title == null) { title = StringUtils.substringBetween(postitle, "<p>", "</p>"); } return StringUtils.abbreviate(title + "...", 150); }
From source file:com.blackducksoftware.tools.commonframework.standard.email.CFEmailNotifier.java
/** * Populates the internal value map containing only those variables that * have specifically been provided in the template. * * @param projectInfo/*from w w w. ja v a 2s . c om*/ * @param templateString * **Absolute Path** of the template file. * @throws CommonFrameworkException */ @Override public EmailContentMap configureContentMap(String templateFileLocation) throws CommonFrameworkException { emailContentMap = new EmailContentMap(); this.templateFileLocation = templateFileLocation; try { String templateBody = getBodyTemplate(); // Run through our template and find all the variables // We are looking for all Velocity templates defined as: ${var} String regExPattern = "\\$\\{(\\s*?.*?)*?\\}"; Pattern pattern = Pattern.compile(regExPattern); Matcher matcher = pattern.matcher(templateBody); // Find all matches while (matcher.find()) { // Get the matching string String match = matcher.group(); String strippedDownVariable = StringUtils.substringBetween(match, "${", "}"); log.debug("Found template match: " + strippedDownVariable); strippedDownVariable = strippedDownVariable.trim(); emailContentMap.put(strippedDownVariable, null); } } catch (Exception e) { ready = false; log.error("Problem parsing template: " + e.getMessage()); } return emailContentMap; }
From source file:com.bstek.dorado.view.config.attachment.AttachedJavaScriptResourceManager.java
protected void registerIncludeDataType(OutputContext context, String expression) throws Exception { String dataTypeName = StringUtils.substringBetween(expression, "@", "."); if (StringUtils.isEmpty(dataTypeName)) { return;/*from w ww .j a v a 2 s. c o m*/ } ViewConfig viewConfig = context.getCurrentView().getViewConfig(); if (viewConfig == null) { return; } DataType dataType = viewConfig.getDataType(dataTypeName); if (dataType != null) { context.markIncludeDataType(dataType); } }
From source file:com.hangum.tadpole.rdb.erd.core.relation.RelationUtil.java
/** * sqlite? relation? .//from w w w. j a v a2 s. co m * * @param userDB * @return */ private static List<ReferencedTableDAO> makeSQLiteRelation(UserDBDAO userDB) { List<ReferencedTableDAO> listRealRefTableDAO = new ArrayList<ReferencedTableDAO>(); try { // ? ?. for (SQLiteRefTableDAO sqliteRefTableDAO : getSQLiteRefTbl(userDB)) { String strFullTextSQL = sqliteRefTableDAO.getSql(); if (logger.isDebugEnabled()) logger.debug("\t full text:" + strFullTextSQL); int indexKey = StringUtils.indexOf(strFullTextSQL, "FOREIGN KEY"); if (indexKey == -1) { indexKey = StringUtils.indexOf(strFullTextSQL, "foreign key"); if (indexKey == -1) { if (logger.isDebugEnabled()) logger.debug("Not found foreign keys."); continue; } } String forKey = sqliteRefTableDAO.getSql().substring(indexKey); if (logger.isDebugEnabled()) logger.debug("\t=================>[forKeys]\n" + forKey); String[] foreignInfo = forKey.split("FOREIGN KEY"); if (foreignInfo.length == 1) foreignInfo = forKey.split("foreign key"); for (int i = 1; i < foreignInfo.length; i++) { try { String strForeign = foreignInfo[i]; if (logger.isDebugEnabled()) logger.debug("\t ==========================> sub[\n" + strForeign + "]"); ReferencedTableDAO ref = new ReferencedTableDAO(); // ? ref.setTable_name(sqliteRefTableDAO.getTbl_name()); // , ( ) ??... String colName = StringUtils.substringBetween(strForeign, "(", ")"); // ?, REFERENCES ? ( String refTbName = StringUtils.substringBetween(strForeign, "REFERENCES", "("); if ("".equals(refTbName) || null == refTbName) refTbName = StringUtils.substringBetween(strForeign, "references", "("); // , refTbName? ?? ) ... String refCol = StringUtils.substringBetween(strForeign, refTbName + "(", ")"); ref.setColumn_name(moveSpec(colName)); ref.setReferenced_table_name(moveSpec(refTbName)); ref.setReferenced_column_name(moveSpec(refCol)); // sqlite ?? ? .... ?. ref.setConstraint_name(ref.toString()); listRealRefTableDAO.add(ref); } catch (Exception e) { logger.error("SQLLite Relation making", e); } } // inner if } // last for } catch (Exception e) { logger.error("SQLite Relation check 2", e); } return listRealRefTableDAO; }
From source file:com.zb.app.biz.service.WeixinTest.java
public String getFakeid(String openid) { if (isLogin) { GetMethod get = new GetMethod("https://mp.weixin.qq.com/cgi-bin/contactmanage?t=user/index&token=" + token + "&lang=zh_CN&pagesize=10&pageidx=0&type=0"); get.setRequestHeader("Cookie", this.cookiestr); get.setRequestHeader("Host", "mp.weixin.qq.com"); get.setRequestHeader("Referer", "https://mp.weixin.qq.com/cgi-bin/message?t=message/list&count=20&day=7&token=" + token + "&lang=zh_CN"); get.setRequestHeader("Content-Type", "text/html;charset=UTF-8"); try {// w w w. j a va 2 s . c om int code = httpClient.executeMethod(get); System.out.println(code); if (HttpStatus.SC_OK == code) { System.out.println("Fake Success"); String str = get.getResponseBodyAsString(); System.out.println(str.length()); // String userjson = StringUtils.substringBetween(str, // "<script id=\"json-friendList\" type=\"json/text\">", "</script>"); String userjson = StringUtils.substringBetween(str, "\"contacts\":", "})"); System.out.println(userjson); JSONParser parser = new JSONParser(); try { JSONArray array = (JSONArray) parser.parse(userjson); for (int i = 0; i < array.size(); i++) { JSONObject obj = (JSONObject) array.get(i); String fakeid = obj.get("id").toString(); if (compareFakeid(fakeid, openid)) { return fakeid; } } } catch (Exception e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } else { login(); return getFakeid(openid); } return null; }
From source file:com.micro.rent.common.comm.aio.AsyncClientHttpExchangeFutureCallback.java
public static String duration(String responseString) { String status = StringUtils.substringBetween(responseString, "<status>", "</status>"); String duration = "1"; if (!StringUtils.isNumeric(status)) { duration = "0"; }/*from w w w .j ava2 s. c o m*/ if (MSG_OK != Integer.valueOf(status).intValue()) { log.info("baidu map redirect error:" + StringUtils.substringBetween(responseString, "<message>", "</message>")); } else { duration = StringUtils.substringBetween(responseString, "<duration>", "</duration>"); // duration=StringUtil.secondToHm(Double.valueOf(duration) // .intValue()); } return duration; }
From source file:mediathekplugin.Database.java
private Channel findChannel(final String mediathekChannelName) { Object result = mNameMapping.get(mediathekChannelName); if (result == NON_EXISTING_CHANNEL) { return null; }//from w ww . j a v a 2s.c o m if (result == null) { Channel[] allChannels = Plugin.getPluginManager().getSubscribedChannels(); for (Channel channel : allChannels) { if (channel.getName().equalsIgnoreCase(mediathekChannelName) || StringUtils.startsWithIgnoreCase(channel.getName(), mediathekChannelName + " ")) { mNameMapping.put(mediathekChannelName, channel); return channel; } String namePart = StringUtils.substringBetween(channel.getName(), "(", ")"); if (StringUtils.isNotEmpty(namePart)) { mNameMapping.put(mediathekChannelName, channel); return channel; } } mNameMapping.put(mediathekChannelName, NON_EXISTING_CHANNEL); LOG.info("Ignored Mediathek channel: " + mediathekChannelName); return null; } return (Channel) result; }
From source file:com.prowidesoftware.swift.model.field.FieldTest.java
@Test //TODO add API for partyfields structure like field 83J public void testGetValueByCodewordWorkaround() { final Field83J f = new Field83J("/ACCT/006-6005XXXXXX\n/NAME/JF ASIAN TOTAL RETURN BOND FUND"); assertEquals("006-6005XXXXXX", StringUtils.substringBetween(f.getComponent1(), "/ACCT/", "\n")); }
From source file:net.poemerchant.scraper.ShopScraper.java
private String scrapeItemJSArray(Document doc) { Element scriptDataElem = doc.select("script").last(); // a with href String raw = scriptDataElem.data(); raw = StringUtils.substringBetween(raw, "new R(", ")).run();"); return raw;/*from w w w. j a v a 2s . co m*/ }