Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 15c78ca400d094bcaaae86483797a079e4d9c1f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
/*
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License).  You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the license at
 * https://glassfish.dev.java.net/public/CDDLv1.0.html or
 * glassfish/bootstrap/legal/CDDLv1.0.txt.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * Header Notice in each file and include the License file
 * at glassfish/bootstrap/legal/CDDLv1.0.txt.
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * you own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 */

package javax.jms;

import java.util.Enumeration;

/** A <CODE>MapMessage</CODE> object is used to send a set of name-value pairs.
 * The names are <CODE>String</CODE> objects, and the values are primitive
 * data types in the Java programming language. The names must have a value that
 * is not null, and not an empty string. The entries can be accessed
 * sequentially or randomly by name. The order of the entries is undefined.
 * <CODE>MapMessage</CODE> inherits from the <CODE>Message</CODE> interface
 * and adds a message body that contains a Map.
 *
 * <P>The primitive types can be read or written explicitly using methods
 * for each type. They may also be read or written generically as objects.
 * For instance, a call to <CODE>MapMessage.setInt("foo", 6)</CODE> is
 * equivalent to <CODE>MapMessage.setObject("foo", new Integer(6))</CODE>.
 * Both forms are provided, because the explicit form is convenient for
 * static programming, and the object form is needed when types are not known
 * at compile time.
 *
 * <P>When a client receives a <CODE>MapMessage</CODE>, it is in read-only
 * mode. If a client attempts to write to the message at this point, a
 * <CODE>MessageNotWriteableException</CODE> is thrown. If
 * <CODE>clearBody</CODE> is called, the message can now be both read from and
 * written to.
 *
 * <P><CODE>MapMessage</CODE> objects support the following conversion table.
 * The marked cases must be supported. The unmarked cases must throw a
 * <CODE>JMSException</CODE>. The <CODE>String</CODE>-to-primitive conversions
 * may throw a runtime exception if the primitive's <CODE>valueOf()</CODE>
 * method does not accept it as a valid <CODE>String</CODE> representation of
 * the primitive.
 *
 * <P>A value written as the row type can be read as the column type.
 *
 * <PRE>
 * |        | boolean byte short char int long float double String byte[]
 * |----------------------------------------------------------------------
 * |boolean |    X                                            X
 * |byte    |          X     X         X   X                  X
 * |short   |                X         X   X                  X
 * |char    |                     X                           X
 * |int     |                          X   X                  X
 * |long    |                              X                  X
 * |float   |                                    X     X      X
 * |double  |                                          X      X
 * |String  |    X     X     X         X   X     X     X      X
 * |byte[]  |                                                        X
 * |----------------------------------------------------------------------
 * </PRE>
 *
 * <P>Attempting to read a null value as a primitive type must be treated
 * as calling the primitive's corresponding <code>valueOf(String)</code>
 * conversion method with a null value. Since <code>char</code> does not
 * support a <code>String</code> conversion, attempting to read a null value
 * as a <code>char</code> must throw a <code>NullPointerException</code>.
 *
 * @version     1.1 February 2, 002
 * @author      Mark Hapner
 * @author      Rich Burridge
 *
 * @see         javax.jms.Session#createMapMessage()
 * @see         javax.jms.BytesMessage
 * @see         javax.jms.Message
 * @see         javax.jms.ObjectMessage
 * @see         javax.jms.StreamMessage
 * @see         javax.jms.TextMessage
 */

public interface MapMessage extends Message
{

  /** Returns the <CODE>boolean</CODE> value with the specified name.
    *
    * @param name the name of the <CODE>boolean</CODE>
    *
    * @return the <CODE>boolean</CODE> value with the specified name
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    * @exception MessageFormatException if this type conversion is invalid.
    */

  boolean getBoolean(String name) throws JMSException;

  /** Returns the <CODE>byte</CODE> value with the specified name.
    *
    * @param name the name of the <CODE>byte</CODE>
    *
    * @return the <CODE>byte</CODE> value with the specified name
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    * @exception MessageFormatException if this type conversion is invalid.
    */

  byte getByte(String name) throws JMSException;

  /** Returns the <CODE>short</CODE> value with the specified name.
    *
    * @param name the name of the <CODE>short</CODE>
    *
    * @return the <CODE>short</CODE> value with the specified name
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    * @exception MessageFormatException if this type conversion is invalid.
    */

  short getShort(String name) throws JMSException;

  /** Returns the Unicode character value with the specified name.
    *
    * @param name the name of the Unicode character
    *
    * @return the Unicode character value with the specified name
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    * @exception MessageFormatException if this type conversion is invalid.
    */

  char getChar(String name) throws JMSException;

  /** Returns the <CODE>int</CODE> value with the specified name.
    *
    * @param name the name of the <CODE>int</CODE>
    *
    * @return the <CODE>int</CODE> value with the specified name
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    * @exception MessageFormatException if this type conversion is invalid.
    */

  int getInt(String name) throws JMSException;

  /** Returns the <CODE>long</CODE> value with the specified name.
    *
    * @param name the name of the <CODE>long</CODE>
    *
    * @return the <CODE>long</CODE> value with the specified name
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    * @exception MessageFormatException if this type conversion is invalid.
    */

  long getLong(String name) throws JMSException;

  /** Returns the <CODE>float</CODE> value with the specified name.
    *
    * @param name the name of the <CODE>float</CODE>
    *
    * @return the <CODE>float</CODE> value with the specified name
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    * @exception MessageFormatException if this type conversion is invalid.
    */

  float getFloat(String name) throws JMSException;

  /** Returns the <CODE>double</CODE> value with the specified name.
    *
    * @param name the name of the <CODE>double</CODE>
    *
    * @return the <CODE>double</CODE> value with the specified name
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    * @exception MessageFormatException if this type conversion is invalid.
    */

  double getDouble(String name) throws JMSException;

  /** Returns the <CODE>String</CODE> value with the specified name.
    *
    * @param name the name of the <CODE>String</CODE>
    *
    * @return the <CODE>String</CODE> value with the specified name; if there
    * is no item by this name, a null value is returned
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    * @exception MessageFormatException if this type conversion is invalid.
    */

  String getString(String name) throws JMSException;

  /** Returns the byte array value with the specified name.
    *
    * @param name the name of the byte array
    *
    * @return a copy of the byte array value with the specified name; if there
    * is no
    * item by this name, a null value is returned.
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    * @exception MessageFormatException if this type conversion is invalid.
    */

  byte[] getBytes(String name) throws JMSException;

  /** Returns the value of the object with the specified name.
    *
    * <P>This method can be used to return, in objectified format,
    * an object in the Java programming language ("Java object") that had
    * been stored in the Map with the equivalent
    * <CODE>setObject</CODE> method call, or its equivalent primitive
    * <CODE>set<I>type</I></CODE> method.
    *
    * <P>Note that byte values are returned as <CODE>byte[]</CODE>, not
    * <CODE>Byte[]</CODE>.
    *
    * @param name the name of the Java object
    *
    * @return a copy of the Java object value with the specified name, in
    * objectified format (for example, if the object was set as an
    * <CODE>int</CODE>, an <CODE>Integer</CODE> is returned); if there is no
    * item by this name, a null value is returned
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    */

  Object getObject(String name) throws JMSException;

  /** Returns an <CODE>Enumeration</CODE> of all the names in the
    * <CODE>MapMessage</CODE> object.
    *
    * @return an enumeration of all the names in this <CODE>MapMessage</CODE>
    *
    * @exception JMSException if the JMS provider fails to read the message
    *                         due to some internal error.
    */

  Enumeration getMapNames() throws JMSException;

  /** Sets a <CODE>boolean</CODE> value with the specified name into the Map.
    *
    * @param name the name of the <CODE>boolean</CODE>
    * @param value the <CODE>boolean</CODE> value to set in the Map
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
    * @exception IllegalArgumentException if the name is null or if the name is
    *                          an empty string.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setBoolean(String name, boolean value) throws JMSException;

  /** Sets a <CODE>byte</CODE> value with the specified name into the Map.
    *
    * @param name the name of the <CODE>byte</CODE>
    * @param value the <CODE>byte</CODE> value to set in the Map
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
   * @exception IllegalArgumentException if the name is null or if the name is
    *                          an empty string.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setByte(String name, byte value) throws JMSException;

  /** Sets a <CODE>short</CODE> value with the specified name into the Map.
    *
    * @param name the name of the <CODE>short</CODE>
    * @param value the <CODE>short</CODE> value to set in the Map
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
     * @exception IllegalArgumentException if the name is null or if the name is
    *                          an empty string.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setShort(String name, short value) throws JMSException;

  /** Sets a Unicode character value with the specified name into the Map.
    *
    * @param name the name of the Unicode character
    * @param value the Unicode character value to set in the Map
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
     * @exception IllegalArgumentException if the name is null or if the name is
    *                          an empty string.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setChar(String name, char value) throws JMSException;

  /** Sets an <CODE>int</CODE> value with the specified name into the Map.
    *
    * @param name the name of the <CODE>int</CODE>
    * @param value the <CODE>int</CODE> value to set in the Map
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
    * @exception IllegalArgumentException if the name is null or if the name is
    *                          an empty string.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setInt(String name, int value) throws JMSException;

  /** Sets a <CODE>long</CODE> value with the specified name into the Map.
    *
    * @param name the name of the <CODE>long</CODE>
    * @param value the <CODE>long</CODE> value to set in the Map
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
    * @exception IllegalArgumentException if the name is null or if the name is
    *                          an empty string.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setLong(String name, long value) throws JMSException;

  /** Sets a <CODE>float</CODE> value with the specified name into the Map.
    *
    * @param name the name of the <CODE>float</CODE>
    * @param value the <CODE>float</CODE> value to set in the Map
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
     * @exception IllegalArgumentException if the name is null or if the name is
    *                          an empty string.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setFloat(String name, float value) throws JMSException;

  /** Sets a <CODE>double</CODE> value with the specified name into the Map.
    *
    * @param name the name of the <CODE>double</CODE>
    * @param value the <CODE>double</CODE> value to set in the Map
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
    * @exception IllegalArgumentException if the name is null or if the name is
    *                          an empty string.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setDouble(String name, double value) throws JMSException;

  /** Sets a <CODE>String</CODE> value with the specified name into the Map.
    *
    * @param name the name of the <CODE>String</CODE>
    * @param value the <CODE>String</CODE> value to set in the Map
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
    * @exception IllegalArgumentException if the name is null or if the name is
    *                          an empty string.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setString(String name, String value) throws JMSException;

  /** Sets a byte array value with the specified name into the Map.
    *
    * @param name the name of the byte array
    * @param value the byte array value to set in the Map; the array
    *              is copied so that the value for <CODE>name</CODE> will
    *              not be altered by future modifications
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
    * @exception NullPointerException if the name is null, or if the name is
    *                          an empty string.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setBytes(String name, byte[] value) throws JMSException;

  /** Sets a portion of the byte array value with the specified name into the
    * Map.
    *
    * @param name the name of the byte array
    * @param value the byte array value to set in the Map
    * @param offset the initial offset within the byte array
    * @param length the number of bytes to use
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
     * @exception IllegalArgumentException if the name is null or if the name is
    *                          an empty string.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setBytes(String name, byte[] value, int offset, int length) throws JMSException;

  /** Sets an object value with the specified name into the Map.
    *
    * <P>This method works only for the objectified primitive
    * object types (<code>Integer</code>, <code>Double</code>,
    * <code>Long</code>&nbsp;...), <code>String</code> objects, and byte
    * arrays.
    *
    * @param name the name of the Java object
    * @param value the Java object value to set in the Map
    *
    * @exception JMSException if the JMS provider fails to write the message
    *                         due to some internal error.
    * @exception IllegalArgumentException if the name is null or if the name is
    *                          an empty string.
    * @exception MessageFormatException if the object is invalid.
    * @exception MessageNotWriteableException if the message is in read-only
    *                                         mode.
    */

  void setObject(String name, Object value) throws JMSException;

  /** Indicates whether an item exists in this <CODE>MapMessage</CODE> object.
    *
    * @param name the name of the item to test
    *
    * @return true if the item exists
    *
    * @exception JMSException if the JMS provider fails to determine if the
    *                         item exists due to some internal error.
    */

  boolean itemExists(String name) throws JMSException;
}

Back to the top