List of usage examples for java.util.regex Matcher appendTail
public StringBuilder appendTail(StringBuilder sb)
From source file:Main.java
public static String getAttributeNameFromColName(String tableName) { Pattern p = Pattern.compile("_+(\\w?)"); Matcher m = p.matcher(tableName); StringBuffer sb = new StringBuffer(); while (m.find()) { if (m.start() != 0) m.appendReplacement(sb, m.group(1).toUpperCase()); else/* ww w .j a va 2 s . co m*/ m.appendReplacement(sb, m.group(1).toLowerCase()); } m.appendTail(sb); return sb.toString(); }
From source file:com.vaadin.sass.internal.visitor.IfElseNodeHandler.java
private static String replaceStrings(String expression) { expression = expression.replaceAll("\"", ""); Matcher m = pattern.matcher(expression); StringBuffer b = new StringBuffer(); while (m.find()) { String group = m.group(); m.appendReplacement(b, "'" + group + "'"); }/*from w w w. j a va2s . c om*/ m.appendTail(b); if (b.length() != 0) { return b.toString(); } return expression; }
From source file:com.gs.obevo.db.impl.platforms.db2.Db2lookReveng.java
public static String removeQuotes(String input) { Pattern compile = Pattern.compile("\"([A-Z_0-9]+)\"", Pattern.DOTALL); StringBuffer sb = new StringBuffer(input.length()); Matcher matcher = compile.matcher(input); while (matcher.find()) { matcher.appendReplacement(sb, matcher.group(1)); }/* w ww . j a va 2s. co m*/ matcher.appendTail(sb); return sb.toString(); }
From source file:org.apache.ode.tools.sendsoap.cline.HttpSoapSender.java
public static String doSend(URL u, InputStream is, String proxyServer, int proxyPort, String username, String password, String soapAction) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(8192); StreamUtils.copy(bos, is);//from w w w.j a v a2 s. com String now = Long.toString(System.currentTimeMillis()); int c = 1; String data = new String(bos.toByteArray()); Matcher m = SEQ.matcher(data); StringBuffer sb = new StringBuffer(8192); while (m.find()) { m.appendReplacement(sb, now + "-" + c++); } m.appendTail(sb); SimpleHttpConnectionManager mgr = new SimpleHttpConnectionManager(); try { mgr.getParams().setConnectionTimeout(60000); mgr.getParams().setSoTimeout(60000); HttpClient httpClient = new HttpClient(mgr); PostMethod httpPostMethod = new PostMethod(u.toExternalForm()); if (proxyServer != null && proxyServer.length() > 0) { httpClient.getState().setCredentials(new AuthScope(proxyServer, proxyPort), new UsernamePasswordCredentials(username, password)); httpPostMethod.setDoAuthentication(true); } if (soapAction == null) soapAction = ""; httpPostMethod.setRequestHeader("SOAPAction", "\"" + soapAction + "\""); httpPostMethod.setRequestHeader("Content-Type", "text/xml"); httpPostMethod.setRequestEntity(new StringRequestEntity(sb.toString())); httpClient.executeMethod(httpPostMethod); return httpPostMethod.getResponseBodyAsString() + "\n"; } finally { mgr.shutdown(); } }
From source file:com.mirth.connect.connectors.jdbc.JdbcUtils.java
/** * Parse the given statement filling the parameter list and return the ready to use statement. * //from ww w .j a va 2 s . c o m * @param statement * @param params * List that will contain the parameters found in the statement * @return The parsed statement */ public static String extractParameters(String statement, List<String> params) { if (statement == null) { return null; } Pattern p = Pattern.compile("\\$\\{([^\\}]*)\\}"); Matcher m = p.matcher(statement); StringBuffer sb = new StringBuffer(); while (m.find()) { String key = m.group(0); m.appendReplacement(sb, "?"); params.add(key); } m.appendTail(sb); return sb.toString(); }
From source file:iox.refused.jhp.JHP_Parser.java
private static void compile(StringBuffer sb, String src) { Matcher m = TEXTLET.matcher(src); while (m.find()) { String name = BSLASHES.matcher(StringEscapeUtils.escapeJava(m.group(2))).replaceAll("\\\\\\\\"); m.appendReplacement(sb, "echo(\"" + name + "\");\n"); }/* w w w.ja va2 s . com*/ m.appendTail(sb); }
From source file:com.github.ibole.infrastructure.persistence.db.mybatis.pagination.SqlHelper.java
/** * orderby ??/*w w w. j a va2 s. c o m*/ * * @param sql sql * @return order by sql */ public static String removeOrders(String sql) { Preconditions.checkNotNull(sql); Pattern p = Pattern.compile(ORDER_BY_REGEX, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(sql); StringBuffer sb = new StringBuffer(sql.length()); while (m.find()) { m.appendReplacement(sb, ""); } m.appendTail(sb); return sb.toString(); }
From source file:iox.refused.jhp.JHP_Parser.java
private static String compileImports(StringBuffer buffer, String src) { Matcher m = IMPORTS.matcher(src); StringBuffer sb = new StringBuffer(); while (m.find()) { String imp = m.group(1);/*w ww. ja v a2 s . c o m*/ buffer.append("import ").append(imp).append(";\n"); m.appendReplacement(sb, ""); } m.appendTail(sb); return sb.toString(); }
From source file:com.github.ibole.infrastructure.persistence.db.mybatis.pagination.SqlHelper.java
public static String removeXsqlBuilderOrders(String string) { Preconditions.checkNotNull(string);//from ww w . j a va 2s . co m Pattern p = Pattern.compile(XSQL_ORDER_BY_REGEX, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(string); StringBuffer sb = new StringBuffer(string.length()); while (m.find()) { m.appendReplacement(sb, ""); } m.appendTail(sb); return removeOrders(sb.toString()); }
From source file:team.curise.dao.BaseDao.java
/** * orderby??/*from w w w. j av a2s . co m*/ * @param hql * @return */ public static String removeOrders(String hql) { Assert.hasText(hql); Pattern p = Pattern.compile("order\\s*by[\\w|\\W|\\s|\\S]*", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(hql); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, ""); } m.appendTail(sb); return sb.toString(); }