org.apache.james.mailet.standard.matchers
Class HasMailAttributeWithValueRegex

java.lang.Object
  extended by org.apache.mailet.base.GenericMatcher
      extended by org.apache.james.mailet.standard.matchers.HasMailAttributeWithValueRegex
All Implemented Interfaces:
Matcher, MatcherConfig

public class HasMailAttributeWithValueRegex
extends GenericMatcher

This Matcher determines if the mail contains the attribute specified in the condition and that attribute matches the supplied regular expression, it returns all recipients if that is the case.

Sample configuration:


 <mailet match="HasMailAttributeWithValueRegex=whatever," class="<any-class>">
 
Note: as it is not possible to put arbitrary objects in the configuration, toString() is called on the attribute value, and that is the value matched against.

Since:
2.2.0
Version:
CVS $Revision$ $Date$

Constructor Summary
HasMailAttributeWithValueRegex()
           
 
Method Summary
 String getMatcherInfo()
          Return a string describing this matcher.
 void init(MatcherConfig conf)
          Called by the matcher container to indicate to a matcher that the matcher is being placed into service.
 Collection<MailAddress> match(Mail mail)
          Called by the matcher container to allow the matcher to process a message.
 
Methods inherited from class org.apache.mailet.base.GenericMatcher
destroy, getCondition, getMailetContext, getMatcherConfig, getMatcherName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HasMailAttributeWithValueRegex

public HasMailAttributeWithValueRegex()
Method Detail

getMatcherInfo

public String getMatcherInfo()
Return a string describing this matcher.

Specified by:
getMatcherInfo in interface Matcher
Overrides:
getMatcherInfo in class GenericMatcher
Returns:
a string describing this matcher

init

public void init(MatcherConfig conf)
          throws javax.mail.MessagingException
Description copied from class: GenericMatcher

Called by the matcher container to indicate to a matcher that the matcher is being placed into service.

This implementation stores the MatcherConfig object it receives from the matcher container for alter use. When overriding this form of the method, call super.init(config).

Specified by:
init in interface Matcher
Overrides:
init in class GenericMatcher
Parameters:
conf - - the MatcherConfig object that contains configutation information for this matcher
Throws:
javax.mail.MessagingException - if an exception occurs that interrupts the matcher's normal operation

match

public Collection<MailAddress> match(Mail mail)
                              throws javax.mail.MessagingException
Description copied from class: GenericMatcher

Called by the matcher container to allow the matcher to process a message.

This method is declared abstract so subclasses must override it.

Specified by:
match in interface Matcher
Specified by:
match in class GenericMatcher
Parameters:
mail - the mail to check.
Returns:
all recipients if the part of the condition prior to the first equalsign is the name of an attribute set on the mail and the part of the condition after interpreted as a regular expression matches the toString value of the corresponding attributes value.
Throws:
javax.mail.MessagingException - if any error occurs which prevents the Mail matching from completing successfully


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.