1 /* 2 * The contents of this file are subject to the terms 3 * of the Common Development and Distribution License 4 * (the License). You may not use this file except in 5 * compliance with the License. 6 * 7 * You can obtain a copy of the license at 8 * https://glassfish.dev.java.net/public/CDDLv1.0.html or 9 * glassfish/bootstrap/legal/CDDLv1.0.txt. 10 * See the License for the specific language governing 11 * permissions and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL 14 * Header Notice in each file and include the License file 15 * at glassfish/bootstrap/legal/CDDLv1.0.txt. 16 * If applicable, add the following below the CDDL Header, 17 * with the fields enclosed by brackets [] replaced by 18 * you own identifying information: 19 * "Portions Copyrighted [year] [name of copyright owner]" 20 * 21 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 22 */ 23 24 package javax.jms; 25 26 /** A <CODE>TextMessage</CODE> object is used to send a message containing a 27 * <CODE>java.lang.String</CODE>. 28 * It inherits from the <CODE>Message</CODE> interface and adds a text message 29 * body. 30 * 31 * <P>This message type can be used to transport text-based messages, including 32 * those with XML content. 33 * 34 * <P>When a client receives a <CODE>TextMessage</CODE>, it is in read-only 35 * mode. If a client attempts to write to the message at this point, a 36 * <CODE>MessageNotWriteableException</CODE> is thrown. If 37 * <CODE>clearBody</CODE> is 38 * called, the message can now be both read from and written to. 39 * 40 * @version 1.1 - February 2, 2002 41 * @author Mark Hapner 42 * @author Rich Burridge 43 * @author Kate Stout 44 * 45 * @see javax.jms.Session#createTextMessage() 46 * @see javax.jms.Session#createTextMessage(String) 47 * @see javax.jms.BytesMessage 48 * @see javax.jms.MapMessage 49 * @see javax.jms.Message 50 * @see javax.jms.ObjectMessage 51 * @see javax.jms.StreamMessage 52 * @see java.lang.String 53 */ 54 55 public interface TextMessage extends Message { 56 57 /** Sets the string containing this message's data. 58 * 59 * @param string the <CODE>String</CODE> containing the message's data 60 * 61 * @exception JMSException if the JMS provider fails to set the text due to 62 * some internal error. 63 * @exception MessageNotWriteableException if the message is in read-only 64 * mode. 65 */ 66 67 void 68 setText(String string) throws JMSException; 69 70 71 /** Gets the string containing this message's data. The default 72 * value is null. 73 * 74 * @return the <CODE>String</CODE> containing the message's data 75 * 76 * @exception JMSException if the JMS provider fails to get the text due to 77 * some internal error. 78 */ 79 80 String 81 getText() throws JMSException; 82 } 83