Examples of PatternMatcher


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

    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

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

    {
      return defaultValue;
    }
    List collectAllMatches = new ArrayList();
    try {
      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;
View Full Code Here

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

 
  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

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

          Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK
              | Perl5Compiler.MULTILINE_MASK);
      final Pattern pattern1 = cp.compile(URI_PATTERN,
              Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK
                  | Perl5Compiler.MULTILINE_MASK);
      final PatternMatcher matcher = new Perl5Matcher();

      final PatternMatcher matcher1 = new Perl5Matcher();
      final PatternMatcherInput input = new PatternMatcherInput(plainText);

      MatchResult result;
      String url;

      //loop the matches
      while (matcher.contains(input, pattern)) {
        result = matcher.getMatch();
        url = result.group(2);
        PatternMatcherInput input1 = new PatternMatcherInput(url);
        if (!matcher1.matches(input1, pattern1)) {
          //if (LOG.isTraceEnabled()) { LOG.trace(" - invalid '" + url + "'"); }
          continue;
        }
        if (url.startsWith("www.")) {
            url = "http://" + url;
View Full Code Here

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

            return;
        }
        // Contains Strings and Integers
        List<Object> combined = new ArrayList<Object>();
        String rawTemplate = getTemplate();
        PatternMatcher matcher = JMeterUtils.getMatcher();
        Pattern templatePattern = JMeterUtils.getPatternCache().getPattern("\\$(\\d+)\\$"  // $NON-NLS-1$
                , Perl5Compiler.READ_ONLY_MASK
                & Perl5Compiler.SINGLELINE_MASK);
        if (log.isDebugEnabled()) {
            log.debug("Pattern = " + templatePattern.getPattern());
            log.debug("template = " + rawTemplate);
        }
        int beginOffset = 0;
        MatchResult currentResult;
        PatternMatcherInput pinput = new PatternMatcherInput(rawTemplate);
        while(matcher.contains(pinput, templatePattern)) {
            currentResult = matcher.getMatch();
            final int beginMatch = currentResult.beginOffset(0);
            if (beginMatch > beginOffset) { // string is not empty
                combined.add(rawTemplate.substring(beginOffset, beginMatch));
            }
            combined.add(Integer.valueOf(currentResult.group(1)));// add match as Integer
View Full Code Here

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

        this.regexMatch = regexMatch;
    }

    @Override
    public JMeterProperty transformValue(JMeterProperty prop) throws InvalidVariableException {
        PatternMatcher pm = JMeterUtils.getMatcher();
        Pattern pattern = null;
        PatternCompiler compiler = new Perl5Compiler();
        String input = prop.getStringValue();
        if(input == null) {
            return prop;
View Full Code Here

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

     */
    private void setFieldsValues(String value) {
        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());

View Full Code Here

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

      else
        return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.string.regexp", new String[] {regexp}, Constants.I18N_CATALOGUE));
    }
   
    private boolean matchesRegExp(String string) {
        PatternMatcher matcher = new Perl5Matcher();
        return matcher.matches(string, pattern);
    }
View Full Code Here

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

    try {
      final PatternCompiler cp = new Perl5Compiler();
      final Pattern pattern = cp.compile(URL_PATTERN,
          Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK
              | 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) {
View Full Code Here

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

      return defaultValue;
    }

    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;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.