KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > api > jms > MantaMapMessage


1 /*
2  * Copyright 2002 by
3  * <a HREF="http://www.coridan.com">Coridan</a>
4  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is "MantaRay" (TM).
17  *
18  * The Initial Developer of the Original Code is Nimo 23-MAR-2004.
19  * Portions created by the Initial Developer are Copyright (C) 2006
20  * Coridan Inc. All Rights Reserved.
21  *
22  * Contributor(s): all the names of the contributors are added in the source
23  * code where applicable.
24  *
25  * Alternatively, the contents of this file may be used under the terms of the
26  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
27  * provisions of LGPL are applicable instead of those above. If you wish to
28  * allow use of your version of this file only under the terms of the LGPL
29  * License and not to allow others to use your version of this file under
30  * the MPL, indicate your decision by deleting the provisions above and
31  * replace them with the notice and other provisions required by the LGPL.
32  * If you do not delete the provisions above, a recipient may use your version
33  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
34  
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Lesser General Public License as published by the Free Software Foundation;
39  * either version 2.1 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
44  * License for more details.
45  */

46 package org.mr.api.jms;
47 import java.io.IOException JavaDoc;
48 import java.util.Enumeration JavaDoc;
49 import java.util.HashMap JavaDoc;
50 import java.util.Iterator JavaDoc;
51 import java.util.Map JavaDoc;
52
53 import javax.jms.JMSException JavaDoc;
54 import javax.jms.MapMessage JavaDoc;
55 import javax.jms.MessageFormatException JavaDoc;
56 import javax.jms.MessageNotWriteableException JavaDoc;
57
58 import org.mr.core.util.byteable.Byteable;
59 import org.mr.core.util.byteable.ByteableInputStream;
60 import org.mr.core.util.byteable.ByteableOutputStream;
61 import org.mr.core.util.byteable.ByteableRegistry;
62
63 /**
64  * A MapMessage object is used to send a set of name-value pairs. The names are String
65  * objects, and the values are primitive data types in the Java programming language.
66  * The names must have a value that is not null, and not an empty string. The entries
67  * can be accessed sequentially or randomly by name. The order of the entries is undefined.
68  * MapMessage inherits from the Message interface and adds a message body that contains a
69  * Map. The primitive types can be read or written explicitly using methods for each type.
70  * They may also be read or written generically as objects. For instance, a call to
71  * MapMessage.setInt("foo", 6) is equivalent to MapMessage.setObject("foo", new Integer(6)).
72  * Both forms are provided, because the explicit form is convenient for static programming,
73  * and the object form is needed when types are not known at compile time. When a client
74  * receives a MapMessage, it is in read-only mode. If a client attempts to write to the
75  * message at this point, a MessageNotWriteableException is thrown. If clearBody is called,
76  * the message can now be both read from and written to. MapMessage objects support the
77  * following conversion table. The marked cases must be supported. The unmarked cases must
78  * throw a JMSException. The String-to-primitive conversions may throw a runtime exception
79  * if the primitive's valueOf() method does not accept it as a valid String representation
80  * of the primitive.
81  * A value written as the row type can be read as the column type.
82  *
83  * | | boolean byte short char int long float double String byte[]
84  * |----------------------------------------------------------------------
85  * |boolean | X X
86  * |byte | X X X X X
87  * |short | X X X X
88  * |char | X X
89  * |int | X X X
90  * |long | X X
91  * |float | X X X
92  * |double | X X
93  * |String | X X X X X X X X
94  * |byte[] | X
95  * |----------------------------------------------------------------------
96  *
97  * Attempting to read a null value as a primitive type must be treated as calling the
98  * primitive's corresponding valueOf(String) conversion method with a null value. Since
99  * char does not support a String conversion, attempting to read a null value as a char must
100  * throw a NullPointerException.
101  *
102  * @author Nimo 23-MAR-2004
103  *
104  */

105 public class MantaMapMessage extends MantaMessage implements MapMessage JavaDoc {
106     
107     /**
108      * only for makeCopy method use
109      *
110      */

111     MantaMapMessage(){
112         
113     }
114     /**
115      * Constructor for a map message.
116      * @param sess - the creating session
117      * @param message - a Map to construct the message on.
118      * @throws JMSException
119      */

120     public MantaMapMessage(MantaSession sess) throws JMSException JavaDoc {
121         this(sess,new HashMap JavaDoc(INITIAL_SIZE));
122          
123     }//MantaMapMessage
124

125
126     /**
127      * Constructor for a map message.
128      * @param sess - the creating session
129      * @param message - a Map to construct the message on.
130      * @throws JMSException
131      */

132     public MantaMapMessage(MantaSession sess,Map JavaDoc message) throws JMSException JavaDoc {
133         super();
134         flags = (flags & ONLY_MSG_TYPES)| MAP_MESSAGE;
135         
136         this.message = message;
137         this.creatingSession = sess;
138     } //MantaMapMessage
139

140     /**
141      * Get a boolean value from the map.
142      */

143     public boolean getBoolean(String JavaDoc name) throws JMSException JavaDoc {
144         
145         Object JavaDoc val = message.get(name);
146         if (val == null)
147             return Boolean.valueOf(null).booleanValue();
148         else if (val instanceof Boolean JavaDoc)
149             return ((Boolean JavaDoc) val).booleanValue();
150         else if (val instanceof String JavaDoc)
151             return Boolean.valueOf(val.toString()).booleanValue();
152         else
153             throw new MessageFormatException JavaDoc("MNJMS00039 : CAN NOT CONVERT "+val.getClass().getName()+
154                     " TO BOOLEAN. FAILED ON METHOD getBoolean().");
155             
156     }//getBoolean
157

158     /**
159      * Get a byte value from the map
160      */

161     public byte getByte(String JavaDoc name) throws JMSException JavaDoc {
162
163          Object JavaDoc val = message.get(name);
164          if (val == null)
165              return Byte.valueOf(null).byteValue();
166          else if (val instanceof Byte JavaDoc)
167              return ((Byte JavaDoc) val).byteValue();
168          else if (val instanceof String JavaDoc)
169              try {
170                  return Byte.valueOf(val.toString()).byteValue();
171              }
172              catch (NumberFormatException JavaDoc nfe) {
173                  throw new MessageFormatException JavaDoc("MNJMS0003A : FAILED ON METHOD getByte(). ERROR TEXT :"+nfe.getMessage());
174          
175              }
176          else
177              throw new MessageFormatException JavaDoc("MNJMS0003B : CAN NOT CONVERT "+val.getClass().getName()+
178                 " TO BYTE. FAILED ON METHOD getByte().");
179      
180
181     }//getBytes
182

183     /**
184      * get a short value from the map
185      */

186     public short getShort(String JavaDoc name) throws JMSException JavaDoc {
187         Object JavaDoc val = message.get(name);
188         if (val == null)
189             return Short.valueOf(null).shortValue();
190         else if (val instanceof Short JavaDoc)
191             return ((Short JavaDoc) val).shortValue();
192         else if (val instanceof Byte JavaDoc)
193             return ((Byte JavaDoc) val).shortValue();
194         else if (val instanceof String JavaDoc)
195             try {
196                 return Short.valueOf(val.toString()).shortValue();
197              }
198              catch (NumberFormatException JavaDoc nfe) {
199                  throw new MessageFormatException JavaDoc("MNJMS0003C : FAILED ON METHOD getShort(). ERROR TEXT :"+nfe.getMessage());
200              }
201             
202         else
203             throw new MessageFormatException JavaDoc("MNJMS0003D : CAN NOT CONVERT "+val.getClass().getName()+
204             " TO SHORT. FAILED ON METHOD getShort().");
205  
206         
207     }//getShort
208

209     /**
210      * get a char value from the map
211      */

212     public char getChar(String JavaDoc name) throws JMSException JavaDoc {
213          Object JavaDoc val = message.get(name);
214             if (val == null)
215                 throw new NullPointerException JavaDoc();
216             
217             else if (val instanceof Character JavaDoc)
218                 return ((Character JavaDoc) val).charValue();
219              else
220                 throw new MessageFormatException JavaDoc("MNJMS0003F : CAN NOT CONVERT "+val.getClass().getName()+
221                 " TO CHAR. FAILED ON METHOD getChar().");
222      
223     }//getChar
224

225     
226     /**
227      * get an int value from the map
228      */

229     public int getInt(String JavaDoc name) throws JMSException JavaDoc {
230         Object JavaDoc val = message.get(name);
231         if (val == null)
232             return Integer.valueOf(null).intValue();
233         else if (val instanceof Integer JavaDoc)
234             return ((Integer JavaDoc) val).intValue();
235         else if (val instanceof Short JavaDoc)
236             return ((Short JavaDoc) val).intValue();
237         else if (val instanceof Byte JavaDoc)
238             return ((Byte JavaDoc) val).intValue();
239         else if (val instanceof String JavaDoc)
240             try {
241                 return Integer.valueOf(val.toString()).intValue();
242              }
243              catch (NumberFormatException JavaDoc nfe) {
244                  throw new MessageFormatException JavaDoc("MNJMS00040 : FAILED ON METHOD getInt(). ERROR TEXT :"+nfe.getMessage());
245              }
246             
247         else
248             throw new MessageFormatException JavaDoc("MNJMS00041 : CAN NOT CONVERT "+val.getClass().getName()+
249             " TO INTEGER. FAILED ON METHOD getInt().");
250     }//getInt
251

252     /**
253      * get a long value from the map
254      */

255     public long getLong(String JavaDoc name) throws JMSException JavaDoc {
256         Object JavaDoc val = message.get(name);
257         if (val == null)
258             return Long.valueOf(null).longValue();
259         else if (val instanceof Long JavaDoc)
260             return ((Long JavaDoc) val).longValue();
261         else if (val instanceof Integer JavaDoc)
262             return ((Integer JavaDoc) val).longValue();
263         else if (val instanceof Short JavaDoc)
264             return ((Short JavaDoc) val).longValue();
265         else if (val instanceof Byte JavaDoc)
266             return ((Byte JavaDoc) val).longValue();
267         else if (val instanceof String JavaDoc)
268             try {
269                 return Long.valueOf(val.toString()).longValue();
270              }
271              catch (NumberFormatException JavaDoc nfe) {
272                  throw new MessageFormatException JavaDoc("MNJMS00042 : FAILED ON METHOD getLong(). ERROR TEXT :"+nfe.getMessage());
273              }
274         
275         else
276             throw new MessageFormatException JavaDoc("MNJMS00043 : CAN NOT CONVERT "+val.getClass().getName()+
277             " TO LONG. FAILED ON METHOD getLong().");
278     }//getLong
279

280     /**
281      * get a float value from the map
282      */

283     public float getFloat(String JavaDoc name) throws JMSException JavaDoc {
284         Object JavaDoc val = message.get(name);
285         if (val == null)
286             return Float.valueOf(null).floatValue();
287         else if (val instanceof Float JavaDoc)
288             return ((Float JavaDoc) val).floatValue();
289         if (val instanceof String JavaDoc)
290             try {
291                 return Float.valueOf(val.toString()).floatValue();
292              }
293              catch (NumberFormatException JavaDoc nfe) {
294                  throw new MessageFormatException JavaDoc("MNJMS00044 : FAILED ON METHOD getFloat(). ERROR TEXT :"+nfe.getMessage());
295              }
296             
297         else
298             throw new MessageFormatException JavaDoc("MNJMS00045 : CAN NOT CONVERT "+val.getClass().getName()+
299             " TO FLOAT. FAILED ON METHOD getFloat().");
300         
301     }//getFloat
302

303     /**
304      * get a double value from the map
305      */

306     public double getDouble(String JavaDoc name) throws JMSException JavaDoc {
307           Object JavaDoc val = message.get(name);
308             if (val == null)
309                 return Double.valueOf(null).doubleValue();
310             else if (val instanceof Double JavaDoc)
311                 return ((Double JavaDoc) val).doubleValue();
312             else if (val instanceof Float JavaDoc)
313                 return ((Float JavaDoc) val).floatValue();
314             else if (val instanceof String JavaDoc)
315                 try {
316                     return Float.valueOf(val.toString()).floatValue();
317                  }
318                  catch (NumberFormatException JavaDoc nfe) {
319                      throw new MessageFormatException JavaDoc("MNJMS00046 : FAILED ON METHOD getDouble(). ERROR TEXT :"+nfe.getMessage());
320                  }
321                 
322             else
323                 throw new MessageFormatException JavaDoc("MNJMS00047 : CAN NOT CONVERT "+val.getClass().getName()+
324                 " TO DOUBLE. FAILED ON METHOD getDouble().");
325             
326     }//getDouble
327

328     /**
329      * get a string value from the map
330      */

331     public String JavaDoc getString(String JavaDoc name) throws JMSException JavaDoc {
332         Object JavaDoc val = message.get(name);
333         if (val == null)
334             return null;
335         else if (val instanceof byte[])
336             throw new MessageFormatException JavaDoc("MNJMS00048 : CAN NOT CONVERT A BYTE ARRAY TO STRING. FAILED ON METHOD getString().");
337         
338         else
339             return val.toString();
340         
341     }//getString
342

343     /**
344      * get a byte array from the map
345      */

346     public byte[] getBytes(String JavaDoc name) throws JMSException JavaDoc {
347          Object JavaDoc val = message.get(name);
348             if (val==null || val instanceof byte[])
349                 return (byte[]) val;
350             else
351                 throw new MessageFormatException JavaDoc("MNJMS00049 : CAN NOT GET A BYTE ARRAY FROM "+
352                         val.getClass().getName()+" FAILED ON METHOD getBytes().");
353             
354     }//getBytes
355

356     /**
357      * get an object (runtime decision) from the map
358      */

359     public Object JavaDoc getObject(String JavaDoc name) throws JMSException JavaDoc {
360         
361             return message.get(name);
362         
363     }//getObject
364

365     
366     /**
367      * get the names for the objects in the map
368      */

369     public Enumeration JavaDoc getMapNames() throws JMSException JavaDoc {
370
371         //Get a final Iterator on the keySet (it cannnot be modified)
372
final Iterator JavaDoc i = message.keySet().iterator();
373         
374         //Return an anonymous inner wrapper class which wraps an Iterator inside an Enumeration
375
return new Enumeration JavaDoc() {
376             public boolean hasMoreElements() {
377                 return i.hasNext();
378             }//hasMoreElements
379

380             public Object JavaDoc nextElement() {
381                 return i.next();
382             }//nextElement
383
};
384     }//getMapNames
385

386     
387     /**
388      * Sets a <CODE>boolean</CODE> value with the specified name into the
389      * Map.
390      *
391      * @param name
392      * the name of the <CODE>boolean</CODE>
393      * @param value
394      * the <CODE>boolean</CODE> value to set in the Map
395      *
396      * @exception JMSException
397      * if the JMS provider fails to write the message due to
398      * some internal error.
399      * @exception IllegalArgumentException
400      * if the name is null or if the name is an empty string.
401      * @exception MessageNotWriteableException
402      * if the message is in read-only mode.
403      */

404     public void setBoolean(String JavaDoc name, boolean value) throws JMSException JavaDoc {
405         checkUpdateOperation(name);
406         message.put(name, Boolean.valueOf(value));
407     }//setBoolean
408

409     /**
410      * set a byte value inside the map
411      */

412     public void setByte(String JavaDoc name, byte value) throws JMSException JavaDoc {
413         checkUpdateOperation(name);
414         message.put(name, new Byte JavaDoc(value));
415     }//setByte
416

417     /**
418      * set a short value inside the map
419      */

420     public void setShort(String JavaDoc name, short value) throws JMSException JavaDoc {
421         checkUpdateOperation(name);
422         message.put(name, new Short JavaDoc(value));
423     }//setShort
424

425     /**
426      * set a char value inside the map
427      */

428     public void setChar(String JavaDoc name, char value) throws JMSException JavaDoc {
429         checkUpdateOperation(name);
430         message.put(name, new Character JavaDoc(value));
431     }//setChar
432

433     /**
434      * set an int value inside the map
435      */

436     public void setInt(String JavaDoc name, int value) throws JMSException JavaDoc {
437         checkUpdateOperation(name);
438         message.put(name, new Integer JavaDoc(value));
439     }//setInt
440

441     /**
442      * set a long value inside the map
443      */

444     public void setLong(String JavaDoc name, long value) throws JMSException JavaDoc {
445         checkUpdateOperation(name);
446         message.put(name, new Long JavaDoc(value));
447     }//setLong
448

449     /**
450      * set a float value inside the map
451      */

452     public void setFloat(String JavaDoc name, float value) throws JMSException JavaDoc {
453         checkUpdateOperation(name);
454         message.put(name, new Float JavaDoc(value));
455     }//setFloat
456

457     /**
458      * set a double value inside the map
459      */

460     public void setDouble(String JavaDoc name, double value) throws JMSException JavaDoc {
461         checkUpdateOperation(name);
462         message.put(name, new Double JavaDoc(value));
463     }//setDouble
464

465     /**
466      * set a string value inside the map
467      */

468     public void setString(String JavaDoc name, String JavaDoc value) throws JMSException JavaDoc {
469         checkUpdateOperation(name);
470         message.put(name, value);
471     }//setString
472

473     /**
474      * set a byte array value inside the map
475      */

476     public void setBytes(String JavaDoc name, byte[] value) throws JMSException JavaDoc {
477         checkUpdateOperation(name);
478         message.put(name, value);
479     }//setBytes
480

481     /**
482      * another method for setting a bytevalue inside the map.
483      * with an offset and a length to the passed byte array.
484      */

485     public void setBytes(String JavaDoc name, byte[] values, int offset, int length) throws JMSException JavaDoc {
486         checkUpdateOperation(name);
487         try {
488             byte[] a = new byte[length];
489             for(int i = 0;i < length;i++) {
490                 a[i] = values[i + offset];
491             }//for
492
message.put(name, a);
493         }//try
494
catch(Exception JavaDoc x) {
495             throw new JMSException JavaDoc("MNJMS0004A : FAILED ON METHOD setBytes(). ERROR TEXT : "+x.getMessage());
496         }//catch
497
}//setBytes
498

499     /**
500      * set an object value inside the map
501      */

502     public void setObject(String JavaDoc name, Object JavaDoc value) throws JMSException JavaDoc {
503
504         checkUpdateOperation(name);
505
506         if (value instanceof String JavaDoc || value instanceof Short JavaDoc ||
507                     value instanceof Byte JavaDoc || value instanceof Long JavaDoc ||
508                     value instanceof Boolean JavaDoc || value instanceof Float JavaDoc ||
509                     value instanceof Integer JavaDoc || value instanceof Double JavaDoc ||
510                     value instanceof byte[] || value instanceof Character JavaDoc)
511         {
512              message.put(name, value);
513         } else
514             throw new MessageFormatException JavaDoc("MNJMS0004B : FAILED ON METHOD setObject(). INVALID OBJECT TYPE : "+value.getClass().getName());
515     }
516
517
518     
519     /**
520      * checks that the name passed as a parameter exists in the message's map.
521      */

522     public boolean itemExists(String JavaDoc name) throws JMSException JavaDoc {
523         return (message.get(name) != null);
524     }//itemExists
525

526     //-------------Byteable methods.
527

528     public void toBytes(ByteableOutputStream out) throws IOException JavaDoc {
529         
530         super.toBytes(out);
531         
532         //write the Map properties number and then properties:
533
out.writeInt(message.size());
534         Iterator JavaDoc msgIt = message.keySet().iterator();
535         while (msgIt.hasNext()) {
536             
537             //get the key and value
538
String JavaDoc key = (String JavaDoc)msgIt.next();
539             Object JavaDoc val = message.get(key);
540             
541             //write the property name
542
out.writeUTF(key);
543             
544             //check what type it is, write the type code and the value.
545
if (val instanceof Boolean JavaDoc) {
546                 out.write(BOOLEAN);
547                 out.writeBoolean( ((Boolean JavaDoc)val).booleanValue());
548             }
549             else if (val instanceof Byte JavaDoc) {
550                 out.write(BYTE);
551                 out.writeByte( ((Byte JavaDoc)val).byteValue());
552             }
553             else if (val instanceof byte[]) {
554                 out.write(BYTEARR);
555                 out.writeInt( ((byte[])val).length);
556                 out.write((byte[])val);
557             }
558             else if (val instanceof Character JavaDoc) {
559                 out.write(CHAR);
560                 out.writeChar(((Character JavaDoc)val).charValue());
561             }
562             else if (val instanceof Double JavaDoc) {
563                 out.write(DOUBLE);
564                 out.writeDouble( ((Double JavaDoc)val).doubleValue());
565             }
566             else if (val instanceof Float JavaDoc) {
567                 out.write(FLOAT);
568                 out.writeFloat( ((Float JavaDoc)val).floatValue());
569             }
570             else if (val instanceof Integer JavaDoc) {
571                 out.write(INTEGER);
572                 out.writeInt( ((Integer JavaDoc)val).intValue());
573             }
574             else if (val instanceof Long JavaDoc) {
575                 out.write(LONG);
576                 out.writeLong( ((Long JavaDoc)val).longValue());
577             }
578             else if (val instanceof Short JavaDoc) {
579                 out.write(SHORT);
580                 out.writeShort( ((Short JavaDoc)val).shortValue());
581             }
582             else if (val instanceof String JavaDoc) {
583                 out.write(STRING);
584                 out.writeUTF((String JavaDoc)val);
585             }
586             
587         }
588         
589         out.flush();
590             
591             
592     }
593         
594
595     public Byteable createInstance(ByteableInputStream in) throws IOException JavaDoc {
596         
597         MantaMapMessage result;
598         try {
599             result = new MantaMapMessage(null);
600             createHeadersAndProperties(result,in);
601         }
602         catch (JMSException JavaDoc jmse) {
603             throw new IOException JavaDoc("MNJMS00FFD : METHOD createInstance() FAILED ON MantaMapMessage. EXCEPTION TEXT : "+jmse.getMessage());
604         }
605         
606         //now - for the map.
607
int size = in.readInt();
608         for (int i = 0; i<size ; i++) {
609             //key, type, value.
610
String JavaDoc key = in.readUTF();
611             byte type = in.readByte();
612             switch (type) {
613                 case BYTE : result.message.put(key,new Byte JavaDoc(in.readByte())); break ;
614                 case BOOLEAN : result.message.put(key, new Boolean JavaDoc(in.readBoolean())); break;
615                 case SHORT : result.message.put(key,new Short JavaDoc(in.readShort())); break;
616                 case INTEGER : result.message.put(key,new Integer JavaDoc(in.readInt())); break;
617                 case DOUBLE : result.message.put(key,new Double JavaDoc(in.readDouble())); break;
618                 case FLOAT : result.message.put(key,new Float JavaDoc(in.readFloat())); break;
619                 case STRING : result.message.put(key,in.readUTF()); break;
620                 case LONG : result.message.put(key,new Long JavaDoc(in.readLong())); break;
621                 case BYTEARR : byte[] surreal = new byte[in.readInt()];
622                                 in.read(surreal);
623                                 result.message.put(key,surreal); break;
624             
625                 case CHAR : result.message.put(key,new Character JavaDoc(in.readChar()));break;
626             
627             }
628         }
629         return result;
630     }
631
632     public void registerToByteableRegistry() {
633         ByteableRegistry.registerByteableFactory(getByteableName() , this);
634     }
635     
636     public final static String JavaDoc BYTEABLENAME = "MantaMapMsg";
637     public String JavaDoc getByteableName() {
638         
639         return BYTEABLENAME;
640     }
641     
642     public static void register() throws JMSException JavaDoc{
643         MantaMapMessage instance = new MantaMapMessage(null);
644         instance.registerToByteableRegistry();
645     }
646     private void checkUpdateOperation(String JavaDoc str) throws IllegalArgumentException JavaDoc, MessageNotWriteableException JavaDoc {
647         if (!isWriteable())
648             throw new MessageNotWriteableException JavaDoc("MNJMS0004C : MESSAGE IS NOT WRITEABLE. FAILED IN METHOD checkUpdateOperation().");
649         if (str == null ||str.length() == 0)
650             throw new IllegalArgumentException JavaDoc("MNJMS0004D : ILLEGAL PROPERTY NAME. FAILED IN METHOD checkUpdateOperation().");
651     }//checkUpdateOperation
652

653     //----------------End of byteable methods.
654

655     /**
656      * Clear out the message body.
657      */

658     public final void clearBody() throws JMSException JavaDoc {
659         super.clearBody();
660         //if ((flags&ORIG_BODY_SAVED)==0) {
661
// backupMessage = message;
662
// flags=flags|ORIG_BODY_SAVED;
663
//}
664
message = new HashMap JavaDoc(INITIAL_SIZE);
665             
666     }//clearBody
667

668     public MantaMessage makeCopy() throws JMSException JavaDoc{
669         MantaMapMessage copy = new MantaMapMessage();
670         initCopy(copy);
671         copy.message = new HashMap JavaDoc(message);
672         return copy;
673     }
674     
675 // protected void retrieveOldBody() {
676
//
677
//
678
// if ((flags&ORIG_BODY_SAVED)>0) {
679
// //if someone actually cleared body.
680
// if (backupMessage==null)
681
// message=null;
682
// else
683
// message = new Hashtable(backupMessage);
684
// }
685
// //else - the message was not touched, probably.
686
// }
687

688     //The message itself.
689
private Map JavaDoc message = null;
690     //private Map backupMessage = null;
691
private final static int INITIAL_SIZE = 11;
692     
693 }//MantaMapMessage
694
Popular Tags