1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.jms;
  6. /** A <CODE>TextMessage</CODE> object is used to send a message containing a
  7. * <CODE>java.lang.String</CODE>.
  8. * It inherits from the <CODE>Message</CODE> interface and adds a text message
  9. * body.
  10. *
  11. * <P>The inclusion of this message type is based on the presumption
  12. * that XML will likely become a popular mechanism for representing
  13. * content of all kinds, including the content of JMS messages.
  14. *
  15. * <P>When a client receives a <CODE>TextMessage</CODE>, it is in read-only
  16. * mode. If a client attempts to write to the message at this point, a
  17. * <CODE>MessageNotWriteableException</CODE> is thrown. If
  18. * <CODE>clearBody</CODE> is
  19. * called, the message can now be both read from and written to.
  20. *
  21. * @version 1.0 - 19 March 1998
  22. * @author Mark Hapner
  23. * @author Rich Burridge
  24. *
  25. * @see javax.jms.Session#createTextMessage()
  26. * @see javax.jms.Session#createTextMessage(String)
  27. * @see javax.jms.BytesMessage
  28. * @see javax.jms.MapMessage
  29. * @see javax.jms.Message
  30. * @see javax.jms.ObjectMessage
  31. * @see javax.jms.StreamMessage
  32. * @see java.lang.String
  33. */
  34. public interface TextMessage extends Message {
  35. /** Sets the string containing this message's data.
  36. *
  37. * @param string the <CODE>String</CODE> containing the message's data
  38. *
  39. * @exception JMSException if the JMS provider fails to set the text due to
  40. * some internal error.
  41. * @exception MessageNotWriteableException if the message is in read-only
  42. * mode.
  43. */
  44. void
  45. setText(String string) throws JMSException;
  46. /** Gets the string containing this message's data. The default
  47. * value is null.
  48. *
  49. * @return the <CODE>String</CODE> containing the message's data
  50. *
  51. * @exception JMSException if the JMS provider fails to get the text due to
  52. * some internal error.
  53. */
  54. String
  55. getText() throws JMSException;
  56. }