List of usage examples for java.util.regex Matcher end
public int end(String name)
From source file:com.github.gekoh.yagen.ddl.CreateDDL.java
private String addPartitioning(StringBuffer addDdl, IntervalPartitioning partitioning, String nameLC, String sqlCreate, Set<String> columns, List<String> pkCols) { String shortName = getShortName(nameLC); if (StringUtils.isEmpty(shortName)) { String tblName = getProfile().getNamingStrategy().tableName(nameLC); shortName = (tblName.length() > 27 ? tblName.substring(0, 27) : tblName); }//from w w w. j a v a 2 s. c om String partColName = partitioning.columnName().toLowerCase(); if (!columns.contains(partColName)) { Matcher pkMatcher = TBL_PATTERN.matcher(sqlCreate); if (pkMatcher.find()) { StringBuilder sb = new StringBuilder(); sb.append(sqlCreate.substring(0, pkMatcher.start(TBL_PATTERN_IDX_AFTER_COL_DEF))); sb.append(", ").append(partColName).append(" date default sysdate"); sb.append(sqlCreate.substring(pkMatcher.start(TBL_PATTERN_IDX_AFTER_COL_DEF))); sqlCreate = sb.toString(); columns.add(partColName); } } StringBuilder sb; if (partitioning.useLocalPK()) { sb = new StringBuilder(); Matcher matcher = TBL_PATTERN.matcher(sqlCreate); if (!matcher.find()) { throw new IllegalArgumentException("cannot parse create table statement: " + sqlCreate); } if (matcher.group(TBL_PATTERN_IDX_PK_CLAUSE) != null) { String pkColList = matcher.group(TBL_PATTERN_IDX_PK_COLLIST); if (!pkCols.contains(partColName)) { pkColList += ", " + partColName; } addDdl.append(STATEMENT_SEPARATOR) .append("-- creating local unique index instead of global primary key\n"); addDdl.append("create unique index ").append(getProfile().getNamingStrategy().indexName( getEntityClassName(nameLC), nameLC, DefaultNamingStrategy.concatColumnNames(pkColList))); addDdl.append(" on ").append(nameLC).append("(").append(pkColList).append(") local\n"); } sb.append(sqlCreate.substring(0, matcher.start(TBL_PATTERN_IDX_AFTER_COL_DEF))); sb.append(sqlCreate.substring(matcher.end(TBL_PATTERN_IDX_AFTER_COL_DEF))); } else { sb = new StringBuilder(sqlCreate); } sb.append(" partition by range (").append(partitioning.columnName()).append(") "); sb.append("interval(").append(partitioning.interval()).append(") "); sb.append("( partition ").append(shortName).append("_P1 values less than ("); if (StringUtils.isEmpty(partitioning.startPartitionLessThanValue())) { sb.append("to_date('").append(FIRST_OF_NEXT_MONTH).append("', 'dd.MM.yyyy')"); } else { sb.append(partitioning.startPartitionLessThanValue()); } sb.append(")) "); sb.append(partitioning.enableRowMovement() ? "ENABLE" : "DISABLE"); sb.append(" ROW MOVEMENT"); return sb.toString(); }
From source file:org.exoplatform.outlook.OutlookServiceImpl.java
/** * Make links open new window./*w ww . j a v a2s. c o m*/ * * @param text the text * @return the string */ protected String makeLinksOpenNewWindow(String text) { // Make all links target a new window // Replace in all links with target attribute to its _blank value Matcher m = linkWithTarget.matcher(text); StringBuilder sb = new StringBuilder(); int pos = 0; while (m.find()) { if (linkNotLocal.matcher(m.group()).find()) { int start = m.start(1); int end = m.end(1); if (start >= 0 && end >= 0) { sb.append(text.substring(pos, start)); sb.append("target=\"_blank\""); pos = end; } else { if (LOG.isDebugEnabled()) { LOG.debug("Cannot find link target group in " + m.group(1)); } } } } if (pos < text.length()) { sb.append(text.substring(pos)); } text = sb.toString(); // Add in all links without target attribute add it with _blank value m = linkWithoutTarget.matcher(text); sb = new StringBuilder(); pos = 0; while (m.find()) { if (linkNotLocal.matcher(m.group()).find()) { int start = m.start(2); int end = m.end(2); if (start >= 0 && end >= 0) { sb.append(text.substring(pos, start)); sb.append(" target=\"_blank\""); sb.append(text.substring(start, end)); pos = end; } else { if (LOG.isDebugEnabled()) { LOG.debug("Cannot find link end group in " + m.group(2)); } } } } if (pos < text.length()) { sb.append(text.substring(pos)); } return sb.toString(); }