org.apache.james.transport.matchers
Class HasMailAttributeWithValue

java.lang.Object
  extended by org.apache.mailet.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: 494012 $ $Date: 2007-01-08 10:23:58 +0000 (lun, 08 gen 2007) $

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(MatcherConfig config)
          Called by the matcher container to indicate to a matcher that the matcher is being placed into service.
 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.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
Parameters:
mail - - the Mail object that contains the MimeMessage and routing information
Returns:
java.util.Collection - the recipients that the mailet container should have the mailet affect.
Throws:
MessagingException - - if an message or address parsing exception occurs or an exception that interferes with the matcher's normal operation
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(MatcherConfig config)
          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:
config - - a MatcherConfig object containing the matcher's configuration and initialization parameters
Throws:
javax.mail.MessagingException - if an exception occurs that interrupts the matcher's normal operation
See Also:
Matcher.init(MatcherConfig)

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 © 2002-2007 The Apache Software Foundation. All Rights Reserved.