1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package com.sun.star.lib.uno.environments.remote;
25 
26 import com.sun.star.uno.IMethodDescription;
27 import com.sun.star.uno.ITypeDescription;
28 import com.sun.star.uno.XCurrentContext;
29 
30 /**
31    A remote request or reply message.
32 */
33 public class Message {
Message( ThreadId threadId, boolean request, String objectId, ITypeDescription type, IMethodDescription method, boolean synchronous, XCurrentContext currentContext, boolean abnormalTermination, Object result, Object[] arguments)34     public Message(
35         ThreadId threadId, boolean request, String objectId,
36         ITypeDescription type, IMethodDescription method, boolean synchronous,
37         XCurrentContext currentContext, boolean abnormalTermination,
38         Object result, Object[] arguments)
39     {
40         this.threadId = threadId;
41         this.request = request;
42         this.objectId = objectId;
43         this.type = type;
44         this.method = method;
45         this.synchronous = synchronous;
46         this.currentContext = currentContext;
47         this.abnormalTermination = abnormalTermination;
48         this.result = result;
49         this.arguments = arguments;
50     }
51 
52     /**
53        Returns the thread ID of the message.
54 
55        <p>Valid for all kinds of messages.</p>
56 
57        @return the (non-<code>null</code>) thread ID
58     */
getThreadId()59     public final ThreadId getThreadId() {
60         return threadId;
61     }
62 
63     /**
64        Returns whether the message is a request or a reply.
65 
66        <p>Valid for all kinds of messages.</p>
67 
68        @return <code>true</code> for a request, <code>false</code> for a reply
69     */
isRequest()70     public final boolean isRequest() {
71         return request;
72     }
73 
74     /**
75        Returns the object ID of a request message.
76 
77        <p>Valid only for request messages.</p>
78 
79        @return the (non-<code>null</code>) object ID for a request,
80        <code>null</code> for a reply
81     */
getObjectId()82     public final String getObjectId() {
83         return objectId;
84     }
85 
86     /**
87        Returns the type of a request message.
88 
89        <p>Valid only for request messages.</p>
90 
91        @return the (non-<code>null</code>) type for a request, <code>null</code>
92        for a reply
93     */
getType()94     public final ITypeDescription getType() {
95         return type;
96     }
97 
98     /**
99        Returns the method description of a request message.
100 
101        <p>Valid only for request messages.  The returned
102        <code>IMethodDescription</code> is consistent with the type of the
103        message.</p>
104 
105        @return the (non-<code>null</code>) method description for a request,
106        <code>null</code> for a reply
107     */
getMethod()108     public final IMethodDescription getMethod() {
109         return method;
110     }
111 
112     /**
113        Returns whether the request message is synchronous.
114 
115        <p>Valid only for request messages.</p>
116 
117        @return <code>true</code> for a synchronous request, <code>false</code>
118        for an asynchronous request or a reply
119     */
isSynchronous()120     public final boolean isSynchronous() {
121         return synchronous;
122     }
123 
124     /**
125        Returns the current context of a request message.
126 
127        <p>Valid only for request messages.</p>
128 
129        @return the current context (which may be <code>null</code>) for a
130        request, <code>null</code> for a reply
131     */
getCurrentContext()132     public XCurrentContext getCurrentContext() {
133         return currentContext;
134     }
135 
136     /**
137        Returns whether the reply message represents abnormal termination.
138 
139        <p>Valid only for reply messages.</p>
140 
141        @return <code>true</code> for a reply that represents abnormal
142        termination, <code>false</code> for a reply that represents normal
143        termination or a request
144     */
isAbnormalTermination()145     public final boolean isAbnormalTermination() {
146         return abnormalTermination;
147     }
148 
149     /**
150        Returns the result of a reply message.
151 
152        <p>Valid only for reply messages.</p>
153 
154        @return any (possibly <code>null</code>) return value for a reply that
155        represents normal termination, the (non-<code>null</code>) exception for
156        a reply that represents abnormal termination, <code>null</code> for a
157        request
158     */
getResult()159     public final Object getResult() {
160         return result;
161     }
162 
163     /**
164        Returns the arguments of a message.
165 
166        <p>Valid only for request messages and reply messages that represent
167        normal termination.  Any returned array must not be modified.</p>
168 
169        @return the in and in&ndash {
170     }out arguments for a request (possibly
171        <code>null</code> for a paramterless function), the out and in&dash {
172     }out
173        arguments for a reply that represents normal termination (possibly
174        <code>null</code> for a parameterless function), <code>null</code> for a
175        reply that represents abnormal termination
176     */
getArguments()177     public final Object[] getArguments() {
178         return arguments;
179     }
180 
181     private final ThreadId threadId;
182     private final boolean request;
183     private final String objectId;
184     private final ITypeDescription type;
185     private final IMethodDescription method;
186     private final boolean synchronous;
187     private final XCurrentContext currentContext;
188     private final boolean abnormalTermination;
189     private final Object result;
190     private final Object[] arguments;
191 }
192