KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > extend > Reply


1 /*
2  * Copyright 2005 Joe Walker
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.directwebremoting.extend;
17
18 /**
19  * Reply is a read-only POJO to encapsulate the information required to make a
20  * single java call, including the result of the call (either returned data or
21  * exception).
22  * @author Joe Walker [joe at getahead dot ltd dot uk]
23  */

24 public class Reply
25 {
26     /**
27      * Constructor for the success case.
28      * @param callId The call callId, copied from the Call object
29      * @param reply The successful reply data
30      */

31     public Reply(String JavaDoc callId, Object JavaDoc reply)
32     {
33         this.callId = callId;
34         this.reply = reply;
35     }
36
37     /**
38      * Constructor for the error case.
39      * Reply <b>must</b> be set to null for this constructor to work. This
40      * parameter exists to avoid overloading issues. See Java Puzzlers #46 for
41      * an example.
42      * @param callId The call callId, copied from the Call object
43      * @param reply Must be set to null
44      * @param th The exception to record against this call.
45      */

46     public Reply(String JavaDoc callId, Object JavaDoc reply, Throwable JavaDoc th)
47     {
48         if (reply != null)
49         {
50             throw new NullPointerException JavaDoc("'reply' must be null when setting an Exception.");
51         }
52
53         this.callId = callId;
54         this.th = th;
55     }
56
57     /**
58      * @return Returns the call callId.
59      */

60     public String JavaDoc getCallId()
61     {
62         return callId;
63     }
64
65     /**
66      * @return Returns the call return value.
67      */

68     public Object JavaDoc getReply()
69     {
70         return reply;
71     }
72
73     /**
74      * @return Returns the Exception
75      */

76     public Throwable JavaDoc getThrowable()
77     {
78         return th;
79     }
80
81     private String JavaDoc callId = null;
82
83     private Object JavaDoc reply = null;
84
85     private Throwable JavaDoc th = null;
86 }
87
Popular Tags