xref: /AOO41X/main/jurt/com/sun/star/lib/uno/environments/remote/Message.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package com.sun.star.lib.uno.environments.remote;
29 
30 import com.sun.star.uno.IMethodDescription;
31 import com.sun.star.uno.ITypeDescription;
32 import com.sun.star.uno.XCurrentContext;
33 
34 /**
35    A remote request or reply message.
36 */
37 public class Message {
38     public Message(
39         ThreadId threadId, boolean request, String objectId,
40         ITypeDescription type, IMethodDescription method, boolean synchronous,
41         XCurrentContext currentContext, boolean abnormalTermination,
42         Object result, Object[] arguments)
43     {
44         this.threadId = threadId;
45         this.request = request;
46         this.objectId = objectId;
47         this.type = type;
48         this.method = method;
49         this.synchronous = synchronous;
50         this.currentContext = currentContext;
51         this.abnormalTermination = abnormalTermination;
52         this.result = result;
53         this.arguments = arguments;
54     }
55 
56     /**
57        Returns the thread ID of the message.
58 
59        <p>Valid for all kinds of messages.</p>
60 
61        @return the (non-<code>null</code>) thread ID
62     */
63     public final ThreadId getThreadId() {
64         return threadId;
65     }
66 
67     /**
68        Returns whether the message is a request or a reply.
69 
70        <p>Valid for all kinds of messages.</p>
71 
72        @return <code>true</code> for a request, <code>false</code> for a reply
73     */
74     public final boolean isRequest() {
75         return request;
76     }
77 
78     /**
79        Returns the object ID of a request message.
80 
81        <p>Valid only for request messages.</p>
82 
83        @return the (non-<code>null</code>) object ID for a request,
84        <code>null</code> for a reply
85     */
86     public final String getObjectId() {
87         return objectId;
88     }
89 
90     /**
91        Returns the type of a request message.
92 
93        <p>Valid only for request messages.</p>
94 
95        @return the (non-<code>null</code>) type for a request, <code>null</code>
96        for a reply
97     */
98     public final ITypeDescription getType() {
99         return type;
100     }
101 
102     /**
103        Returns the method description of a request message.
104 
105        <p>Valid only for request messages.  The returned
106        <code>IMethodDescription</code> is consistent with the type of the
107        message.</p>
108 
109        @return the (non-<code>null</code>) method description for a request,
110        <code>null</code> for a reply
111     */
112     public final IMethodDescription getMethod() {
113         return method;
114     }
115 
116     /**
117        Returns whether the request message is synchronous.
118 
119        <p>Valid only for request messages.</p>
120 
121        @return <code>true</code> for a synchronous request, <code>false</code>
122        for an asynchronous request or a reply
123     */
124     public final boolean isSynchronous() {
125         return synchronous;
126     }
127 
128     /**
129        Returns the current context of a request message.
130 
131        <p>Valid only for request messages.</p>
132 
133        @return the current context (which may be <code>null</code>) for a
134        request, <code>null</code> for a reply
135     */
136     public XCurrentContext getCurrentContext() {
137         return currentContext;
138     }
139 
140     /**
141        Returns whether the reply message represents abnormal termination.
142 
143        <p>Valid only for reply messages.</p>
144 
145        @return <code>true</code> for a reply that represents abnormal
146        termination, <code>false</code> for a reply that represents normal
147        termination or a request
148     */
149     public final boolean isAbnormalTermination() {
150         return abnormalTermination;
151     }
152 
153     /**
154        Returns the result of a reply message.
155 
156        <p>Valid only for reply messages.</p>
157 
158        @return any (possibly <code>null</code>) return value for a reply that
159        represents normal termination, the (non-<code>null</code>) exception for
160        a reply that represents abnormal termination, <code>null</code> for a
161        request
162     */
163     public final Object getResult() {
164         return result;
165     }
166 
167     /**
168        Returns the arguments of a message.
169 
170        <p>Valid only for request messages and reply messages that represent
171        normal termination.  Any returned array must not be modified.</p>
172 
173        @return the in and in&ndash {
174     }out arguments for a request (possibly
175        <code>null</code> for a paramterless function), the out and in&dash {
176     }out
177        arguments for a reply that represents normal termination (possibly
178        <code>null</code> for a parameterless function), <code>null</code> for a
179        reply that represents abnormal termination
180     */
181     public final Object[] getArguments() {
182         return arguments;
183     }
184 
185     private final ThreadId threadId;
186     private final boolean request;
187     private final String objectId;
188     private final ITypeDescription type;
189     private final IMethodDescription method;
190     private final boolean synchronous;
191     private final XCurrentContext currentContext;
192     private final boolean abnormalTermination;
193     private final Object result;
194     private final Object[] arguments;
195 }
196