Package org.apache.oro.text.regex

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(new Integer(currentResult.group(1)));// add match as Integer
View Full Code Here


            return defaultValue;
        }

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

    private Object[] generateTemplate(String rawTemplate) {
        List<String> pieces = new ArrayList<String>();
        // String or Integer
        List<Object> combined = new LinkedList<Object>();
        PatternMatcher matcher = JMeterUtils.getMatcher();
        Util.split(pieces, matcher, templatePattern, rawTemplate);
        PatternMatcherInput input = new PatternMatcherInput(rawTemplate);
        boolean startsWith = isFirstElementGroup(rawTemplate);
        if (startsWith) {
            pieces.remove(0);// Remove initial empty entry
        }
        Iterator<String> 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)) {
            combined.add(new Integer(matcher.getMatch().group(1)));
        }
        return combined.toArray();
    }
View Full Code Here

            throw new ConfigValidatorException("Invalid regexp mode: " + getMode()
                    + ", should be contain, exact or prefix.");
        }

        // ƥ��
        PatternMatcher matcher = new Perl5Matcher();
        boolean not = getMode().startsWith("!");

        if (getMode().endsWith("contain")) {
            boolean match = matcher.contains(value, pattern);

            return not ? !match : match;
        } else if (getMode().endsWith("exact")) {
            boolean match = matcher.matches(value, pattern);

            return not ? !match : match;
        } else if (getMode().endsWith("prefix")) {
            boolean match = matcher.matchesPrefix(value, pattern);

            return not ? !match : match;
        }

        return false;
View Full Code Here

     *
     * @param context context
     */
    protected void populateWarContext(Map context, String name) {
        Pattern componentNamePattern;
        PatternMatcher matcher = new Perl5Matcher();
        String componentName = "";

        try {
            componentNamePattern = new PathNameCompiler().compile("META-INF/**/autoconf/auto-config.xml");
        } catch (MalformedPatternException e) {
            throw new ConfigException(e);
        }

        if (matcher.matches(name.replace('\\', '/'), componentNamePattern)) {
            componentName = matcher.getMatch().group(1);
        }

        context.put("component", componentName);
    }
View Full Code Here

        Map modifiedProperties = new HashMap();

        for (Iterator i = getMergedKeys().iterator(); i.hasNext();) {
            String key = (String) i.next();
            String value = toString(getMergedProperties().get(key));
            PatternMatcher matcher = new Perl5Matcher();

            if (value == null) {
                continue;
            }

            // ����antx.properties.*����Ϊ����������
            if (matcher.matches(key, ANTX_PROPERTIES_PATTERN) || "antx.properties".equals(key)) {
                continue;
            }

            String defaultValue = null;

View Full Code Here

     * ���shared properties�еı����ǵ�ֵ��
     */
    private void checkOverlap(boolean reload) {
        for (Iterator i = getMergedKeys().iterator(); i.hasNext();) {
            String key = (String) i.next();
            PatternMatcher matcher = new Perl5Matcher();

            // ����antx.properties.*����Ϊ����������
            if (matcher.matches(key, ANTX_PROPERTIES_PATTERN) || "antx.properties".equals(key)) {
                continue;
            }

            // ��shared properties����key
            PropertiesFile[] files = getSharedPropertiesFilesExpanded();
View Full Code Here

    private Map getNamedSharedPropertiesFiles(Map props) {
        Map names = new TreeMap();

        for (Iterator i = props.keySet().iterator(); i.hasNext();) {
            String key = (String) i.next();
            PatternMatcher matcher = new Perl5Matcher();

            if (matcher.matches(key, ANTX_PROPERTIES_PATTERN)) {
                MatchResult result = matcher.getMatch();
                String name = result.group(1);
                int index;

                try {
                    index = Integer.parseInt(result.group(3));
View Full Code Here

            ServletMappingInfo servletMappingInfo = (ServletMappingInfo) it.next();
            Pattern pattern = servletMappingInfo.getPattern();

            if (pattern != null)
            {
                PatternMatcher matcher = new Perl5Matcher();
               
                if ((matcher.matches(path, pattern)) || (matcher.matches(path + "/", pattern)))
                {
                    servlet = (Servlet) this.servletInstanceMap.get(servletMappingInfo.getServletName());
                    break;
                }
            }
View Full Code Here

    private Object[] generateTemplate(String rawTemplate) {
        List<String> pieces = new ArrayList<String>();
        // String or Integer
        List<Object> combined = new LinkedList<Object>();
        PatternMatcher matcher = JMeterUtils.getMatcher();
        Util.split(pieces, matcher, templatePattern, rawTemplate);
        PatternMatcherInput input = new PatternMatcherInput(rawTemplate);
        boolean startsWith = isFirstElementGroup(rawTemplate);
        if (startsWith) {
            pieces.remove(0);// Remove initial empty entry
        }
        Iterator<String> iter = pieces.iterator();
        while (iter.hasNext()) {
            boolean matchExists = matcher.contains(input, templatePattern);
            if (startsWith) {
                if (matchExists) {
                    combined.add(Integer.valueOf(matcher.getMatch().group(1)));
                }
                combined.add(iter.next());
            } else {
                combined.add(iter.next());
                if (matchExists) {
                    combined.add(Integer.valueOf(matcher.getMatch().group(1)));
                }
            }
        }
        if (matcher.contains(input, templatePattern)) {
            combined.add(Integer.valueOf(matcher.getMatch().group(1)));
        }
        return combined.toArray();
    }
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.