KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quadcap > pop3 > client > HookShell


1 package com.quadcap.pop3.client;
2
3 /*
4  * Copyright 1997 - 2003 by Stan Bailes and Quadcap Software.
5  *
6  **/

7
8 import java.io.IOException JavaDoc;
9 import java.io.InputStream JavaDoc;
10
11 import java.util.Map JavaDoc;
12 import java.util.Properties JavaDoc;
13
14 /**
15  * Interface for message delivery.
16  *
17  * @author Stan Bailes
18  */

19 public class HookShell implements MessageHook {
20     /**
21      * Initialize the hook with its property set
22      */

23     public void init(Properties JavaDoc p) {
24     }
25
26     /**
27      * Return <code>true</code> if the call to
28      * <code>boolean passHeaders(Map headers)</code> will always return
29      * true, so the message receiver can avoid calling it.
30      */

31     public boolean passAllHeaders() { return false; }
32
33     /**
34      * A hook first gets called with the parsed headers from the message.
35      * If the hook returns 'true' to this call, it will be called again
36      * to process the body using <code>sendMessage()</code>, below.
37      */

38     public boolean passHeaders(Map JavaDoc headers) {
39         return "shell".equals(headers.get("X-MessageHook"));
40     }
41
42     /**
43      * The hook is called to process the entire message (including headers)
44      * as an octet stream.
45      *
46      * @return <code>false</code> if the message is to be retained in
47      * the store, <code>true</code> to delete it.
48      */

49     public boolean passMessage(InputStream JavaDoc is) throws IOException JavaDoc {
50         return false;
51     }
52 }
53
Popular Tags