Package org.apache.oro.text.regex

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


        return StringUtils.containsAny(value, new char[] { '*', '?', '+', '|', '(', ')', '{', '}', '[', ']', '\\', '$',
                '^', '.' });
    }

    private static boolean isWildCardMatch(String matchPattern, String value) {
        PatternMatcher matcher = new Perl5Matcher();
        return matcher.matches(value, patterns.get(matchPattern));
    }
View Full Code Here


            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

     */
    public String[] getMatches(String pattern, String input, int subgroup)
    {try { __CLOVER_400_0.M[2177]++;
        __CLOVER_400_0.S[8932]++;Pattern compiledPattern = getCompiledPattern(pattern);

        __CLOVER_400_0.S[8933]++;PatternMatcher matcher = getPatternMatcher();
        __CLOVER_400_0.S[8934]++;PatternMatcherInput matcherInput = new PatternMatcherInput(input);

        __CLOVER_400_0.S[8935]++;List matches = new ArrayList();

        __CLOVER_400_0.S[8936]++;while ((((matcher.contains(matcherInput, compiledPattern)) && (++__CLOVER_400_0.CT[1514] != 0)) || (++__CLOVER_400_0.CF[1514] == 0))){
        {
            __CLOVER_400_0.S[8937]++;MatchResult match = matcher.getMatch();

            __CLOVER_400_0.S[8938]++;String matchedInput = match.group(subgroup);

            __CLOVER_400_0.S[8939]++;matches.add(matchedInput);
        }}
View Full Code Here

     */
    private static String parsePropertiesInString(Properties props, String string,
                                                  boolean failIfMissing) throws CruiseControlException {

        if (string != null) {
            PatternMatcher matcher = new Perl5Matcher();

            // Expand all (possibly nested) properties
            while (matcher.contains(string, PROPERTY_PATTERN)) {
                MatchResult result = matcher.getMatch();
                String pre = result.group(1);
                String propertyName = result.group(2);
                String post = result.group(3);
                String value = props.getProperty(propertyName);
                if (value == null && failIfMissing) {
View Full Code Here

     * @param string The string to be parsed
     * @return The parsed string
     */
    private String parsePropertiesInString(String string, Properties buildProperties) {

        PatternMatcher matcher = new Perl5Matcher();

        // Expand all (possibly nested) properties
        while (matcher.contains(string, LOG_PROPERTY_PATTERN)) {
            MatchResult result = matcher.getMatch();
            String pre = result.group(1);
            String propertyName = result.group(2);
            String post = result.group(3);
            String value = buildProperties.getProperty(propertyName);
            if (value == null) {
View Full Code Here

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

            return;
        }
        List pieces = new ArrayList();
        List combined = new LinkedList();
        String rawTemplate = getTemplate();
        PatternMatcher matcher = (Perl5Matcher) localMatcher.get();
        Pattern templatePattern =
            patternCache.getPattern(
                "\\$(\\d+)\\$",
                Perl5Compiler.READ_ONLY_MASK & Perl5Compiler.SINGLELINE_MASK);
        log.debug("Pattern = " + templatePattern);
        log.debug("template = " + rawTemplate);
        Util.split(pieces, matcher, templatePattern, rawTemplate);
        PatternMatcherInput input = new PatternMatcherInput(rawTemplate);
        boolean startsWith = isFirstElementGroup(rawTemplate);
        log.debug(
            "template split into "
                + pieces.size()
                + " pieces, starts with = "
                + startsWith);
        if (startsWith){
            pieces.remove(0);// Remove initial empty entry
        }
        Iterator iter = pieces.iterator();
        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))
        {
            log.debug("Template does end with template pattern");
            combined.add(new Integer(matcher.getMatch().group(1)));
        }
        template = combined.toArray();
    }
View Full Code Here

        }

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

    private Object[] 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)));
        }
        return combined.toArray();
    }
View Full Code Here

                enteredValue = null;
        }

        if (enteredValue != null) {
            // try to split it
            PatternMatcher matcher = new Perl5Matcher();
            if (matcher.matches(enteredValue, definition.getSplitPattern())) {
                MatchResult matchResult = matcher.getMatch();
                Iterator iterator = definition.getSplitMappingsIterator();
                while (iterator.hasNext()) {
                    SplitMapping splitMapping = (SplitMapping)iterator.next();
                    String result = matchResult.group(splitMapping.getGroup());
                    // Since we know the fields are guaranteed to have a string datatype, we
View Full Code Here

TOP

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

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.