Package org.apache.oro.text.regex

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


        HTTPSampler newLink,
        HTTPSampler config)
        throws MalformedPatternException
    {
        boolean ok = true;
        Perl5Matcher matcher = (Perl5Matcher) localMatcher.get();
        PropertyIterator iter = config.getArguments().iterator();

        String query = null;
        try
        {
            query = JOrphanUtils.decode(newLink.getQueryString(),"UTF-8");
        }
        catch (UnsupportedEncodingException e)
        {
            // UTF-8 unsupported? You must be joking!
            log.error("UTF-8 encoding not supported!");
            throw new Error("Should not happen: "+e.toString());
        }

        if (query == null && config.getArguments().getArgumentCount() > 0)
        {
            return false;
        }
       
        while (iter.hasNext())
        {
            Argument item = (Argument) iter.next().getObjectValue();
            if (query.indexOf(item.getName() + "=") == -1)
            {
                if (!(ok =
                    ok
                        && matcher.contains(
                            query,
                            patternCache.getPattern(
                                item.getName(),
                                Perl5Compiler.READ_ONLY_MASK))))
                {
                    return false;
                }
            }
        }

        if (config.getDomain() != null
            && config.getDomain().length() > 0
            && !newLink.getDomain().equals(config.getDomain()))
        {
            if (!(ok =
                ok
                    && matcher.matches(
                        newLink.getDomain(),
                        patternCache.getPattern(
                            config.getDomain(),
                            Perl5Compiler.READ_ONLY_MASK))))
            {
                return false;
            }
        }

        if (!newLink.getPath().equals(config.getPath())
            && !matcher.matches(
                newLink.getPath(),
                patternCache.getPattern(
                    "[/]*" + config.getPath(),
                    Perl5Compiler.READ_ONLY_MASK)))
        {
            return false;
        }

        if (!(ok =
            ok
                && matcher.matches(
                    newLink.getProtocol(),
                    patternCache.getPattern(
                        config.getProtocol(),
                        Perl5Compiler.READ_ONLY_MASK))))
        {
View Full Code Here


    public static synchronized boolean isArgumentMatched(
        Argument arg,
        Argument patternArg)
        throws MalformedPatternException
    {
        Perl5Matcher matcher = (Perl5Matcher) localMatcher.get();
        return (
            arg.getName().equals(patternArg.getName())
                || matcher.matches(
                    arg.getName(),
                    patternCache.getPattern(
                        patternArg.getName(),
                        Perl5Compiler.READ_ONLY_MASK)))
            && (arg.getValue().equals(patternArg.getValue())
                || matcher.matches(
                    (String) arg.getValue(),
                    patternCache.getPattern(
                        (String) patternArg.getValue(),
                        Perl5Compiler.READ_ONLY_MASK)));
    }
View Full Code Here

      }

      try
      {
         // Get the Matcher for this thread
         Perl5Matcher localMatcher = (Perl5Matcher) matcher.get();
         PropertyIterator iter = getTestStrings().iterator();
         while (iter.hasNext())
         {
            String stringPattern = iter.next().getStringValue();
            Pattern pattern =
               patternCache.getPattern(
                  stringPattern,
                  Perl5Compiler.READ_ONLY_MASK);
            boolean found;
            if ((CONTAINS & getTestType()) > 0)
            {
               found = localMatcher.contains(toCheck, pattern);
            }
            else
            {
               found = localMatcher.matches(toCheck, pattern);
            }
            pass = not ? !found : found;
            if (!pass)
            {
               result.setFailure(true);
View Full Code Here

  /************************************************************
   *  !ToDo (Constructor description)
   ***********************************************************/
  public ProxyControl()
  {
    matcher = new Perl5Matcher();
    compiler = new Perl5Compiler();
    setPort(DEFAULT_PORT);
    setExcludeList(new LinkedList());
    setIncludeList(new LinkedList());
  }
View Full Code Here

   ***************************************/
  public static synchronized boolean isAnchorMatched(HTTPSampler newLink,
      HTTPSampler config) throws MalformedPatternException
  {
    boolean ok = true;
    Perl5Matcher matcher = (Perl5Matcher)localMatcher.get();
    Iterator iter = config.getArguments().iterator();

    // In JDK1.2, URLDecoder.decode has Exception in its throws clause. However, it
    // was removed in JDK1.3. Since JMeter is JDK1.2-compatible, we need to catch
    // Exception.
    String query = null;
    try
    {
      query = URLDecoder.decode(newLink.getQueryString());
    }
    catch (Exception e)
    {
      // do nothing. query will remain null.
    }

    if(query == null && config.getArguments().getArgumentCount() > 0)
      return false;

    while(iter.hasNext())
    {
      Argument item = (Argument)iter.next();
      if(query.indexOf(item.getName()+"=") == -1)
      {
        if(!(ok = ok && matcher.contains(query,
            patternCache.getPattern(item.getName(), Perl5Compiler.READ_ONLY_MASK))))
        {
          return false;
        }
      }
    }

    if(config.getDomain() != null && config.getDomain().length() > 0 &&
        !newLink.getDomain().equals(config.getDomain()))
    {
      if(!(ok = ok && matcher.matches(newLink.getDomain(),
          patternCache.getPattern(config.getDomain(), Perl5Compiler.READ_ONLY_MASK))))
        return false;
    }

    if(!newLink.getPath().equals(config.getPath()) && !matcher.matches(newLink.getPath(),
        patternCache.getPattern("[/]*" + config.getPath(), Perl5Compiler.READ_ONLY_MASK)))
      return false;

    if(!(ok = ok && matcher.matches(newLink.getProtocol(),
        patternCache.getPattern(config.getProtocol(), Perl5Compiler.READ_ONLY_MASK))))
      return false;

    return ok;
  }
View Full Code Here

   *@return                               !ToDo (Return description)
   *@exception MalformedPatternException  !ToDo (Exception description)
   ***************************************/
  public static synchronized boolean isArgumentMatched(Argument arg, Argument patternArg) throws MalformedPatternException
  {
    Perl5Matcher matcher = (Perl5Matcher)localMatcher.get();
    return (arg.getName().equals(patternArg.getName()) ||
        matcher.matches(arg.getName(), patternCache.getPattern(patternArg.getName(),
            Perl5Compiler.READ_ONLY_MASK))) &&
        (arg.getValue().equals(patternArg.getValue()) ||
        matcher.matches((String)arg.getValue(), patternCache.getPattern((String)patternArg.getValue(),
            Perl5Compiler.READ_ONLY_MASK)));
  }
View Full Code Here

    if(case1 == null)
    {
      initRegex(getArgumentName());
    }
    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)
    {
View Full Code Here

    private void generateTemplate(String rawTemplate)
    {
        List pieces = new ArrayList();
        List combined = new LinkedList();
        PatternMatcher matcher = new Perl5Matcher();
        Util.split(pieces, new Perl5Matcher(), templatePattern, rawTemplate);
        PatternMatcherInput input = new PatternMatcherInput(rawTemplate);
        Iterator iter = pieces.iterator();
        boolean startsWith = isFirstElementGroup(rawTemplate);
        while (iter.hasNext())
        {
            boolean matchExists = matcher.contains(input, templatePattern);
            if (startsWith)
            {
                if (matchExists)
                {
                    combined.add(new Integer(matcher.getMatch().group(1)));
                }
                combined.add(iter.next());
            }
            else
            {
                combined.add(iter.next());
                if (matchExists)
                {
                    combined.add(new Integer(matcher.getMatch().group(1)));
                }
            }
        }
        if (matcher.contains(input, templatePattern))
        {
            combined.add(new Integer(matcher.getMatch().group(1)));
        }
        template = combined.toArray();
    }
View Full Code Here

    }

    private boolean isFirstElementGroup(String rawData)
    {
        Pattern pattern = patternCache.getPattern("^\\$\\d+\\$", Perl5Compiler.READ_ONLY_MASK);
        return new Perl5Matcher().contains(rawData, pattern);
    }
View Full Code Here

 
  private void generateTemplate(String rawTemplate)
  {
    List pieces = new ArrayList();
    List combined = new LinkedList();
    PatternMatcher matcher = new Perl5Matcher();
    Util.split(pieces,new Perl5Matcher(),templatePattern,rawTemplate);   
    PatternMatcherInput input = new PatternMatcherInput(rawTemplate);
    int count = 0;
    Iterator iter = pieces.iterator();
    boolean startsWith = isFirstElementGroup(rawTemplate);
    while(iter.hasNext())
    {
      boolean matchExists = matcher.contains(input,templatePattern);
      if(startsWith)
      {
        if(matchExists)
        {
          combined.add(new Integer(matcher.getMatch().group(1)));
        }
        combined.add(iter.next());
      }
      else
      {
        combined.add(iter.next());
        if(matchExists)
        {
          combined.add(new Integer(matcher.getMatch().group(1)));
        }
      }
    }
    if(matcher.contains(input,templatePattern))
    {
      combined.add(new Integer(matcher.getMatch().group(1)));
   
    template = combined.toArray()
  }
View Full Code Here

TOP

Related Classes of org.apache.oro.text.regex.Perl5Matcher

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.