Package org.apache.oro.text.regex

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


      if (DebugFile.trace) DebugFile.writeln("Perl5Compiler.compile(\""+sPattern+"\", Perl5Compiler.SINGLELINE_MASK)");
      Pattern oPattern = oCompiler.compile(sPattern, Perl5Compiler.SINGLELINE_MASK);

      if (oMatcher.contains(sBase, oPattern)) {
        MatchResult oMtrs = oMatcher.getMatch();
        if (oMtrs!=null) sMatch = oMtrs.toString();
        if (sMatch.length()==0) {
          oCompiler = new Perl5Compiler();
          oMatcher = new Perl5Matcher();
          oPattern = oCompiler.compile(sPattern, Perl5Compiler.SINGLELINE_MASK);
          if (oMatcher.contains(sBase, oPattern)) {
            oMtrs = oMatcher.getMatch();
            if (oMtrs!=nullsMatch = oMtrs.toString();
          }
        } // fi
        if (sMatch.length()==0)
          throw new ParserException("Match could not be retrieved for pattern " + sPattern);       
        int iDquote = sMatch.indexOf('"');
View Full Code Here


    Perl5Matcher matcher = new Perl5Matcher();
    if (isMatch ? matcher.matches(_string, pattern)
                : matcher.contains(_string, pattern))
    {
      if (array != null) {
        MatchResult match = matcher.getMatch();
        array.clear();
        int n = match.groups();
        for(int i=0; i<n; i++) {
          array.append(Any.create(match.group(i)));
        }
        return array;

      } else if (list != null) {
        MatchResult match = matcher.getMatch();
        list.clear();
        int n = match.groups();
        for(int i=0; i<n; i++) {
          list.append(Any.create(match.group(i)));
        }
        return list;       
      }

      return TRUE;
View Full Code Here

    Perl5Matcher matcher = new Perl5Matcher();
    if (isMatch ? matcher.matches(string, _pattern)
                : matcher.contains(string, _pattern))
    {
      if (array != null) {
        MatchResult match = matcher.getMatch();
        array.clear();
        int n = match.groups();
        for(int i=0; i<n; i++) {
          array.append(Any.create(match.group(i)));
        }
        return array;

      } else if (list != null) {
        MatchResult match = matcher.getMatch();
        list.clear();
        int n = match.groups();
        for(int i=0; i<n; i++) {
          list.append(Any.create(match.group(i)));
        }
        return list;       
      }

      return TRUE;
View Full Code Here

      return Any.create(_index);
    }
   
    public Object nextElement()
    {
      MatchResult match = _matcher.getMatch();
      int n = match.groups();
      Any[] list = new Any[n];
      for(int i=0; i<n; i++) {
        list[i] = Any.create(match.group(i));
      }
      return new AnyList(list);
    }
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<MatchResult> collectAllMatches = new ArrayList<MatchResult>();
        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)) {
            StringBuilder value = new StringBuilder();
            Iterator<MatchResult> it = collectAllMatches.iterator();
            boolean first = true;
            while (it.hasNext()) {
                if (!first) {
                    value.append(between);
                } else {
                    first = false;
                }
                value.append(generateResult(it.next(), name, tmplt, vars));
            }
            return value.toString();
        } else if (valueIndex.equals(RAND)) {
            MatchResult result = collectAllMatches.get(rand.nextInt(collectAllMatches.size()));
            return generateResult(result, name, tmplt, vars);
        } else {
            try {
                int index = Integer.parseInt(valueIndex) - 1;
                MatchResult result = collectAllMatches.get(index);
                return generateResult(result, name, tmplt, vars);
            } catch (NumberFormatException e) {
                float ratio = Float.parseFloat(valueIndex);
                MatchResult result = collectAllMatches
                        .get((int) (collectAllMatches.size() * ratio + .5) - 1);
                return generateResult(result, name, tmplt, vars);
            } catch (IndexOutOfBoundsException e) {
                return defaultValue;
            }
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

                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 = ConversionUtils.makeRelativeURL(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 text = new String(responseText.getResponseData()); // TODO - charset?
        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

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.