Package org.apache.regexp

Examples of org.apache.regexp.RE


            throw new PatternException(rse.getMessage(), rse);
        }
    }

    protected boolean preparedMatch(REProgram preparedPattern, String match) {
        RE re = new RE(preparedPattern);

        if (match == null) {
            return false;
        }

        return re.match(match);
    }
View Full Code Here


     */
    protected boolean preparedMatch(REProgram preparedPattern, String match) {
        boolean result = false;
       
        if (match != null) {
            RE re = new RE(preparedPattern);
            result = re.match(match);
        }
        return result;
    }
View Full Code Here

            int comma = list.indexOf(',');
            if (comma < 0)
                break;
            String pattern = list.substring(0, comma).trim();
            try {
                reProgramList.add(new RE(pattern).getProgram());
            } catch (RESyntaxException e) {
                throw new IllegalArgumentException
                    (sm.getString("requestFilterValve.syntax", pattern));
            }
            list = list.substring(comma + 1);
View Full Code Here

            return;
        }

       
        // Create local RE since RE is not thread safe
        RE re = new RE();
       
        // Check the deny patterns, if any
        for (int i = 0; i < denies.length; i++) {
            re.setProgram(denies[i]);
            if (re.match(property)) {
                ServletResponse sres = response.getResponse();
                if (sres instanceof HttpServletResponse) {
                    HttpServletResponse hres = (HttpServletResponse) sres;
                    hres.sendError(HttpServletResponse.SC_FORBIDDEN);
                    return;
                }
            }
        }

        // Check the allow patterns, if any
        for (int i = 0; i < allows.length; i++) {
            re.setProgram(allows[i]);
            if (re.match(property)) {
                context.invokeNext(request, response);
                return;
            }
        }
View Full Code Here

            int comma = list.indexOf(',');
            if (comma < 0)
                break;
            String pattern = list.substring(0, comma).trim();
            try {
                reList.add(new RE(pattern));
            } catch (RESyntaxException e) {
                throw new IllegalArgumentException
                    ("Syntax error in request filter pattern");
            }
            list = list.substring(comma + 1);
        }

        RE reArray[] = new RE[reList.size()];
        return ((RE[]) reList.toArray(reArray));

    }   
View Full Code Here

     *
     * @param userAgent user-agent string
     */
    public void addNoCompressionUserAgent(String userAgent) {
        try {
            RE nRule = new RE(userAgent);
            noCompressionUserAgents =
                addREArray(noCompressionUserAgents, nRule);
        } catch (RESyntaxException pse) {
            log.error(sm.getString("http11processor.regexp.error", userAgent), pse);
        }
View Full Code Here

     *
     * @param userAgent user-agent string
     */
    public void addRestrictedUserAgent(String userAgent) {
        try {
            RE nRule = new RE(userAgent);
            restrictedUserAgents = addREArray(restrictedUserAgents, nRule);
        } catch (RESyntaxException pse) {
            log.error(sm.getString("http11processor.regexp.error", userAgent), pse);
        }
    }
View Full Code Here

    /**
     * Match the prepared pattern against the value returned by {@link #getMatchString(Map, Parameters)}.
     */
    public Map preparedMatch(Object preparedPattern, Map objectModel, Parameters parameters) {
       
        RE re = new RE((REProgram)preparedPattern);
        String match = getMatchString(objectModel, parameters);
       
        if (match == null)
            return null;
       
        if(re.match(match)) {
            /* Handle parenthesised subexpressions. XXX: could be faster if we count
             * parens *outside* the generated code.
             * Note: *ONE* based, not zero.
             */
            int parenCount = re.getParenCount();
            Map map = new HashMap();
            for (int paren = 1; paren <= parenCount; paren++) {
                map.put(Integer.toString(paren), re.getParen(paren));
            }

            return map;
        }
       
View Full Code Here

            // configure the factory
            _setup( resolver );

            // setup everything for the current locale
            String[] matches = new RE( "_" ).split( lc );

            String l = matches.length > 0
                    ? matches[0] : Locale.getDefault().getLanguage();
            String c = matches.length > 1 ? matches[1] : "";
            String v = matches.length > 2 ? matches[2] : "";
View Full Code Here

        // the specific locale value
        String lc = (String) params.get( attribute );
        if ( lc != null )
            try {

                String[] matches = new RE( "_" ).split( lc );
                String l = matches.length > 0
                        ? matches[0] : Locale.getDefault().getLanguage();
                String c = matches.length > 1 ? matches[1] : "";
                String v = matches.length > 2 ? matches[2] : "";
                locale = new Locale( l, c, v );
View Full Code Here

TOP

Related Classes of org.apache.regexp.RE

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.