KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > jms > message > TextMessageImpl


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6
7 package org.jfox.jms.message;
8
9 import javax.jms.JMSException JavaDoc;
10 import javax.jms.MessageNotWriteableException JavaDoc;
11 import javax.jms.TextMessage JavaDoc;
12
13 /**
14  * <p/>
15  * This class provides an implementation of the JMS TextMessage. This message
16  * type is used to send a textual string to another java client.This message
17  * can be used to transmit any valid java string including XML.
18  * </p>
19  *
20  * @author <a HREF="mailto:founder_chen@yahoo.com.cn">Peter.Cheng</a>
21  * @version Revision: 1.1 Date: 2002-11-30 15:45:25
22  */

23
24 public class TextMessageImpl extends JMSMessage implements TextMessage JavaDoc {
25
26     private String JavaDoc text = null;
27
28     /**
29      * Defalut contructor.
30      */

31     public TextMessageImpl() {
32         super();
33     }
34
35     /**
36      * Set TextMessage body
37      *
38      * @param string
39      * @throws javax.jms.JMSException if the JMS provider fails to set the TextMessage bodyt
40      * due to some internal error.
41      * @see javax.jms.TextMessage#setText(String)
42      */

43     public void setText(String JavaDoc string) throws JMSException JavaDoc {
44         if (isBodyModifiable()) {
45             text = new String JavaDoc(string);
46         } else {
47             throw new MessageNotWriteableException JavaDoc("TextMessage is read-only.");
48         }
49     }
50
51     /**
52      * Return TextMessage body
53      *
54      * @return text
55      * @see javax.jms.TextMessage#getText()
56      */

57     public String JavaDoc getText() throws JMSException JavaDoc {
58         return text;
59     }
60
61     /**
62      * Clear out the message body.
63      *
64      * @throws javax.jms.JMSException
65      */

66     public void clearBody() throws JMSException JavaDoc {
67         super.clearBody();
68         text = null;
69     }
70
71     public String JavaDoc toString() {
72         return "TextMessage {body=" + text + "}";
73     }
74 }
75
Popular Tags