01: package org.mockejb.jms;
02:
03: import javax.jms.*;
04:
05: /**
06: * <code>TextMessage</code> implementation.
07: * @author Dimitar Gospodinov
08: */
09: public class TextMessageImpl extends MessageImpl implements TextMessage {
10:
11: private String messageText = null;
12:
13: /**
14: * Creates new <code>TextMessageImpl</code> initialized
15: * with the text from <code>msg</code>
16: * @param msg
17: * @throws JMSException
18: */
19: public TextMessageImpl(TextMessage msg) throws JMSException {
20: super (msg);
21: setText(msg.getText());
22: }
23:
24: /**
25: * Creates empty <code>TextMessage</code>
26: */
27: public TextMessageImpl() {
28: super ();
29: }
30:
31: /**
32: * Creates new <code>TextMessageImpl</code> initialized with
33: * <code>text</code>
34: * @param text
35: */
36: public TextMessageImpl(String text) throws JMSException {
37: setText(text);
38: }
39:
40: /**
41: * @see javax.jms.TextMessage#clearBody()
42: */
43: public void clearBody() throws JMSException {
44: super .clearBody();
45: messageText = null;
46: }
47:
48: /**
49: * @see javax.jms.TextMessage#setText(java.lang.String)
50: */
51: public void setText(String text) throws JMSException {
52: checkBodyWriteable();
53: messageText = text;
54: }
55:
56: /**
57: * @see javax.jms.TextMessage#getText()
58: */
59: public String getText() throws JMSException {
60: return messageText;
61: }
62:
63: // Non-standard methods
64:
65: /**
66: * Sets message body in read-only mode.
67: * @throws JMSException
68: */
69: void resetBody() throws JMSException {
70: setBodyReadOnly();
71: }
72:
73: }
|