KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Sample


1 import innoval.mailer.FilterMessage;
2 /*
3 This is a sample InnoVal mail filter class. In creating your own filter
4 classes it is only necessary to add logic to the getResult method. This method
5 must exist as a public boolean method and must return either true or false. If
6 you wish to pass the method string argument(s) from InnoVal's filter
7 procedure, you may do so by entering comma-delimited strings on the filter
8 definition screen. These parameters will automatically be loaded into a
9 string array called parameterValues and will be available to this class.
10 Passing parameters in this way allows you to build multiple
11 filtering scenarios into a single class file.
12
13 The following variables are available to you. You do not need to read the
14 message file (it has been read by the time this class is instantiated and
15 values are loaded into these variables). The variables must be prefaced by
16 the name give the FilterMessage parameter to getResult (in this sample the
17 name is "msg"). So to reference the SUBJECT variable, use msg.SUBJECT in your
18 java statement.
19
20 parameterValues[] an array of strings containing the parameters defined for
21    the given java filter
22 FROM From header (reformed and unfolded)
23 REPLY_TO Reply-to header (reformed and unfolded)
24 TO To header (reformed and unfolded)
25 CC Cc header (reformed and unfolded)
26 BCC Bcc header (reformed and unfolded)
27 DATE Date header
28 SUBJECT Subject header
29 RECEIVED Received header
30 PRIORITY Priority header
31 BODY Text portion of message
32 ALLHEADERS Single string containing all header lines
33 ENTIREMSG Single string containing complete original message
34 MSG_FULLPATH Full path and file name of message file
35 ATTACHMENTS Blank delimited string of attachments
36
37 */

38
39 public class Sample {
40
41   public boolean getResult(FilterMessage msg) {
42     if (msg.SUBJECT.indexOf(msg.parameterValues[0]) >= 0)
43       return(true);
44     else
45       return(false);
46   }
47
48   public Sample() {
49   }
50 /*
51 Within the context of a java filter, you may read the message file, revise its
52 content and rewrite it. You should not, however, rename it or delete it. If
53 you rewrite the file or make copies of the file in other JStreet folders, it
54 is important that it conform to applicable RFC's for POP files.
55 */

56
57 }
58
59
Popular Tags