List of usage examples for java.util.regex Matcher lookingAt
public boolean lookingAt()
From source file:org.exoplatform.wiki.rendering.render.confluence.ConfluenceSyntaxEscapeHandler.java
private void escapeFirstMatchedCharacter(Pattern pattern, StringBuffer accumulatedBuffer) { Matcher matcher = pattern.matcher(accumulatedBuffer); if (matcher.lookingAt()) { // Escape the first character accumulatedBuffer.replace(matcher.start(1), matcher.start(1) + 1, ESCAPE_CHAR + matcher.group(1).charAt(0)); }/*from w ww .j a va 2 s . co m*/ }
From source file:org.gradle.build.docs.dsl.docbook.JavadocConverter.java
private void adjustAccessorComment(DocCommentImpl docComment) { // Replace 'Returns the ...'/'Sets the ...' with 'The ...' List<Element> nodes = docComment.getDocbook(); if (nodes.isEmpty()) { return;//from www . j ava 2 s . c o m } Element firstNode = nodes.get(0); if (!firstNode.getNodeName().equals("para") || !(firstNode.getFirstChild() instanceof Text)) { return; } Text comment = (Text) firstNode.getFirstChild(); Matcher matcher = ACCESSOR_COMMENT_PATTERN.matcher(comment.getData()); if (matcher.lookingAt()) { String theOrWhether = matcher.group(1).toLowerCase(Locale.US); comment.setData( StringUtils.capitalize(theOrWhether) + " " + comment.getData().substring(matcher.end())); } }
From source file:org.gradle.integtests.fixtures.executer.LogContent.java
/** * Returns a copy of this log content with the debug prefix removed. *//* w w w. j a va2 s .co m*/ public LogContent removeDebugPrefix() { if (definitelyNoDebugPrefix) { return this; } List<String> result = new ArrayList<String>(lines.size()); for (String line : lines) { java.util.regex.Matcher matcher = DEBUG_PREFIX.matcher(line); if (matcher.lookingAt()) { result.add(line.substring(matcher.end())); } else { result.add(line); } } return new LogContent(ImmutableList.copyOf(result), true, rawContent); }
From source file:org.gradle.nativebinaries.language.c.internal.incremental.sourceparser.RegexBackedCSourceParser.java
private void parseFile(File file, DefaultSourceDetails sourceDetails) { try {//from w ww . j a v a 2 s .c o m BufferedReader bf = new BufferedReader( new PreprocessingReader(new BufferedReader(new FileReader(file)))); try { String line; while ((line = bf.readLine()) != null) { Matcher m = includePattern.matcher(line); if (m.lookingAt()) { boolean isImport = "import".equals(m.group(1)); String value = m.group(2); if (isImport) { sourceDetails.getImports().add(value); } else { sourceDetails.getIncludes().add(value); } } } } finally { IOUtils.closeQuietly(bf); } } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:org.jboss.richfaces.integrationTest.SeleniumLoggingTestListener.java
/** * Get method name from ITestResult/* www .j a va 2 s . c o m*/ * * @param result * from the fine-grained listener's method such as * onTestFailure(ITestResult) * @return the method name in current context */ protected static String getMethodName(ITestResult result) { String methodName = result.getMethod().toString(); Matcher matcher = Pattern.compile(".*\\.(.*\\..*)\\(\\)").matcher(methodName); if (matcher.lookingAt()) { methodName = matcher.group(1); } return methodName; }
From source file:org.jboss.tools.openshift.express.internal.ui.filters.SimplePropertyActionFilter.java
private boolean isAccessorFor(String property, String accessorName) { Matcher matcher = simpleAccessorPattern.matcher(accessorName); if (matcher.lookingAt()) { return property.equals(StringUtils.uncapitalize(matcher.group(NAME_CAPTURE_GROUP))); }/* w w w. jav a2s . co m*/ return false; }
From source file:org.lockss.daemon.PrunedCachedUrlSetSpec.java
boolean matches0(String url) { if (!super.matches(url)) { return false; }/*from w w w .j av a 2 s.c o m*/ if (includePat != null) { Matcher mat = includePat.matcher(url); return mat.lookingAt() || mat.hitEnd(); } if (excludePat != null) { Matcher mat = excludePat.matcher(url); return !mat.lookingAt(); } return true; }
From source file:org.nuclos.server.dblayer.impl.standard.StandardSqlDBAccess.java
@Override protected IBatch getSqlForCreateCallable(DbCallable callable) throws DbException { String code = callable.getCode(); if (code == null) throw new DbException("No code for callable " + callable.getCallableName()); Pattern pattern = Pattern.compile(String.format("\\s*(CREATE\\s+(OR\\s+REPLACE\\s+)?)?%s\\s+%s\\s*(?=\\W)", callable.getType(), callable.getCallableName()), Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(code); boolean success = matcher.lookingAt(); if (!success) throw new DbException("Cannot interpret header for callable " + callable.getCallableName()); return BatchImpl.simpleBatch(PreparedString.format("CREATE %s %s %s", callable.getType(), getQualifiedName(callable.getCallableName()), code.substring(matcher.group().length()))); }
From source file:org.omnaest.utils.strings.parser.ParserState.java
private List<ParserState.Match> parseInternal(String remainingText, Iterator<TokenPath.StackElement> stackIterator, int lookup) { final boolean stackHasNext = stackIterator.hasNext(); final boolean remainingTextIsEmpty = StringUtils.isEmpty(remainingText); List<ParserState.Match> retlist = !stackHasNext && remainingTextIsEmpty ? new ArrayList<ParserState.Match>() : null;/* w w w. j av a 2 s . c o m*/ if (stackHasNext && (lookup <= -1 || lookup > 0)) { TokenPath.StackElement stackElement = stackIterator.next(); final int localLookup = stackElement.getLookup(); final int reducedLookup = Math.max(Math.max(lookup - 1, localLookup), -1); final int normalizedLookup = Math.max(Math.max(lookup, localLookup), -1); if (stackElement instanceof TokenPath.StackElementPattern) { TokenPath.StackElementPattern stackElementPattern = (TokenPath.StackElementPattern) stackElement; Pattern pattern = stackElementPattern.getPattern(); Matcher matcher = pattern.matcher(remainingText); boolean lookingAt = matcher.lookingAt(); if (lookingAt) { if (remainingTextIsEmpty) { retlist = ListUtils.emptyList(); } else { final int end = matcher.end(); final String remainingTextNew = StringUtils.substring(remainingText, end); retlist = this.parseInternal(remainingTextNew, stackIterator, reducedLookup); if (retlist != null) { final String token = matcher.group(); Grammar.TokenAction tokenAction = stackElement.getTokenAction(); ParserState.Match match = new Match(token); match.addTokenAction(tokenAction); retlist = ListUtils.add(retlist, 0, match); } } } } else if (stackElement instanceof TokenPath.StackElementTokenPath) { TokenPath.StackElementTokenPath stackElementTokenPath = (TokenPath.StackElementTokenPath) stackElement; final Grammar.TokenPath[] tokenPathes = stackElementTokenPath.getTokenPathes(); final Grammar.TokenAction tokenAction = stackElement.getTokenAction(); if (tokenPathes != null) { for (Grammar.TokenPath tokenPathCurrent : tokenPathes) { retlist = this.parseInternal(remainingText, tokenPathCurrent, normalizedLookup); if (retlist != null) { ParserState.Match lastElement = ListUtils.lastElement(retlist); if (lastElement != null) { lastElement.addTokenAction(tokenAction); } break; } } } } } return retlist; }
From source file:org.onehippo.forge.content.exim.core.util.ContentPathUtils.java
/** * Returns encoded node path where each node name in the {@code nodePath} is encoded * by using Hippo CMS Default URI Encoding strategy. * @param nodePath node path/*from w w w .j a v a 2 s .co m*/ * @return encoded node path where each node name in the {@code nodePath} is encoded * by using Hippo CMS Default URI Encoding strategy */ public static String encodeNodePath(final String nodePath) { String[] nodeNames = StringUtils.splitPreserveAllTokens(nodePath, '/'); if (nodeNames == null) { return null; } // If the nodePath starts with typical Hippo content node path like '/content/documents/MyHippoProject/...', // DO NOT encode the first three path segments // because the third path segment might be in upper-cases unlike descendant nodes. int begin = 0; final Matcher m = HIPPO_CONTENT_PATH_PREFIX_PATTERN.matcher(nodePath); if (m.lookingAt()) { begin = 4; } for (int i = begin; i < nodeNames.length; i++) { nodeNames[i] = HippoNodeUtils.getDefaultUriEncoding().encode(nodeNames[i]); } return StringUtils.join(nodeNames, '/'); }