You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by pg...@apache.org on 2002/10/04 06:56:46 UTC

cvs commit: jakarta-james/src/java/org/apache/james/transport/matchers HasHeader.java

pgoldstein    2002/10/03 21:56:46

  Added:       src/java/org/apache/james/transport/matchers HasHeader.java
  Log:
  Adding HasHeader matcher.
  Thanks to Noel Bergman
  
  Revision  Changes    Path
  1.1                  jakarta-james/src/java/org/apache/james/transport/matchers/HasHeader.java
  
  Index: HasHeader.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.james.transport.matchers;
  
  import org.apache.mailet.GenericMatcher;
  import org.apache.mailet.Mail;
  
  import java.util.Collection;
  
  /**
   * use: <mailet match="HasHeader=<header>" class="..." />
   *
   * This matcher simply checks to see if the header named is present.
   * If complements the AddHeader mailet.
   *
   * TODO: support lists of headers and values, e.g, match="{<header>[=value]}+"
   *       [will require a complete rewrite from the current trivial one-liner]
   *
   * @author  Noel J. Bergman <no...@devtech.com>
   */
  public class HasHeader extends GenericMatcher {
  
      public Collection match(Mail mail) throws javax.mail.MessagingException {
          return (mail.getMessage().getHeader(getCondition(), null) != null) ? mail.getRecipients() : null;
      }
  }
  
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>