org.apache.james.transport.matchers
Class HasMailAttributeWithValue

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

public class HasMailAttributeWithValue
extends GenericMatcher

This Matcher determines if the mail contains the attribute specified in the condition and if the value answered when the method toString() is invoked on the attribute is equal to the String value specified in the condition. If both tests are true, all recipients are returned, else null.

Notes:

The current matcher implementation expects a single String value to match on. This matcher requires two values, the attribute name and attribute value. This requires some implicit rules to govern how the single value supplied to the matcher is parsed into two values.

Sample configuration:


 <mailet match="HasMailAttributeWithValue=name, value" class="<any-class>">
 

Since:
2.2.0
Version:
CVS $Revision: 800345 $ $Date: 2009-08-03 14:00:44 +0100 (Mon, 03 Aug 2009) $

Constructor Summary
HasMailAttributeWithValue()
           
 
Method Summary
protected  java.lang.String getAttributeName()
          Returns the attributeName.
protected  java.lang.String getAttributeValue()
          Returns the attributeValue.
 java.lang.String getMatcherInfo()
          Return a string describing this matcher.
 void init()
           
 java.util.Collection match(Mail mail)
          Answers the recipients of the mail if the attribute is present, and has a toString() value equal to the configured value.
protected  void setAttributeName(java.lang.String attributeName)
          Sets the attributeName.
protected  void setAttributeValue(java.lang.String attributeValue)
          Sets the attributeValue.
 
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

HasMailAttributeWithValue

public HasMailAttributeWithValue()
Method Detail

match

public java.util.Collection match(Mail mail)
                           throws javax.mail.MessagingException

Answers the recipients of the mail if the attribute is present, and has a toString() value equal to the configured value.

Specified by:
match in interface Matcher
Specified by:
match in class GenericMatcher
Throws:
javax.mail.MessagingException
See Also:
Matcher.match(Mail)

getAttributeName

protected java.lang.String getAttributeName()
Returns the attributeName.

Returns:
String

getAttributeValue

protected java.lang.String getAttributeValue()
Returns the attributeValue.

Returns:
String

setAttributeName

protected void setAttributeName(java.lang.String attributeName)
Sets the attributeName.

Parameters:
attributeName - The attributeName to set

setAttributeValue

protected void setAttributeValue(java.lang.String attributeValue)
Sets the attributeValue.

Parameters:
attributeValue - The attributeValue to set

init

public void init()
          throws javax.mail.MessagingException
Overrides:
init in class GenericMatcher
Throws:
javax.mail.MessagingException
See Also:
org.apache.mailet.Matcher#init()

getMatcherInfo

public java.lang.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


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