com/scalagent/kjoram/TextMessage.java

00001 /*
00002  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
00003  * Copyright (C) 2001 - ScalAgent Distributed Technologies
00004  * Copyright (C) 1996 - Dyade
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  * 
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA.
00020  *
00021  * Initial developer(s): Frederic Maistre (INRIA)
00022  * Contributor(s): Nicolas Tachker (ScalAgent)
00023  */
00024 package com.scalagent.kjoram;
00025 
00026 import com.scalagent.kjoram.excepts.*;
00027 
00028 
00029 public class TextMessage extends Message
00030 {
00032   private String text = null;
00034   private boolean RObody = false;
00035 
00039   TextMessage()
00040   {
00041     super();
00042   }
00043   
00051   TextMessage(Session sess, com.scalagent.kjoram.messages.Message momMsg)
00052   {
00053     super(sess, momMsg);
00054     text = momMsg.getText();
00055     RObody = true;
00056   }
00057 
00058 
00064   public void clearBody() throws JMSException
00065   {
00066     super.clearBody();
00067     text = null;
00068     RObody = false;
00069   }
00070 
00077   public void setText(String text) throws MessageNotWriteableException
00078   {
00079     if (RObody)
00080       throw new MessageNotWriteableException("Can't set a text as the"
00081                                              + " message body is read-only.");
00082     this.text = text;
00083   }
00084 
00090   public String getText() throws JMSException
00091   {
00092     return text;
00093   }
00094 
00101   protected void prepare() throws Exception
00102   {
00103     super.prepare();
00104     momMsg.clearBody();
00105     momMsg.setText(text);
00106   }
00107 }

Generated on Tue Sep 16 16:14:25 2008 for joram by  doxygen 1.5.0