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:com.googlecode.fascinator.portal.velocity.JythonLogger.java
public JythonLogger(String name) { String packageName = getClass().getPackage().getName(); String scriptName = StringUtils.substringBetween(name, "scripts/", ".py"); scriptName = scriptName.replace("/", "$") + "$py"; // log.debug("scriptName:{}", scriptName); jythonLogger = LoggerFactory.getLogger(packageName + "." + scriptName); dirty = false;/* w ww .j a v a 2 s. co m*/ buffer = new StringBuilder(); }
From source file:model.Times.java
protected void parseValue(final String value) { try {//from w w w . j av a 2 s. c o m setUserTime(Double.parseDouble(StringUtils.substringBetween(value, "user=", " "))); setSysTime(Double.parseDouble(StringUtils.substringBetween(value, "sys=", ","))); setRealTime(Double.parseDouble(StringUtils.substringBetween(value, "real=", " "))); LOG.info("Successfully parsed Times: " + this); } catch (final Exception ex) { LOG.error("Error parsing TIMES: ", ex); } }
From source file:com.mmounirou.spotirss.provider.Billboard.java
@Override @Nullable/* w w w. jav a2 s . c om*/ public Track apply(@Nullable String strTitle) { int rankPos = strTitle.indexOf(":"); String strRank = strTitle.substring(0, rankPos); String strArtistName = strTitle.substring(rankPos + 1); String strDefaultTitle = strArtistName.substring(0, strArtistName.lastIndexOf(",")); String strDefaultArtist = strArtistName.substring(strArtistName.lastIndexOf(",") + 1); String strSong = StringUtils.remove(strDefaultTitle, String.format("(%s)", StringUtils.substringBetween(strDefaultTitle, "(", ")"))); String strArtist = strDefaultArtist; final Set<String> artistNames = StringTools.split(strArtist, new String[] { "Featuring", "Feat\\.", "feat\\.", "&", "," }); return new Track(Integer.parseInt(strRank), artistNames, strSong); }
From source file:com.google.resting.component.impl.URLContext.java
private void constructContextPath(String restUrl) { this.targetDomain = StringUtils.substringBetween(restUrl, URL_SEPARATOR, SEPARATOR); this.contextPath = StringUtils.substringAfter(restUrl, targetDomain); if (restUrl.startsWith(RequestConstants.HTTPS)) this.isSecureInvocation = true; removeEnd();/* ww w . j a v a 2 s . c o m*/ // System.out.println("url is "+targetDomain); // System.out.println("context path is "+contextPath); }
From source file:com.mmounirou.spotirss.provider.Apple.java
@Override @Nullable//from w w w.java 2s.co m public Track apply(@Nullable String strTitle) { int rankPos = strTitle.indexOf("."); String strRank = strTitle.substring(0, rankPos); String strArtistAndSong = strTitle.substring(rankPos + 1); String strTempSong = strArtistAndSong.substring(0, strArtistAndSong.lastIndexOf(" - ")); String strTempArtist = strArtistAndSong.substring(strArtistAndSong.lastIndexOf(" - ") + 2); String strSong = strTempSong; strSong = StringUtils.remove(strSong, String.format("(%s)", StringUtils.substringBetween(strSong, "(", ")"))); strSong = StringUtils.remove(strSong, String.format("[%s]", StringUtils.substringBetween(strSong, "[", "]"))); String strArtist = strTempArtist; String strfeaturing = StringUtils.trimToEmpty(StringUtils.substringBetween(strTempSong, "(", ")")); if (strfeaturing.contains("feat.")) { strArtist = strArtist + " " + strfeaturing; } strfeaturing = StringUtils.trimToEmpty(StringUtils.substringBetween(strTempSong, "[", "]")); if (strfeaturing.contains("feat.")) { strArtist = strArtist + " " + strfeaturing; } final Set<String> artistNames = StringTools.split(strArtist, new String[] { "Featuring", "Feat\\.", "feat\\.", "&", "," }); return new Track(Integer.parseInt(strRank), artistNames, strSong); }
From source file:com.hangum.tadpole.mongodb.core.utils.MongoDBTableColumn.java
/** * mongodb table column /*from www. j a va 2 s.co m*/ * * @param indexInfo * @param dbObject * @return */ public static List<CollectionFieldDAO> tableColumnInfo(List<DBObject> indexInfo, DBObject dbObject) { Map<String, Boolean> mapIndex = new HashMap<String, Boolean>(); // key list parsing for (DBObject indexObject : indexInfo) { String realKey = StringUtils.substringBetween(indexObject.get("key").toString(), "\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ mapIndex.put(realKey, true); } // column info List<CollectionFieldDAO> retColumns = new ArrayList<CollectionFieldDAO>(); try { // ? ? ? .. if (dbObject == null) return retColumns; Set<String> names = dbObject.keySet(); for (String name : names) { CollectionFieldDAO column = new CollectionFieldDAO(name, dbObject.get(name) != null ? dbObject.get(name).getClass().getSimpleName() : "Unknow", //$NON-NLS-1$ mapIndex.get(name) != null ? "YES" : "NO"); //$NON-NLS-1$ //$NON-NLS-2$ // ??? ? ? if (dbObject.get(name) instanceof BasicDBObject) { makeTableColumn(column, (BasicDBObject) dbObject.get(name)); } retColumns.add(column); } } catch (Exception e) { logger.error("get MongoDB table column info", e); //$NON-NLS-1$ } return retColumns; }
From source file:com.aionemu.packetsamurai.parser.valuereader.ClientStringReader.java
public static void load() { //PacketSamurai.getUserInterface().log("Loading Client strings... Please wait."); Util.drawTitle("Client Strings"); File stringsFolder = new File("./data/client_strings"); if (!stringsFolder.exists()) { stringsFolder.mkdir();//from w ww .ja v a2 s .com } try { File[] files = stringsFolder.listFiles(); File[] arrayOfFile1; int j = (arrayOfFile1 = files).length; for (int i = 0; i < j; i++) { File sFile = arrayOfFile1[i]; File xml = new File(sFile.getPath()); String stringFile = FileUtils.readFileToString(xml); String[] strings = StringUtils.substringsBetween(stringFile, "<string>", "</string>"); if (strings != null) { String[] arrayOfString1; int m = (arrayOfString1 = strings).length; for (int k = 0; k < m; k++) { String string = arrayOfString1[k]; int stringId = Integer.parseInt(StringUtils.substringBetween(string, "<id>", "</id>")); String stringBody = StringUtils.substringBetween(string, "<body>", "</body>"); stringsById.put(Integer.valueOf(stringId), stringBody); } } } PacketSamurai.getUserInterface().log( "Strings [Client] - Loaded " + stringsById.size() + " strings from " + files.length + " Files"); } catch (IOException e) { PacketSamurai.getUserInterface().log("ERROR: Failed to load client_strings.xsd: " + e.toString()); e.printStackTrace(); } }
From source file:jef.database.wrapper.clause.SelectPart.java
public void appendNoGroupFunc(StringBuilder sb) { sb.append("select "); if (distinct) sb.append("distinct "); Set<String> alreadyField = new HashSet<String>(); List<String> columns = new ArrayList<String>(); for (CommentEntry entry : entries) { String column;/*from w ww . ja va 2s . c o m*/ if (entry.getKey().indexOf('(') > 0) { column = StringUtils.substringBetween(entry.getKey(), "(", ")"); } else { column = entry.getKey(); } int point = column.indexOf('.'); String key = point == -1 ? column : column.substring(point + 1); if ("*".equals(key)) { columns.clear(); columns.add(column); break; } if (!alreadyField.contains(key)) { alreadyField.add(key); columns.add(column); } } Iterator<String> iter = columns.iterator(); sb.append(iter.next()); for (; iter.hasNext();) { sb.append(',').append(iter.next()); } if (ORMConfig.getInstance().isFormatSQL() && columns.size() > 1) { sb.append("\n"); } }
From source file:com.adobe.acs.tools.csv_asset_importer.impl.Column.java
public Column(final String raw, final int index) { this.index = index; this.raw = StringUtils.trim(raw); String paramsStr = StringUtils.substringBetween(raw, "{{", "}}"); String[] params = StringUtils.split(paramsStr, ":"); if (StringUtils.isBlank(paramsStr)) { this.relPropertyPath = this.getRaw(); } else {//from w w w . jav a 2 s. c o m this.relPropertyPath = StringUtils.trim(StringUtils.substringBefore(this.getRaw(), "{{")); if (params.length == 2) { this.dataType = nameToClass(StringUtils.stripToEmpty(params[0])); this.multi = StringUtils.equalsIgnoreCase(StringUtils.stripToEmpty(params[1]), MULTI); } if (params.length == 1) { if (StringUtils.equalsIgnoreCase(MULTI, StringUtils.stripToEmpty(params[0]))) { this.multi = true; } else { this.dataType = nameToClass(StringUtils.stripToEmpty(params[0])); } } } if (StringUtils.contains(this.relPropertyPath, "/")) { this.propertyName = StringUtils.trim(StringUtils.substringAfterLast(this.relPropertyPath, "/")); } else { this.propertyName = StringUtils.trim(this.relPropertyPath); } }
From source file:com.enonic.cms.business.portal.rendering.tracing.TraceMarkerHelper.java
public static String unwrapResultWithPortletMarker(RenderedWindowResult result) { String content = result.getContent(); String contentUnwrapped = StringUtils.substringBetween(content, "<div id=\"marker-", "</div>"); if (contentUnwrapped != null) { return StringUtils.substringAfter(contentUnwrapped, ">"); } else {/*from w ww . ja v a 2 s. c om*/ return content; } }