Package org.apache.oro.text.regex

Examples of org.apache.oro.text.regex.Perl5Matcher


  }

 
  private boolean checkEmail(String email)
  {
    return new Perl5Matcher().matches(email, EMAIL_PATTERN);
  }
View Full Code Here


  /// @return New sequence containing selected elements
  public static final Object[] p_grep = new Object[] { null, "pattern" };
  public Any m_grep(Context context, Any pattern_)
  {
    Pattern pattern = ObjectPool.createPattern(context, pattern_);
    Perl5Matcher matcher = new Perl5Matcher();
    AnySequence matched = createEmptySequence();
    int size = getSize();
    for(int i=0; i<size; i++) {
      Any element = getElement(i);
      if (matcher.contains(element.toString(), pattern)) {
        matched = matched.append(element);
      }
    } 
    return matched;
  }  
View Full Code Here

  String sAllowPattern, sDenyPattern;
    ArrayList<String> oRecipientsWithoutDuplicates;
    boolean bAllowed;

  Pattern oAllowPattern=null, oDenyPattern=null;
  Perl5Matcher oMatcher = new Perl5Matcher();
  Perl5Compiler oCompiler = new Perl5Compiler();
   
    if (aEMails!=null) {
      if (aEMails.length>0) {
        if (aRecipients==null) {
          aRecipients = aEMails;
        } else {
          aRecipients = concatArrays(aRecipients, aEMails);
        } // fi (aRecipients!=null)
        final int nRecipients = aRecipients.length;
        Arrays.sort(aRecipients, String.CASE_INSENSITIVE_ORDER);
   
    oRecipientsWithoutDuplicates = new ArrayList<String>(nRecipients);

      sAllowPattern = getAllowPattern();
      sDenyPattern = getDenyPattern();
     
      if (sAllowPattern.length()>0) {
        oAllowPattern = oCompiler.compile(sAllowPattern, Perl5Compiler.CASE_INSENSITIVE_MASK);
      }

      if (sDenyPattern.length()>0) {
        oDenyPattern = oCompiler.compile(sDenyPattern, Perl5Compiler.CASE_INSENSITIVE_MASK);
      }
       
      for (int r=0; r<nRecipients-1; r++) {
      bAllowed = true;
      try {
        if (sAllowPattern.length()>0) bAllowed &= oMatcher.matches(aRecipients[r], oAllowPattern);
      } catch (ArrayIndexOutOfBoundsException aiob) {
        throw new ArrayIndexOutOfBoundsException("Gadgets.matches("+aRecipients[r]+","+sAllowPattern+")");
      }
      try {
      if (sDenyPattern.length()>0) bAllowed &= !oMatcher.matches(aRecipients[r], oDenyPattern);
      } catch (ArrayIndexOutOfBoundsException aiob) {
        throw new ArrayIndexOutOfBoundsException("Gadgets.matches("+aRecipients[r]+","+sDenyPattern+")");
      }
      if (bAllowed) {
          if (!aRecipients[r].equalsIgnoreCase(aRecipients[r+1])) {
View Full Code Here

                                 String sId, String [] aAttachmentsPath,
                                 String sBasePath)
  throws IOException,MessagingException,IllegalArgumentException,SecurityException {

  PatternCompiler oCompiler = new Perl5Compiler();
  PatternMatcher oMatcher = new Perl5Matcher();
 
  String sContentType = (sHtmlBody==null ? "plain" : "html");
 
  if (DebugFile.trace) {
    DebugFile.writeln("Begin SessionHandler.composeMessage("+sSubject+","+sEncoding+",...,"+sId+","+sContentType+")");
View Full Code Here

  public void setEmail(String sAttendantEmail)
    throws IllegalArgumentException {

    try {
    if (!new Perl5Matcher().matches(sAttendantEmail, new Perl5Compiler().compile("[\\w\\x2E_-]+@[\\w\\x2E_-]+\\x2E\\D{2,4}",Perl5Compiler.CASE_INSENSITIVE_MASK)))
      throw new IllegalArgumentException("Invalid e-mail syntax");
    } catch (MalformedPatternException neverthrown) { }

    if (sAttendantEmail.length()>100)
      throw new IllegalArgumentException("e-mail may not exceed 100 characters");
View Full Code Here

      if (oMatcher.contains(sBase, oPattern)) {
        MatchResult oMtrs = oMatcher.getMatch();
        if (oMtrs!=null) sMatch = oMtrs.toString();
        if (sMatch.length()==0) {
          oCompiler = new Perl5Compiler();
          oMatcher = new Perl5Matcher();
          oPattern = oCompiler.compile(sPattern, Perl5Compiler.SINGLELINE_MASK);
          if (oMatcher.contains(sBase, oPattern)) {
            oMtrs = oMatcher.getMatch();
            if (oMtrs!=nullsMatch = oMtrs.toString();
          }
View Full Code Here

  protected Zone accept(String pathinfo, int start)
  {
    if (_pattern != null) {
      PatternMatcherInput input = new PatternMatcherInput(pathinfo, start, pathinfo.length()-start);
      Perl5Matcher matcher = new Perl5Matcher();
      if (matcher.contains(input, _pattern)) {
        return resolveZone(pathinfo, start);
      }
    } else {
      String pi = _pathinfo;
      int pi_length = pi.length();
View Full Code Here

        list = (AnyList)matches_;
      }
    }
   
    Pattern pattern = ObjectPool.createPattern(context, pattern_);
    Perl5Matcher matcher = new Perl5Matcher();
    if (isMatch ? matcher.matches(_string, pattern)
                : matcher.contains(_string, pattern))
    {
      if (array != null) {
        MatchResult match = matcher.getMatch();
        array.clear();
        int n = match.groups();
        for(int i=0; i<n; i++) {
          array.append(Any.create(match.group(i)));
        }
        return array;

      } else if (list != null) {
        MatchResult match = matcher.getMatch();
        list.clear();
        int n = match.groups();
        for(int i=0; i<n; i++) {
          list.append(Any.create(match.group(i)));
        }
View Full Code Here

  /// @throws MalformedPattern If pattern is invalid
  public static final Object[] p_split = new Object[] { null, "pattern" };
  public Any m_split(Context context, Any pattern_)
  {
    Pattern pattern = ObjectPool.createPattern(context, pattern_);
    Perl5Matcher matcher = new Perl5Matcher();
    Vector parts = Util.split(matcher, pattern, _string);
    int n = parts.size();
    Any[] list = new Any[n];
    for(int i=0; i<n; i++) {
      list[i] = Any.create(parts.elementAt(i).toString());
View Full Code Here

    } else {
      substitution = new AnyUtils.FunctionSubstitute(context, replacement);
    }
   
    Pattern pattern = ObjectPool.createPattern(context, pattern_);
    Perl5Matcher matcher = new Perl5Matcher();
    return Any.create(Util.substitute(matcher, pattern, substitution, _string, flags));
  }
View Full Code Here

TOP

Related Classes of org.apache.oro.text.regex.Perl5Matcher

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.