KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jivesoftware > messenger > interceptor > PacketRejectedException


1 /**
2  * $RCSfile: PacketRejectedException.java,v $
3  * $Revision: 1.2 $
4  * $Date: 2005/06/28 22:46:49 $
5  *
6  * Copyright (C) 2004 Jive Software. All rights reserved.
7  *
8  * This software is published under the terms of the GNU Public License (GPL),
9  * a copy of which is included in this distribution.
10  */

11
12 package org.jivesoftware.messenger.interceptor;
13
14 import java.io.PrintStream JavaDoc;
15 import java.io.PrintWriter JavaDoc;
16
17 /**
18  * Thrown by a PacketInterceptor when a packet is prevented from being processed. If the packet was
19  * received then it will not be processed and a not_allowed error will be sent back to the sender
20  * of the packet. If the packet was going to be sent then the sending will be aborted.
21  *
22  * @see PacketInterceptor
23  * @author Gaston Dombiak
24  */

25 public class PacketRejectedException extends Exception JavaDoc {
26     private static final long serialVersionUID = 1L;
27
28     private Throwable JavaDoc nestedThrowable = null;
29
30     /**
31      * Text to include in a message that will be sent to the sender of the packet that got
32      * rejected. If no text is specified then no message will be sent to the user.
33      */

34     private String JavaDoc rejectionMessage;
35
36     public PacketRejectedException() {
37         super();
38     }
39
40     public PacketRejectedException(String JavaDoc msg) {
41         super(msg);
42     }
43
44     public PacketRejectedException(Throwable JavaDoc nestedThrowable) {
45         this.nestedThrowable = nestedThrowable;
46     }
47
48     public PacketRejectedException(String JavaDoc msg, Throwable JavaDoc nestedThrowable) {
49         super(msg);
50         this.nestedThrowable = nestedThrowable;
51     }
52
53     public void printStackTrace() {
54         super.printStackTrace();
55         if (nestedThrowable != null) {
56             nestedThrowable.printStackTrace();
57         }
58     }
59
60     public void printStackTrace(PrintStream JavaDoc ps) {
61         super.printStackTrace(ps);
62         if (nestedThrowable != null) {
63             nestedThrowable.printStackTrace(ps);
64         }
65     }
66
67     public void printStackTrace(PrintWriter JavaDoc pw) {
68         super.printStackTrace(pw);
69         if (nestedThrowable != null) {
70             nestedThrowable.printStackTrace(pw);
71         }
72     }
73
74     /**
75      * Retuns the text to include in a message that will be sent to the sender of the packet
76      * that got rejected or <tt>null</tt> if none was defined. If no text was specified then
77      * no message will be sent to the sender of the rejected packet.
78      *
79      * @return the text to include in a message that will be sent to the sender of the packet
80      * that got rejected or <tt>null</tt> if none was defined.
81      */

82     public String JavaDoc getRejectionMessage() {
83         return rejectionMessage;
84     }
85
86     /**
87      * Sets the text to include in a message that will be sent to the sender of the packet
88      * that got rejected or <tt>null</tt> if no message will be sent to the sender of the
89      * rejected packet. Bt default, no message will be sent.
90      *
91      * @param rejectionMessage the text to include in the notification message for the rejection.
92      */

93     public void setRejectionMessage(String JavaDoc rejectionMessage) {
94         this.rejectionMessage = rejectionMessage;
95     }
96 }
97
Popular Tags