Package org.apache.oro.text.regex

Examples of org.apache.oro.text.regex.MatchResult


                "URL\\(\\s*('|\")(.*)('|\")\\s*\\)", // $NON-NLS-1$
                Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.SINGLELINE_MASK | Perl5Compiler.READ_ONLY_MASK);
        PatternMatcherInput input = null;
        input = new PatternMatcherInput(styleTagStr);
        while (matcher.contains(input, pattern)) {
            MatchResult match = matcher.getMatch();
            // The value is in the second group
            String styleUrl = match.group(2);
            urls.addURL(styleUrl, baseUrl);
        }
    }
View Full Code Here


        // Construct a multi-line string with all matches
        StringBuilder sb = new StringBuilder();
        final int size = matches.size();
        sb.append("Match count: ").append(size).append("\n");
        for (int j = 0; j < size; j++) {
            MatchResult mr = matches.get(j);
            final int groups = mr.groups();
            for (int i = 0; i < groups; i++) {
                sb.append("Match[").append(j+1).append("][").append(i).append("]=").append(mr.group(i)).append("\n");
            }
        }
        return sb.toString();

    }
View Full Code Here

        if (value == null) {
            resetFieldsValues();
        } else {
            PatternMatcher matcher = new Perl5Matcher();
            if (matcher.matches(value, getAggregateFieldDefinition().getSplitPattern())) {
                MatchResult matchResult = matcher.getMatch();
                Iterator iterator = getAggregateFieldDefinition().getSplitMappingsIterator();
                while (iterator.hasNext()) {
                    SplitMapping splitMapping = (SplitMapping)iterator.next();
                    String result = matchResult.group(splitMapping.getGroup());

                    // Fields can have a non-string datatype, going to the readFromRequest
                    Field field = (Field)fieldsById.get(splitMapping.getFieldId());
                    field.readFromRequest(result);
                }
View Full Code Here

              | Perl5Compiler.MULTILINE_MASK);
      final PatternMatcher matcher = new Perl5Matcher();

      final PatternMatcherInput input = new PatternMatcherInput(plainText);

      MatchResult result;
      String url;

      //loop the matches
      while (matcher.contains(input, pattern)) {
        // if this is taking too long, stop matching
        //   (SHOULD really check cpu time used so that heavily loaded systems
        //   do not unnecessarily hit this limit.)
        if (System.currentTimeMillis() - start >= 60000L) {
          if (LOG.isWarnEnabled()) {
            LOG.warn("Time limit exceeded for getOutLinks");
          }
          break;
        }
        result = matcher.getMatch();
        url = result.group(0);
        try {
          Outlink outlink = new Outlink(url, anchor, conf);
          outlinks.add(new Outlink(url, anchor, conf));
        } catch (MalformedURLException mue) {
          LOG.warn("Invalid url: '" + url + "', skipping.");
View Full Code Here

        Perl5Compiler.CASE_INSENSITIVE_MASK
        | Perl5Compiler.SINGLELINE_MASK
        | Perl5Compiler.READ_ONLY_MASK);
   
    while (matcher.contains(input, pattern)) {
      MatchResult match = matcher.getMatch();
      String s;
      if (log.isDebugEnabled()) {
        log.debug("match groups " + match.groups() + " " + match.toString());
      }
      // Check for a BASE HREF:
      for (int g = 1; g <= NUM_BASE_GROUPS && g <= match.groups(); g++) {
        s = match.group(g);
        if (s != null) {
          if (log.isDebugEnabled()) {
            log.debug("new baseUrl: " + s + " - " + baseUrl.toString());
          }
          try {
            baseUrl = new URL(baseUrl, s);
          } catch (MalformedURLException e) {
            // Doesn't even look like a URL?
            // Maybe it isn't: Ignore the exception.
            if (log.isDebugEnabled()) {
              log.debug("Can't build base URL from RL " + s + " in page " + baseUrl, e);
            }
          }
        }
      }
      for (int g = NUM_BASE_GROUPS + 1; g <= match.groups(); g++) {
        s = match.group(g);
        if (s != null) {
          if (log.isDebugEnabled()) {
            log.debug("group " + g + " - " + match.group(g));
          }
          urls.addURL(s, baseUrl);
        }
      }
    }
View Full Code Here

        String regularExpression = "^.$";
        Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
       
        PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
        while(localMatcher.contains(input, pattern)) {
            MatchResult match = localMatcher.getMatch();
            return match.beginOffset(0);
        }
        // No divider was found
        return -1;
    }
View Full Code Here

    private String getBoundaryStringFromContentType(String requestHeaders) {
        Perl5Matcher localMatcher = JMeterUtils.getMatcher();
        String regularExpression = "^" + HTTPSamplerBase.HEADER_CONTENT_TYPE + ": multipart/form-data; boundary=(.+)$";
        Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
        if(localMatcher.contains(requestHeaders, pattern)) {
            MatchResult match = localMatcher.getMatch();
            return match.group(1);
        }
        else {
            return null;
        }
    }
View Full Code Here

    List collectAllMatches = new ArrayList();
    try {
      PatternMatcher matcher = JMeterUtils.getMatcher();
      PatternMatcherInput input = new PatternMatcherInput(textToMatch);
      while (matcher.contains(input, searchPattern)) {
        MatchResult match = matcher.getMatch();
        collectAllMatches.add(match);
      }
    } catch (NumberFormatException e) {//TODO: can this occur?
      log.error("", e); //$NON-NLS-1$
      return defaultValue;
    } finally {
        if (name.length() > 0){
            vars.put(name + "_matchNr", "" + collectAllMatches.size()); //$NON-NLS-1$ //$NON-NLS-2$
        }
    }

    if (collectAllMatches.size() == 0) {
      return defaultValue;
    }

    if (valueIndex.equals(ALL)) {
      StringBuffer value = new StringBuffer();
      Iterator it = collectAllMatches.iterator();
      boolean first = true;
      while (it.hasNext()) {
        if (!first) {
          value.append(between);
        } else {
          first = false;
        }
        value.append(generateResult((MatchResult) it.next(), name, tmplt, vars));
      }
      return value.toString();
    } else if (valueIndex.equals(RAND)) {
      MatchResult result = (MatchResult) collectAllMatches.get(rand.nextInt(collectAllMatches.size()));
      return generateResult(result, name, tmplt, vars);
    } else {
      try {
        int index = Integer.parseInt(valueIndex) - 1;
        MatchResult result = (MatchResult) collectAllMatches.get(index);
        return generateResult(result, name, tmplt, vars);
      } catch (NumberFormatException e) {
        float ratio = Float.parseFloat(valueIndex);
        MatchResult result = (MatchResult) collectAllMatches
            .get((int) (collectAllMatches.size() * ratio + .5) - 1);
        return generateResult(result, name, tmplt, vars);
      } catch (IndexOutOfBoundsException e) {
        return defaultValue;
      }
View Full Code Here

    String text = new String(responseText.getResponseData());
    Perl5Matcher matcher = JMeterUtils.getMatcher();
    String value = "";
    if (isPathExtension() && isPathExtensionNoEquals() && isPathExtensionNoQuestionmark()) {
      if (matcher.contains(text, pathExtensionNoEqualsNoQuestionmarkRegexp)) {
        MatchResult result = matcher.getMatch();
        value = result.group(1);
      }
    } else if (isPathExtension() && isPathExtensionNoEquals()) // && !
                                  // isPathExtensionNoQuestionmark
    {
      if (matcher.contains(text, pathExtensionNoEqualsQuestionmarkRegexp)) {
        MatchResult result = matcher.getMatch();
        value = result.group(1);
      }
    } else if (isPathExtension() && isPathExtensionNoQuestionmark()) // && !
                                      // isPathExtensionNoEquals
    {
      if (matcher.contains(text, pathExtensionEqualsNoQuestionmarkRegexp)) {
        MatchResult result = matcher.getMatch();
        value = result.group(1);
      }
    } else if (isPathExtension()) // && ! isPathExtensionNoEquals && !
                    // isPathExtensionNoQuestionmark
    {
      if (matcher.contains(text, pathExtensionEqualsQuestionmarkRegexp)) {
        MatchResult result = matcher.getMatch();
        value = result.group(1);
      }
    } else // if ! isPathExtension()
    {
      if (matcher.contains(text, parameterRegexp)) {
        MatchResult result = matcher.getMatch();
        for (int i = 1; i < result.groups(); i++) {
          value = result.group(i);
          if (value != null) {
            break;
          }
        }
      }
View Full Code Here

                    log.warn("Could not parse "+prevString+" "+e1);
                }
            }
            int matchCount=0;// Number of refName_n variable sets to keep
      try {
        MatchResult match;
        if (matchNumber >= 0) {// Original match behaviour
          match = getCorrectMatch(matches, matchNumber);
          if (match != null) {
            vars.put(refName, generateResult(match));
            saveGroups(vars, refName, match);
View Full Code Here

TOP

Related Classes of org.apache.oro.text.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.