| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mailet.base.GenericMailet
org.apache.james.transport.mailets.ReplaceContent
public class ReplaceContent
Replace text contents
This mailet allow to specific regular expression to replace text in subject and content.
 Each expression is defined as:
 /REGEX_PATTERN/SUBSTITUTION_PATTERN/FLAGS/
 
 REGEX_PATTERN is a regex used for the match
 SUBSTITUTION_PATTERN is a substitution pattern
 FLAGS flags supported for the pattern:
   i: case insensitive
   m: multi line
   x: extended (N/A)
   r: repeat - keep matching until a substitution is possible
 
To identify subject and body pattern we use the tags <subjectPattern> and <bodyPattern>
Rules can be specified in external files. Lines must be CRLF terminated and lines starting with # are considered commments. Tags used to include external files are <subjectPatternFile> and <bodyPatternFile> If file path starts with # then the file is loaded as a reasource.
Use of both files and direct patterns at the same time is allowed.
This mailet allow also to enforce the resulting charset for messages processed. To do that the tag <charset> must be specified.
 NOTE:
 Regexp rules must be escaped by regexp excaping rules and applying this 2 additional rules:
 - "/" char inside an expression must be prefixed with "\":
   e.g: "/\//-//" replaces "/" with "-"
 - when the rules are specified using <subjectPattern> or <bodyPattern> and
   "/,/" has to be used in a pattern string it must be prefixed with a "\".
   E.g: "/\/\/,//" replaces "/" with "," (the rule would be "/\//,//" but the "/,/" must
   be escaped.
 
| Field Summary | |
|---|---|
| static int | FLAG_REPEAT | 
| Constructor Summary | |
|---|---|
| ReplaceContent() | |
| Method Summary | |
|---|---|
| protected static java.lang.String | applyPatterns(java.util.regex.Pattern[] patterns,
              java.lang.String[] substitutions,
              java.lang.Integer[] pflags,
              java.lang.String text,
              int debug,
              GenericMailet logOwner) | 
|  java.lang.String | getMailetInfo()returns a String describing this mailet. | 
| protected static java.lang.Object[] | getPattern(java.lang.String line) | 
| protected static java.util.List[] | getPatternsFromStream(java.io.InputStream stream,
                      java.lang.String charset) | 
| protected static java.util.List[] | getPatternsFromString(java.lang.String pattern) | 
|  void | init() | 
|  void | service(Mail mail) | 
| Methods inherited from class org.apache.mailet.base.GenericMailet | 
|---|
| arrayToString, checkInitParameters, destroy, getInitParameter, getInitParameter, getInitParameter, getInitParameterNames, getMailetConfig, getMailetContext, getMailetName, init, log, log | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final int FLAG_REPEAT
| Constructor Detail | 
|---|
public ReplaceContent()
| Method Detail | 
|---|
public java.lang.String getMailetInfo()
getMailetInfo in interface MailetgetMailetInfo in class GenericMailet
protected static java.lang.Object[] getPattern(java.lang.String line)
                                        throws MailetException
MailetException
protected static java.util.List[] getPatternsFromString(java.lang.String pattern)
                                                 throws MailetException
MailetException
protected static java.util.List[] getPatternsFromStream(java.io.InputStream stream,
                                                        java.lang.String charset)
                                                 throws MailetException,
                                                        java.io.IOException
MailetException
java.io.IOException
protected static java.lang.String applyPatterns(java.util.regex.Pattern[] patterns,
                                                java.lang.String[] substitutions,
                                                java.lang.Integer[] pflags,
                                                java.lang.String text,
                                                int debug,
                                                GenericMailet logOwner)
public void init()
          throws MailetException
init in class GenericMailetMailetException
public void service(Mail mail)
             throws MailetException
service in interface Mailetservice in class GenericMailetMailetException| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||