Package java.util.regex

Examples of java.util.regex.MatchResult


  }

  private void initFromString(String pattern, String string) {
    Scanner scanner = new Scanner(string);
    scanner.findInLine(pattern);
    MatchResult result = scanner.match();
    setName(result.group(1));
    setBranch(result.group(3));
    this.revision = Integer.parseInt(result.group(2));
  }
View Full Code Here


          "foo expected not to be:<1>", e.getMessage());
    }
  }

  public void testMatchesRegexSuccess() {
    MatchResult result = assertMatchesRegex("a(.)", "ab");
    assertEquals("b", result.group(1));
  }
View Full Code Here

          e.getMessage());
    }
  }

  public void testContainsRegexSuccess() {
    MatchResult result = assertContainsRegex("a(.)", "ace");
    assertEquals("c", result.group(1));
  }
View Full Code Here

          "foo expected not to be:<1>", e.getMessage());
    }
  }

  public void testMatchesRegexSuccess() {
    MatchResult result = assertMatchesRegex("a(.)", "ab");
    assertEquals("b", result.group(1));
  }
View Full Code Here

          e.getMessage());
    }
  }

  public void testContainsRegexSuccess() {
    MatchResult result = assertContainsRegex("a(.)", "ace");
    assertEquals("c", result.group(1));
  }
View Full Code Here

            resultContext.trace(sb.toString());
        }

        for (PatternRulePair<R> prp : rules) {
            // Match each template
            final MatchResult mr = prp.p.match(path);
            if (mr != null) {
                resultContext.setMatchResult(mr);
                return new SingleEntryIterator<R>(prp.r);
            }
        }
View Full Code Here

        public boolean hasNext() {
            if (r != null) return true;
           
            while(i.hasNext()) {
                final PatternRulePair<R> prp = i.next();
                final MatchResult mr = prp.p.match(path);
                if (mr != null) {
                    resultContext.setMatchResult(mr);
                    r = prp.r;
                    return true;
                }               
View Full Code Here

    private int[] getPathParameterBounds(String name) {
        Iterator<UriTemplate> iTemplate = templates.iterator();
        Iterator<MatchResult> iMatchResult = matchResults.iterator();
        while (iTemplate.hasNext()) {
            MatchResult mr = iMatchResult.next();
            // Find the index of path parameter
            int pIndex = getLastPathParameterIndex(name, iTemplate.next());
            if (pIndex != -1) {
                int pathLength = mr.group().length();
                int segmentIndex = mr.end(pIndex + 1);
                int groupLength = segmentIndex - mr.start(pIndex + 1);

                // Find the absolute position of the end of the
                // capturing group in the request path
                while (iMatchResult.hasNext()) {
                    mr = iMatchResult.next();
                    segmentIndex += mr.group().length() - pathLength;
                    pathLength = mr.group().length();
                }
                int[] bounds = {segmentIndex - groupLength, segmentIndex};
                return bounds;
            }
        }
View Full Code Here

        // ��ʼƥ��
        int redirectCode = 0;

        for (RewriteRule rule : rules) {
            MatchResult ruleMatchResult = rule.match(path);
            MatchResult conditionMatchResult = null;
            RewriteSubstitution subs = rule.getSubstitution();

            // ���ƥ�䣬��鿴conditions
            if (ruleMatchResult != null) {
                conditionMatchResult = rule.matchConditions(ruleMatchResult, wrappedRequest);
View Full Code Here

        return null;
    }

    public MatchResult matchConditions(MatchResult ruleMatchResult, HttpServletRequest request) {
        MatchResult conditionMatchResult = MatchResultSubstitution.EMPTY_MATCH_RESULT;

        if (!isEmptyArray(conditions)) {
            int i = 0;
            for (RewriteCondition condition : conditions) {
                MatchResult result = condition.match(ruleMatchResult, conditionMatchResult, request);

                // �ж�ornext��ǣ��������һ��condition����ornext��ǣ������ó���������
                boolean ornext = i < conditions.length - 1 && condition.getFlags().hasOR();

                if (result == null) {
View Full Code Here

TOP

Related Classes of java.util.regex.MatchResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.