|
||||||||||
| 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.mailet.standard.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 String |
applyPatterns(Pattern[] patterns,
String[] substitutions,
Integer[] pflags,
String text,
int debug,
GenericMailet logOwner)
|
String |
getMailetInfo()
returns a String describing this mailet. |
protected static PatternBean |
getPattern(String line)
|
protected static PatternList |
getPatternsFromStream(InputStream stream,
String charset)
|
protected static PatternList |
getPatternsFromString(String pattern)
|
void |
init()
A convenience method which can be overridden so that there's no need to call super.init(config). |
void |
service(Mail mail)
Called by the mailet container to allow the mailet to process a message. |
| 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 String getMailetInfo()
getMailetInfo in interface MailetgetMailetInfo in class GenericMailet
protected static PatternBean getPattern(String line)
throws MailetException
MailetException
protected static PatternList getPatternsFromString(String pattern)
throws MailetException
MailetException
protected static PatternList getPatternsFromStream(InputStream stream,
String charset)
throws MailetException,
IOException
MailetException
IOException
protected static String applyPatterns(Pattern[] patterns,
String[] substitutions,
Integer[] pflags,
String text,
int debug,
GenericMailet logOwner)
public void init()
throws MailetException
GenericMailetA convenience method which can be overridden so that there's no need to call super.init(config).
Instead of overriding init(MailetConfig), simply override this method and it will be called by GenericMailet.init(MailetConfig config). The MailetConfig object can still be retrieved via getMailetConfig().
init in class GenericMailetMailetException
public void service(Mail mail)
throws MailetException
GenericMailetCalled by the mailet container to allow the mailet to process a message.
This method is declared abstract so subclasses must override it.
service in interface Mailetservice in class GenericMailetmail - - the Mail object that contains the MimeMessage and
routing information
MailetException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||