KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > jms > TextMessage


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - 2006 ScalAgent Distributed Technologies
4  * Copyright (C) 1996 - 2000 Dyade
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA.
20  *
21  * Initial developer(s): Frederic Maistre (INRIA)
22  * Contributor(s):ScalAgent Distributed Technologies
23  */

24 package org.objectweb.joram.client.jms;
25
26 import org.objectweb.joram.shared.excepts.*;
27
28 import javax.jms.JMSException JavaDoc;
29 import javax.jms.MessageNotWriteableException JavaDoc;
30
31 /**
32  * Implements the <code>javax.jms.TextMessage</code> interface.
33  */

34 public final class TextMessage extends Message implements javax.jms.TextMessage JavaDoc {
35   /**
36    * Instanciates a bright new <code>TextMessage</code>.
37    */

38   TextMessage() {
39     super();
40     momMsg.type = momMsg.TEXT;
41   }
42
43   /**
44    * Instanciates a <code>TextMessage</code> wrapping a consumed
45    * MOM message containing a text.
46    *
47    * @param session The consuming session.
48    * @param momMsg The MOM message to wrap.
49    */

50   TextMessage(Session session,
51               org.objectweb.joram.shared.messages.Message momMsg) {
52     super(session, momMsg);
53   }
54
55   /**
56    * Sets a String as the body of the message.
57    * API method.
58    *
59    * @exception MessageNotWriteableException When trying to set the text
60    * if the message body is read-only.
61    */

62   public void setText(String JavaDoc text) throws MessageNotWriteableException JavaDoc {
63     if (RObody)
64       throw new MessageNotWriteableException JavaDoc("Can't set a text as the message body is read-only.");
65
66     momMsg.setText(text);
67   }
68
69   /**
70    * Returns the text body of the message.
71    * API method.
72    *
73    * @exception JMSException Actually never thrown.
74    */

75   public String JavaDoc getText() throws JMSException JavaDoc {
76     return momMsg.getText();
77   }
78 }
79
Popular Tags