Package org.apache.regexp

Examples of org.apache.regexp.RE


            this.index = 0;

            while (cache.hasMoreElements() == true) {
                this.add(cache.nextElement().toString());
            }
            RE re = null;

            try {
                re = new RE("^" + cachedir);
            } catch(RESyntaxException ree) {
                ree.printStackTrace();
            }

            while (fs.hasMoreElements() == true) {
                final String key = fs.nextElement().toString();
                if (re.match(cachedir) == true) {
                    this.add(key);
                }
            }
        }
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 ree) {
            log.error("Error parsing regular expression: " + userAgent, ree);
        }
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 ree) {
            log.error("Error parsing regular expression: " + userAgent, ree);
        }
    }
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
                    (sm.getString("requestFilterValve.syntax", pattern));
            }
            list = list.substring(comma + 1);
        }

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

    }
View Full Code Here

     *          expression.
     */
    public Filter addAttribute(String expression,Object substitution)
    {
        try {
            RE r = new RE(expression);
            put(r, substitution);
        }
        catch (RESyntaxException e) {
            return null;
        }
View Full Code Here

     */
    public Filter removeAttribute(String expression)
    {
        try
        {
             RE r = new RE(expression);
             remove(r);
        }
        catch(Exception e)
        {
        }
View Full Code Here

     * as an argument.
     */
    public boolean hasAttribute(String expression)
    {
        try {
            RE r = new RE(expression);
            return containsKey(r);
        }
        catch (Exception e) {
        }
        return false;
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

         * @param  excludeName            Description of Parameter
         * @exception  RESyntaxException  Description of Exception
         * @since
         */
        public ElementAttributeMatching(String includeName, String excludeName) throws RESyntaxException {
            includeNameRE = new RE(includeName, RE.MATCH_CASEINDEPENDENT);
            excludeNameRE = new RE(excludeName, RE.MATCH_CASEINDEPENDENT);
        }
View Full Code Here

            // Validate wheter param matches regular expression
            if (!"".equals (regex)) {
                getLogger().debug ("String parameter " + name +
                        " should match regexp \"" + regex + "\"" );
                try {
                    RE r = new RE ( regex );
                    if ( !r.match(value) ) {
                        getLogger().debug("and it does not match");
                        return new ValidatorActionHelper ( value, ValidatorActionResult.NOMATCH);
                    };
                } catch ( RESyntaxException rese ) {
                    getLogger().error ("String parameter " + name +
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.