Package org.apache.regexp

Examples of org.apache.regexp.RE


    if (s == null)
      return null;

    try
    {
      RE re = REGEX_CACHE.getRegEx(pattern);
      // RE re = new RE(pattern.toLowerCase());
      if (!re.match(s.toLowerCase()))
        return s;

      if (paren < re.getParenCount())
      {
        s = re.getParen(paren);
      }

      return s;
    } catch (Exception e)
    {
View Full Code Here


    public final RE getRegEx(String pattern)
    {
      if (pattern == null)
        return null;
      pattern = pattern.toLowerCase();
      RE result = (RE) map.get(pattern);
      if (result == null)
      {
        result = new RE(pattern);
        map.put(pattern, result);
      }
      // else
      // order.remove(pattern);
      // order.addFirst( pattern);
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) {
                IllegalArgumentException iae = new IllegalArgumentException
                    (sm.getString("requestFilterValve.syntax", pattern));
                jdkCompat.chainException(iae, e);
                throw iae;
            }
            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 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

    /**
     * @return true if the specified input matches the regular expression regex.
     */
    public static boolean matches(String regex, String input)
        throws RESyntaxException {
        RE re = REUtil.createRE(regex);
        return re.match(input);
    }
View Full Code Here

    /**
     * @return true if the specified input matches the regular expression regex.
     */
    public static boolean matches(String regex, String input)
        throws RESyntaxException {
        RE re = REUtil.createRE(regex);
        return re.match(input);
    }
View Full Code Here

     * @param  parameters       Description of the Parameter
     * @return                  Description of the Return Value
     */
    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, zero contains complete match
             */
            int parenCount = re.getParenCount();
            Map map = new HashMap();

            // set defaults
            mapDefaults(parameters, map);

            // override default by matching values
            for (int paren = 0; paren <= parenCount; paren++) {
                getLogger().debug("Matched " +
                        String.valueOf(Integer.toString(paren)) + " " + String.valueOf(re.getParen(paren)));

                map.put(Integer.toString(paren), re.getParen(paren));
            }

            return map;
        }

View Full Code Here

            AsciiArtCoordinate aacEnd = new AsciiArtCoordinate(this.asciiArtPad);
            aacEnd.setTransXY(0, asciiArtPad.getYGrid() / 2);

            // hor line
            try {
                final RE reCorner = new RE(EDGE_GROUP);
                for (int r = 0; r < aa.getH(); r++) {
                    String row = aa.getRow(r);
                    int startIndex = 0;
                    while (reCorner.match(row, startIndex)) {
                        String s = reCorner.getParen(0);
                        int mStart = reCorner.getParenStart(0);
                        int mEnd = reCorner.getParenEnd(0);

                        if (s.equals("\\")) {
                            aacStart.setXY(mStart, r - 1);
                            aacEnd.setXY(mStart + 1, r);
                        } else if (s.equals("/")) {
View Full Code Here

            AsciiArtCoordinate aacEnd = new AsciiArtCoordinate(this.asciiArtPad);
            aacEnd.setTransXY(0, asciiArtPad.getYGrid() / 2);

            // hor line
            try {
                final RE reHorLine = new RE(HLINE_GROUP + "+");
                for (int r = 0; r < aa.getH(); r++) {
                    String row = aa.getRow(r);
                    int startIndex = 0;
                    while (reHorLine.match(row, startIndex)) {
                        int mStart = reHorLine.getParenStart(0);
                        int mEnd = reHorLine.getParenEnd(0);

                        aacStart.setXY(mStart, r);
                        aacEnd.setXY(mEnd - 1, r);
                        AsciiArtLine aal = new AsciiArtLine(aacStart, aacEnd);
                        this.asciiArtPad.add(aal);

                        if (startIndex >= mEnd) {
                            break;
                        }
                        startIndex = mEnd;
                    }
                }
            } catch (RESyntaxException rese) {
                rese.printStackTrace();
            }

            // ver line
            try {
                RE reVerLine = new RE(VLINE_GROUP + "+");
                for (int c = 0; c < aa.getW(); c++) {
                    String col = aa.getColumn(c);
                    int startIndex = 0;
                    while (reVerLine.match(col, startIndex)) {
                        int mStart = reVerLine.getParenStart(0);
                        int mEnd = reVerLine.getParenEnd(0);

                        aacStart.setXY(c, mStart);
                        aacEnd.setXY(c, mEnd - 1);
                        AsciiArtLine aal = new AsciiArtLine(aacStart, aacEnd);
                        this.asciiArtPad.add(aal);
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.