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


        String regularExpression = "^\\r$"; // $NON-NLS-1$
        Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);

        PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
        if(localMatcher.contains(input, pattern)) {
            MatchResult match = localMatcher.getMatch();
            return match.beginOffset(0);
        }
        // No divider was found
        return -1;
    }
View Full Code Here

    Perl5Matcher matcher = new Perl5Matcher();
    boolean matches = matcher.matches(input, pattern);

    String[] groups = null;
    if (matches) {
      MatchResult matchResult = matcher.getMatch();
      int groupCount = matchResult.groups();

      groups = new String[groupCount];
      for (int i = 0; i < groupCount; i++) {
        groups[i] = matchResult.group(i);
      }

    }

    Match match = new Match(matches, groups);
View Full Code Here

        String type = null;
        boolean allowBody = false;

        if (_patternMatcher.matches(jwcId, _implicitIdPattern))
        {
            MatchResult match = _patternMatcher.getMatch();

            jwcId = match.group(IMPLICIT_ID_PATTERN_ID_GROUP);
            type = match.group(IMPLICIT_ID_PATTERN_TYPE_GROUP);

            String libraryId = match.group(IMPLICIT_ID_PATTERN_LIBRARY_ID_GROUP);
            String simpleType = match.group(IMPLICIT_ID_PATTERN_SIMPLE_TYPE_GROUP);

            // If (and this is typical) no actual component id was specified,
            // then generate one on the fly.
            // The allocated id for anonymous components is
            // based on the simple (unprefixed) type, but starts
View Full Code Here

        // probably a new PatternMatcherInput working on a byte[] would do
        // better.
        input.setInput(new String(html));
        while (matcher.contains(input, pattern))
        {
            MatchResult match= matcher.getMatch();
            String s;
            if (log.isDebugEnabled())
                log.debug("match groups " + match.groups());
            // 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 (log.isDebugEnabled())
                {
                    log.debug("group " + g + " - " + match.group(g));
                }
                if (s != null)
                {
                        urls.addURL(s,baseUrl);
                }
View Full Code Here

      }
      while (x != matchNumber && !done);

      try
      {
          MatchResult match;
          if (matchNumber >= 0){// Original match behaviour
            match = getCorrectMatch(matches, matchNumber);
            if (match != null)
            {
                vars.put(refName, generateResult(match));
View Full Code Here

            PatternMatcher matcher = (PatternMatcher) localMatcher.get();
            String responseText = new String(previousResult.getResponseData());
            PatternMatcherInput input = new PatternMatcherInput(responseText);
            while (matcher.contains(input, searchPattern))
            {
                MatchResult match = matcher.getMatch();
                collectAllMatches.add(match);
            }
        }
        catch (NumberFormatException e)
        {
            log.error("", e);
            return defaultValue;
        }
        catch (Exception e)
        {
            return defaultValue;
        }
        finally
    {
      vars.put(name+"_matchNr", ""+collectAllMatches.size());
        }

        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)
View Full Code Here

        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

        String value = "";
        if (isPathExtension() && isPathExtensionNoEquals())
        {
            if (matcher.contains(text, pathExtensionNoEqualsRegexp))
            {
                MatchResult result = matcher.getMatch();
                value = result.group(1);
            }
        }
        else if (isPathExtension()) // && ! isPathExtensionNoEquals
        {
            if (matcher.contains(text, pathExtensionEqualsRegexp))
            {
                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

    String text = new String(responseText.getResponseData());
    Perl5Matcher matcher = new Perl5Matcher();
    String value = "";
    if (matcher.contains(text, case1))
    {
      MatchResult result = matcher.getMatch();
      value = result.group(1);
    }
    else if (matcher.contains(text, case2))
    {
      MatchResult result = matcher.getMatch();
      value = result.group(1);
    }
    else if (matcher.contains(text, case3))
    {
      MatchResult result = matcher.getMatch();
      value = result.group(1);
    }
    modify((HTTPSampler) sampler, value);
    if (value.length() > 0)
    {
      return true;
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.