List of usage examples for org.apache.commons.lang StringUtils replace
public static String replace(String text, String searchString, String replacement)
Replaces all occurrences of a String within another String.
From source file:net.jforum.bbcode.SimpleUrl_TestCase.java
private String html(BBCode bb, String url) { return StringUtils.replace(bb.getReplace(), "$1", url); }
From source file:com.bstek.dorado.core.resource.DefaultResourceManager.java
protected Resource findResource(Locale locale) throws Exception { Resource resource = null;/* w w w . ja va 2s .c o m*/ String path = StringUtils.replace(bundleName, ".", "/"); if (locale != null) { String localeSuffix = '.' + locale.toString(); resource = ResourceUtils.getResource(path + localeSuffix + RESOURCE_FILE_SUFFIX); if (resource != null && resource.exists()) { return resource; } } resource = ResourceUtils.getResource(path + RESOURCE_FILE_SUFFIX); if (resource != null && resource.exists()) { return resource; } return null; }
From source file:com.opengamma.id.ObjectId.java
/** * Parses an {@code ObjectId} from a formatted scheme and value. * <p>/*w w w.j a v a 2s. co m*/ * This parses the identifier from the form produced by {@code toString()} * which is {@code <SCHEME>~<VALUE>}. * * @param str the object identifier to parse, not null * @return the object identifier, not null * @throws IllegalArgumentException if the identifier cannot be parsed */ @FromString public static ObjectId parse(String str) { ArgumentChecker.notEmpty(str, "str"); if (str.contains("~") == false) { str = StringUtils.replace(str, "::", "~"); // leniently parse old data } String[] split = StringUtils.splitByWholeSeparatorPreserveAllTokens(str, "~"); switch (split.length) { case 2: return ObjectId.of(split[0], split[1]); } throw new IllegalArgumentException("Invalid identifier format: " + str); }
From source file:com.hangum.tadpole.rdb.core.editors.main.utils.ExtMakeContentAssistUtil.java
/** * make content assist util//w w w. jav a 2 s . c om * * @param userDB * @param strQuery * @param intPosition * @return */ public String makeContentAssist(final UserDBDAO userDB, String strQuery, final int intPosition) throws Exception { strQuery = StringUtils.replace(strQuery, "\n", " "); String listContentAssist = ""; // ? String[] strPrevArryCursor = SQLTextUtil.findPreCursorObjectArry(strQuery, intPosition); String strCursor = strPrevArryCursor[0] + strPrevArryCursor[1]; if (logger.isDebugEnabled()) logger.debug("\t position text is [" + strCursor + "]"); // ? . String strPrevKeyword = SQLTextUtil.findPrevKeywork(strQuery, intPosition); if (logger.isDebugEnabled()) logger.debug("\t prevous keyword is : [" + strPrevKeyword + "]"); CONTENT_ASSIST_KEYWORD_TYPE prevKeywordType = null; // ? ? . strQuery = StringUtils.removeEnd(StringUtils.trimToEmpty(strQuery), ";") + " "; // ? ? ? ?, ? . if (!"".equals(strPrevKeyword)) { if (SQLConstants.listTableKeywords.contains(strPrevKeyword)) { prevKeywordType = CONTENT_ASSIST_KEYWORD_TYPE.TABLE; } else if (SQLConstants.listColumnKeywords.contains(strPrevKeyword)) { prevKeywordType = CONTENT_ASSIST_KEYWORD_TYPE.COLUMN; } } if (prevKeywordType != null) { if (strCursor.length() == 0) { // ?? ?? . if (prevKeywordType == CONTENT_ASSIST_KEYWORD_TYPE.COLUMN) { if (logger.isDebugEnabled()) logger.debug("==========[0][CURSOR][COLUMN] content assist : "); listContentAssist = getTableColumnAlias(userDB, strQuery, strCursor); // ? ?? . } else { if (logger.isDebugEnabled()) logger.debug("==========[0][CURSOR][TABLE] content assist : "); // insert ? ? ? . listContentAssist = ifInsertGetColumn(userDB, strQuery, strCursor); // ? ? ?? . if ("".equals(listContentAssist)) { listContentAssist = getSchemaOrTableContentAssist(userDB, strPrevArryCursor); } } if (logger.isDebugEnabled()) logger.debug("\t result : " + listContentAssist); } else { // ?? ?? . if (prevKeywordType == CONTENT_ASSIST_KEYWORD_TYPE.COLUMN) { if (logger.isDebugEnabled()) logger.debug("+++++++++++[1][DEFAULT][COLUMN] content assist : " + listContentAssist); listContentAssist = getTableColumnAlias(userDB, strQuery, strCursor); } else { // ?, ? ?, ?? . if (logger.isDebugEnabled()) logger.debug("+++++++++++[1][DEFAULT][TABLE] content assist : " + listContentAssist); // insert ? ? ? . listContentAssist = ifInsertGetColumn(userDB, strQuery, strCursor); // ? ? ?? . if ("".equals(listContentAssist)) { listContentAssist = getSchemaOrTableContentAssist(userDB, strPrevArryCursor); } } if (logger.isDebugEnabled()) logger.debug("\t result : " + listContentAssist); } } else { if (logger.isDebugEnabled()) logger.debug("[NONE] content assist : " + listContentAssist); } return listContentAssist; }
From source file:com.runstate.util.XmlW.java
static public String escapeXml(String str) { str = StringUtils.replace(str, "&", "&"); str = StringUtils.replace(str, "<", "<"); str = StringUtils.replace(str, ">", ">"); str = StringUtils.replace(str, "\"", """); str = StringUtils.replace(str, "'", "'"); return str;//from w ww.j av a 2 s. c om }
From source file:cn.cuizuoli.gotour.utils.HtmlHelper.java
/** * toList/*from www . j av a 2 s . c o m*/ * @param text * @return */ public static String toList(String text) { String[] lines = StringUtils.split(text, "\r\n"); StringBuffer listBuffer = new StringBuffer(); listBuffer.append("<ul>").append("\n"); for (String line : lines) { Matcher listMatcher = LIST_PATTERN.matcher(line); if (listMatcher.matches()) { String li = listMatcher.group(1) + listMatcher.group(2); if (StringUtils.contains(li, "")) { li = "<strong>" + StringUtils.replace(li, "", "</strong>"); } listBuffer.append("<li>").append(li).append("</li>").append("\n"); } } listBuffer.append("</ul>").append("\n"); return listBuffer.toString(); }
From source file:com.sfs.Formatter.java
/** * To percent.//from ww w .j a v a2s. c om * * @param value the value * @param decimalPlaces the decimal places * @param suffix the suffix * * @return the string */ public static String toPercent(final double value, final int decimalPlaces, final String suffix) { final int multiplier = 100; String percent = String.valueOf(round(value * multiplier, decimalPlaces)); // If it ends with .0 then remove the tail if (percent.endsWith(".0")) { percent = StringUtils.replace(percent, ".0", ""); } if (StringUtils.isNotBlank(suffix)) { percent += suffix; } return percent; }
From source file:com.googlecode.jtiger.modules.ecside.util.ExportViewUtils.java
public static String escapeChars(String value) { if (StringUtils.isBlank(value)) return ""; if (StringUtils.contains(value, "&")) { value = StringUtils.replace(value, "&", "&"); }/*from w w w .j av a2 s. c o m*/ if (StringUtils.contains(value, ">")) { value = StringUtils.replace(value, ">", ">"); } if (StringUtils.contains(value, "<")) { value = StringUtils.replace(value, "<", "<"); } return value; }
From source file:com.nec.servlet.view.velocity.VelocityMultipleViewResolver.java
@Override protected AbstractUrlBasedView buildView(final String viewName) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Building view using multiple layout resolver. View name is {}", viewName); }//from ww w. j a v a 2s . c o m VelocityLayoutView view = (VelocityLayoutView) super.buildView(viewName); if (layoutKey != null) { view.setLayoutKey(layoutKey); } if (screenContentKey != null) { view.setScreenContentKey(screenContentKey); } if (!this.mappings.isEmpty()) { for (Map.Entry<String, String> entry : this.mappings.entrySet()) { // Correct wildcards so that we can use the matches method in the String object String mappingRegexp = StringUtils.replace(entry.getKey(), "*", ".*"); // If the view matches the regexp mapping if (viewName.matches(mappingRegexp)) { if (logger.isDebugEnabled()) { logger.debug(" Found matching view. Setting layout url to {}", entry.getValue()); } view.setLayoutUrl(entry.getValue()); return view; } } } return view; }
From source file:immf.Util.java
public static String reverseReplaceUnicodeMapping(String s) { s = StringUtils.replace(s, "\u301c", "\uff5e"); s = StringUtils.replace(s, "\u2016", "\u2225"); s = StringUtils.replace(s, "\u2212", "\uff0d"); s = StringUtils.replace(s, "\u00a2", "\uffe0"); s = StringUtils.replace(s, "\u00a3", "\uffe1"); s = StringUtils.replace(s, "\u00ac", "\uffe2"); s = StringUtils.replace(s, "\u2014", "\u2015"); // UTF-8? ?(1)?Shift_JIS?????????(2)?? s = StringUtils.replace(s, "\u3094", "?"); // ?????????? s = StringUtils.replace(s, "\u00ab", "\u226a"); // ?? s = StringUtils.replace(s, "\u00af", "\uffe3"); // ?? s = StringUtils.replace(s, "\u00b5", "\u03bc"); // ?? s = StringUtils.replace(s, "\u00b7", "\u30fb"); // ?? s = StringUtils.replace(s, "\u00b8", "\uff0c"); // ?? s = StringUtils.replace(s, "\u00bb", "\u226b"); // ?? s = StringUtils.replace(s, "\u203e", "\u007e"); // ?~? return s;/*w w w. j a v a2s . com*/ }