List of usage examples for org.apache.commons.lang StringUtils replaceOnce
public static String replaceOnce(String text, String searchString, String replacement)
Replaces a String with another String inside a larger String, once.
From source file:com.enonic.cms.core.search.query.QueryFieldNameResolver.java
private static String doNormalizeQueryFieldName(final String fieldName) { String normalizedFieldName = IndexFieldnameNormalizer.normalizeFieldName(fieldName); if (StringUtils.startsWith(normalizedFieldName, CONTENTDATA_PREFIX_ALIAS_FOR_BW_COMPATABILITY)) { normalizedFieldName = StringUtils.replaceOnce(normalizedFieldName, CONTENTDATA_PREFIX_ALIAS_FOR_BW_COMPATABILITY, CONTENTDATA_PREFIX); }/* w ww . j a va2s . c o m*/ if (StringUtils.startsWith(normalizedFieldName, ATTACHMENT_ALIAS_FOR_BW_COMPATABILITY)) { normalizedFieldName = StringUtils.replaceOnce(normalizedFieldName, ATTACHMENT_ALIAS_FOR_BW_COMPATABILITY, ATTACHMENT_FIELDNAME); } return normalizedFieldName; }
From source file:com.hangum.tadpole.db.bander.oracle.OracleExecutePlanUtils.java
/** * oracle query plan? . /*www . j a v a 2 s. co m*/ * * @param userDB * @param sql * @param planTableName * @throws Exception */ public static void plan(UserDBDAO userDB, String sql, String planTableName, java.sql.Connection javaConn, PreparedStatement stmt, String statement_id) throws Exception { String query = PartQueryUtil.makeExplainQuery(userDB, sql); query = StringUtils.replaceOnce(query, PublicTadpoleDefine.STATEMENT_ID, statement_id); query = StringUtils.replaceOnce(query, PublicTadpoleDefine.DELIMITER, planTableName); stmt = javaConn.prepareStatement(query); stmt.execute(); }
From source file:com.hangum.tadpole.commons.util.NumberFormatUtils.java
/** * , ??.// w w w . j av a 2s. c o m * @param value * @return */ public static String commaFormat(double value) { // String tmpVal = String.format("%.2f", value); DecimalFormat df = new DecimalFormat("#,###.##"); String tmpVal = df.format(value).toString(); if (-1 == StringUtils.indexOf(tmpVal, ".00")) { return tmpVal; } else { return StringUtils.replaceOnce(tmpVal, ".00", ""); } }
From source file:com.hangum.tadpole.rdb.core.editors.main.utils.plan.OracleExecutePlanUtils.java
/** * oracle query plan? . //w ww.j a va 2 s . c om * * @param userDB * @param reqQuery * @param planTableName * @throws Exception */ public static void plan(UserDBDAO userDB, RequestQuery reqQuery, String planTableName, java.sql.Connection javaConn, String statement_id) throws Exception { PreparedStatement pstmt = null; try { String query = PartQueryUtil.makeExplainQuery(userDB, reqQuery.getSql()); query = StringUtils.replaceOnce(query, PublicTadpoleDefine.STATEMENT_ID, statement_id); query = StringUtils.replaceOnce(query, PublicTadpoleDefine.DELIMITER, planTableName); pstmt = javaConn.prepareStatement(query); if (reqQuery.getSqlStatementType() == SQL_STATEMENT_TYPE.PREPARED_STATEMENT) { final Object[] statementParameter = reqQuery.getStatementParameter(); for (int i = 1; i <= statementParameter.length; i++) { pstmt.setObject(i, statementParameter[i - 1]); } } pstmt.execute(); } finally { try { if (pstmt != null) pstmt.close(); } catch (Exception e) { } } }
From source file:com.hangum.tadpole.rdb.core.util.bander.oracle.OracleExecutePlanUtils.java
/** * oracle query plan? . // ww w . j a va 2 s. c o m * * @param userDB * @param sql * @param planTableName * @throws Exception */ public static void plan(UserDBDAO userDB, String sql, String planTableName, java.sql.Connection javaConn, PreparedStatement stmt, String statement_id) throws Exception { //java.sql.Connection javaConn = null; //PreparedStatement stmt = null; //ResultSet rs = null; try { //SqlMapClient client = TadpoleSQLManager.getInstance(userDB); //javaConn = client.getDataSource().getConnection(); String query = PartQueryUtil.makeExplainQuery(userDB, sql); query = StringUtils.replaceOnce(query, PublicTadpoleDefine.STATEMENT_ID, statement_id); query = StringUtils.replaceOnce(query, PublicTadpoleDefine.DELIMITER, planTableName); stmt = javaConn.prepareStatement(query); //stmt = javaConn.prepareStatement( StringUtils.replaceOnce(PartQueryUtil.makeExplainQuery(userDB, sql), PublicTadpoleDefine.DELIMITER, planTableName)); stmt.execute(); } finally { //if(rs != null) rs.close(); //if(stmt != null) stmt.close(); //if(javaConn != null) javaConn.close(); } }
From source file:eionet.cr.staging.util.ImportExportLogUtil.java
/** * Formats the given import log line for display in the browser. * * @param line The log line./*w w w . ja va2 s .c o m*/ * @return The log line formatted. */ public static String formatLogLineForDisplay(String line) { String start = Level.WARN + ":"; if (line.startsWith(start)) { StringUtils.replaceOnce(line, start, "<span style=\"color:#F5B800\">" + start + "</span>"); } start = Level.ERROR + ":"; if (line.startsWith(start)) { StringUtils.replaceOnce(line, start, "<span style=\"color:#FF0000\">" + start + "</span>"); } return StringUtils.replace(line, "\t", " "); }
From source file:info.magnolia.module.admininterface.AdminTreeMVCServlet.java
/** * @see info.magnolia.cms.servlets.MVCServlet#getHandler(javax.servlet.http.HttpServletRequest) *//*from w w w. j a v a 2s .co m*/ protected MVCServletHandler getHandler(HttpServletRequest request, HttpServletResponse response) { String handlerName = request.getRequestURI(); handlerName = StringUtils.replaceOnce(StringUtils.substringAfterLast(handlerName, "/trees/"), ".html", StringUtils.EMPTY); return TreeHandlerManager.getInstance().getTreeHandler(handlerName, request, response); }
From source file:cn.cuizuoli.gotour.utils.HtmlHelper.java
/** * toTable//from w ww. j a v a 2 s.c o m * @param text * @return */ public static String toTable(String text) { String[] lines = StringUtils.split(text, "\r\n"); StringBuffer tableBuffer = new StringBuffer(); for (String line : lines) { Matcher tileMatcher = TITLE_PATTERN.matcher(line); if (tileMatcher.matches()) { String h4 = new StringBuffer().append("<h4>").append(tileMatcher.group(1)).append("</h4>") .append("\n").append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">") .append("\n").toString(); tableBuffer.append(h4); } Matcher tableMatcher = TABLE_PATTERN.matcher(line); if (tableMatcher.matches()) { String tr = new StringBuffer().append("<tr>").append("\n").append("<th>") .append(tableMatcher.group(1)).append("</th>").append("\n").append("<td>") .append(tableMatcher.group(2)).append("</td>").append("\n").append("</tr>").append("\n") .toString(); tableBuffer.append(tr); } } tableBuffer.append("</table>\n"); String table = tableBuffer.toString(); table = StringUtils.replace(table, "<h4>", "</table>\n<h4>"); table = StringUtils.replaceOnce(table, "</table>\n<h4>", "<h4>"); if (!StringUtils.contains(table, "<table")) { table = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n" + table; } return table; }
From source file:edu.sampleu.demo.kitchensink.UITestPropertyEditor.java
/** * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String) *//*from w ww . j av a2 s.c o m*/ @Override public void setAsText(String text) { String value = text; if (StringUtils.contains(value, "-")) { value = StringUtils.replaceOnce(value, "-", ""); } this.setValue(value); }
From source file:kr.co.aim.nanoframe.orm.SQLLogUtil.java
public static String getLogFormatSqlStatement(String sql, Object args, Log log) { try {//from w ww . j a va2 s . c om if (args instanceof Map) { Map<String, Object> map = (Map<String, Object>) args; TreeMap<String, Object> treeMap = new TreeMap<String, Object>(stringComparator); treeMap.putAll(map); Iterator<Entry<String, Object>> iter = treeMap.entrySet().iterator(); while (iter.hasNext()) { Entry<String, Object> entry = iter.next(); sql = sql.replace(":" + entry.getKey(), getLogFormatArgument(entry.getValue())); } } else if (args instanceof Object[]) { Object[] objs = (Object[]) args; for (Object obj : objs) { sql = StringUtils.replaceOnce(sql, "?", getLogFormatArgument(obj)); } } } catch (Throwable t) { if (log.isDebugEnabled()) log.error(t, t); else log.error(t); } return sql; }