Package gnu.regexp

Examples of gnu.regexp.RE


  public void validate(View view) throws ValidationException, GUIException {
    TextField field = (TextField) view;
    String validationString = field.getText();

    RE r = null;

    try {
      r = new RE(sPattern);
    } catch (Exception e) {
      throw new GUIException("Error while constructing a regular expression", e);
    }

    if (r != null) {
      if (!r.isMatch(validationString)) {
        throw new ValidationException(view, InternationalizationManager.getString("xmlgui.validator.email.invalid"));
      }
    }
  }
View Full Code Here


  public void validate(View view) throws ValidationException, GUIException {
    TextField field = (TextField) view;
    String validationString = field.getText();

    RE r = null;

    try {
      r = new RE(sPattern);
    } catch (Exception e) {
      throw new GUIException("Error while constructing a regular expression", e);
    }

    if (r != null) {
      if (!r.isMatch(validationString)) {
        throw new ValidationException(view, InternationalizationManager.getString("xmlgui.validator.phone.invalid"));
      }
    }
  }
View Full Code Here

    TextField field = (TextField) view;
    String validationString = field.getText();
   
    if (validationString.trim().length() >= 1) {
     
      RE r = null;
      try {
        r = new RE(sPattern);
      } catch (Exception e) {
        throw new GUIException("Error while constructing a regular expression", e);
      }

      if (r != null) {
        if (!r.isMatch(validationString)) {
          throw new ValidationException(view, InternationalizationManager.getString("xmlgui.validator.phone.invalid"));
        }
      }
    }
  }
View Full Code Here

    }
   
    public boolean match(String message) {       
        if ( message != null && expression != null ) {                   
            try {               
                RE re = new RE(expression,RE.REG_ICASE);
                REMatch[] matches = re.getAllMatches(message);           
                if ( matches.length > 0 ) {
                    return true;
                }                           
            }
            catch (Exception e) {
View Full Code Here

    public String parseLine(LogRecord lr,String format) {
        String ret = format;
        try {
          String expression = "\\$\\{([^\\}]+)\\}";
            RE re = new RE(expression);
            REMatch[] matches = re.getAllMatches(format);
            for ( int i = 0; i < matches.length;i++) {
                String token = matches[i].toString(1);
                String placeHolder = matches[i].toString(1);
                String txt = null;
                if ( token.startsWith("${")) {
                    token = token.substring(2);
                }
                if ( token.endsWith("}")) {
                    token = token.substring(0,token.length()-1);
                }
                if ( token.indexOf(":") != -1 ) {
                    token = token.substring(0,token.indexOf(":"));
                    txt = placeHolder.substring(placeHolder.indexOf(":")+1);
                    txt = txt.substring(0,txt.length());
                }
                String match = null;
                if ( tokens.containsKey(token)) {
                    FormatterToken ft = (FormatterToken)tokens.get(token);
                    if ( txt != null ) {
                        ft.setParameterString(txt);
                    }
                    match = ft.format(lr);
                }
                if ( match != null ) {
                    ret = re.substitute(ret,match);
                }
            }
            return ret;
        }
        catch (Exception e) {
View Full Code Here

         }
         this.pattern = new String(rPat, 0, j);
      }
     
      try {
         this.regex = new RE(this.pattern, RE.REG_ICASE);
      }
      catch (REException ex) {
         throw new XmlBlasterException(null, ErrorCode.USER_CONFIGURATION, "FilenameFilter", "wrong regex expression for filter '" + this.pattern + "'", ex);
      }
      //this.pattern = Pattern.compile(new String(rPat, 0, j), Pattern.CASE_INSENSITIVE);
View Full Code Here

      if (msgUnit == null) {
         Thread.dumpStack();
         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Illegal argument in regex match() call");
      }

      RE expression;
      if (query.getPreparedQuery() == null) {
         try {
            expression = new RE(query.getQuery());
            query.setPreparedQuery(expression); // for better performance we remember the regex expression
         } catch (gnu.regexp.REException e) {
            log.severe("Can't compile regular filter expression '" + query + "':" + e.toString());
            throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME, "Can't compile regular filter expression '" + query + "':" + e.toString());
         }
      }
      else
         expression = (RE)query.getPreparedQuery();

      return expression.isMatch(msgUnit.getContentStr());
   }
View Full Code Here

         }
         this.pattern = new String(rPat, 0, j);
      }
     
      try {
         this.regex = new RE(this.pattern, RE.REG_ICASE);
      }
      catch (REException ex) {
         throw new XmlBlasterException(null, ErrorCode.USER_CONFIGURATION, "FilenameFilter", "wrong regex expression for filter '" + this.pattern + "'", ex);
      }
      //this.pattern = Pattern.compile(new String(rPat, 0, j), Pattern.CASE_INSENSITIVE);
View Full Code Here

  return 0;
      }
    }       
   
    InputStream is = null;
    RE pattern = null;
    int optind = g.getOptind();
    if (optind >= argv.length) {
      System.err.println("Usage: java " + PROGNAME + " [OPTION]... PATTERN [FILE]...");
      System.err.println("Try `java " + PROGNAME + " --help' for more information.");
      return 2;
    }
    try {
      pattern = new RE(argv[g.getOptind()],cflags,syntax);
    } catch (REException e) {
      System.err.println("Error in expression: "+e);
      return 2;
    }
    int retval = 1;
View Full Code Here

      if (log.isLoggable(Level.FINE)) this.log.fine("constructor regexPattern='" + tmp + "'");
   }

   try {
      this.regexPattern = tmp;
      this.expression = new RE(tmp);
   }
   catch (REException ex) {
      if (log.isLoggable(Level.FINE)) this.log.fine("constructor " + Global.getStackTraceAsString(ex));
      throw new XmlBlasterException(this.global, ErrorCode.USER_ILLEGALARGUMENT, ME + " constructor: could not generate a Regex from the string '" + pattern + "' reason: " + ex.getMessage());
   }
View Full Code Here

TOP

Related Classes of gnu.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.