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 vi...@apache.org on 2003/06/23 20:46:21 UTC
cvs commit: jakarta-james/src/java/org/apache/james/transport/matchers RecipientIsRegex.java
vincenzo 2003/06/23 11:46:21
Modified: src/java/org/apache/james/transport/matchers
RecipientIsRegex.java
Log:
More javadoc, in sync with new SenderIsRegex, plus better logging of exceptions if caught during init.
Revision Changes Path
1.3 +24 -14 jakarta-james/src/java/org/apache/james/transport/matchers/RecipientIsRegex.java
Index: RecipientIsRegex.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/matchers/RecipientIsRegex.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RecipientIsRegex.java 27 May 2003 08:51:20 -0000 1.2
+++ RecipientIsRegex.java 23 Jun 2003 18:46:21 -0000 1.3
@@ -63,18 +63,22 @@
import org.apache.oro.text.regex.*;
+import javax.mail.MessagingException;
+
/**
- * Uses regular expression
+ * <P>Matches recipients whose address matches a regular expression.</P>
+ * <P>Is equivalent to the {@link SenderIsRegex} matcher but matching on the recipient.</P>
+ * <P>Configuration string: a regular expression.</P>
+ * <PRE><CODE>
+ * <mailet match="RecipientIsRegex=<regular-expression>" class="<any-class>">
+ * </CODE></PRE>
+ * <P>The example below will match any recipient in the format user@log.anything</P>
+ * <PRE><CODE>
+ * <mailet match="RecipientIsRegex=(.*)@log\.(.*)" class="<any-class>">
+ * </mailet>
+ * </CODE></PRE>
*
- *<p><mailet match="RecipientMatch=<regular-expression>"
-class="<any-class>"></p>
- * <p>The example below will match any recipient in the format
-user@log.anything</p>
- * <p><mailet match="RecipientMatch=(.*)@log\.(.*)"
-class="<any-class>"><br>
- * </mailet><br>
- * </p>
- * @version 1.0.0, 27/06/2002
+ * @version CVS $Revision$ $Date$
*/
public class RecipientIsRegex extends GenericRecipientMatcher {
@@ -85,16 +89,22 @@
Pattern pattern = null;
public void init() throws javax.mail.MessagingException {
+ String patternString = getCondition();
+ if (patternString == null) {
+ throw new MessagingException("Pattern is missing");
+ }
+
+ patternString = patternString.trim();
try {
- pattern = compiler.compile( getCondition() );
- } catch(MalformedPatternException e) {
- e.printStackTrace();
+ pattern = compiler.compile(patternString);
+ } catch(MalformedPatternException mpe) {
+ throw new MessagingException("Malformed pattern: " + patternString, mpe);
}
}
public boolean matchRecipient(MailAddress recipient) {
String myRecipient = recipient.toString();
- if ( matcher.matches( myRecipient, pattern) ){
+ if (matcher.matches(myRecipient, pattern)){
return true;
} else {
return false;
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org