1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2000-2007 Sun Microsystems, Inc. All rights reserved.
5 *
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common Development
8 * and Distribution License ("CDDL") (collectively, the "License"). You may
9 * not use this file except in compliance with the License. You can obtain
10 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
11 * or mq/legal/LICENSE.txt. See the License for the specific language
12 * governing permissions and limitations under the License.
13 *
14 * When distributing the software, include this License Header Notice in each
15 * file and include the License file at mq/legal/LICENSE.txt. Sun designates
16 * this particular file as subject to the "Classpath" exception as provided by
17 * Sun in the GPL Version 2 section of the License file that accompanied this
18 * code. If applicable, add the following below the License Header, with the
19 * fields enclosed by brackets [] replaced by your own identifying information:
20 * "Portions Copyrighted [year] [name of copyright owner]"
21 *
22 * Contributor(s):
23 *
24 * If you wish your version of this file to be governed by only the CDDL or
25 * only the GPL Version 2, indicate your decision by adding "[Contributor]
26 * elects to include this software in this distribution under the [CDDL or GPL
27 * Version 2] license." If you don't indicate a single choice of license, a
28 * recipient has the option to distribute your version of this file under
29 * either the CDDL, the GPL Version 2 or to extend the choice of license to
30 * its licensees as provided above. However, if you add GPL Version 2 code
31 * and therefore, elected the GPL Version 2 license, then the option applies
32 * only if the new code is made subject to such option by the copyright holder.
33 */
34
35 /*
36 * @(#)TextMessage.java 1.19 07/02/07
37 */
38
39 package javax.jms;
40
41 /** A <CODE>TextMessage</CODE> object is used to send a message containing a
42 * <CODE>java.lang.String</CODE>.
43 * It inherits from the <CODE>Message</CODE> interface and adds a text message
44 * body.
45 *
46 * <P>This message type can be used to transport text-based messages, including
47 * those with XML content.
48 *
49 * <P>When a client receives a <CODE>TextMessage</CODE>, it is in read-only
50 * mode. If a client attempts to write to the message at this point, a
51 * <CODE>MessageNotWriteableException</CODE> is thrown. If
52 * <CODE>clearBody</CODE> is
53 * called, the message can now be both read from and written to.
54 *
55 * @see javax.jms.Session#createTextMessage()
56 * @see javax.jms.Session#createTextMessage(String)
57 * @see javax.jms.BytesMessage
58 * @see javax.jms.MapMessage
59 * @see javax.jms.Message
60 * @see javax.jms.ObjectMessage
61 * @see javax.jms.StreamMessage
62 * @see java.lang.String
63 */
64
65 public interface TextMessage extends Message {
66
67 /** Sets the string containing this message's data.
68 *
69 * @param string the <CODE>String</CODE> containing the message's data
70 *
71 * @exception JMSException if the JMS provider fails to set the text due to
72 * some internal error.
73 * @exception MessageNotWriteableException if the message is in read-only
74 * mode.
75 */
76
77 void
78 setText(String string) throws JMSException;
79
80
81 /** Gets the string containing this message's data. The default
82 * value is null.
83 *
84 * @return the <CODE>String</CODE> containing the message's data
85 *
86 * @exception JMSException if the JMS provider fails to get the text due to
87 * some internal error.
88 */
89
90 String
91 getText() throws JMSException;
92 }