1 package net.walend.somnifugi; 2 3 import java.io.Serializable ; 4 5 import javax.jms.TextMessage ; 6 import javax.jms.JMSException ; 7 8 14 15 public class SomniTextMessage 16 extends SomniMessage 17 implements TextMessage 18 { 19 private String gut = null; 20 21 protected SomniTextMessage() 22 { 23 super(); 24 } 25 26 29 protected SomniTextMessage(SomniTextMessage message,boolean deep) 30 throws JMSException 31 { 32 super(message,deep); 33 if(deep) 34 { 35 gut = (String )serializedCopy(message.getText()); 36 } 37 else 38 { 39 gut = message.getText(); 40 } 41 } 42 43 57 public void setText(String text) 58 throws JMSException 59 { 60 synchronized(guard) 61 { 62 checkWritable(); 63 gut = text; 64 } 65 } 66 67 76 public String getText() 77 throws JMSException 78 { 79 synchronized(guard) 80 { 81 return gut; 82 } 83 } 84 85 96 public void clearBody() 97 throws JMSException 98 { 99 synchronized(guard) 100 { 101 super.clearBody(); 102 gut = null; 103 } 104 } 105 106 109 protected SomniMessage shallowCopy() 110 throws JMSException 111 { 112 synchronized(guard) 113 { 114 return new SomniTextMessage(this,false); 115 } 116 } 117 118 121 protected SomniMessage deepCopy() 122 throws JMSException 123 { 124 synchronized(guard) 125 { 126 return new SomniTextMessage(this,true); 127 } 128 } 129 130 public String toString() 131 { 132 StringBuffer buffy = new StringBuffer (); 133 buffy.append(super.toString()); 134 buffy.append(" contains:"); 135 136 if(gut!=null) 137 { 138 buffy.append(gut.toString()); 139 } 140 else 141 { 142 buffy.append("null"); 143 } 144 145 return buffy.toString(); 146 } 147 } 148 149 169 | Popular Tags |