1 21 package com.presumo.jms.message; 22 23 import java.io.Serializable ; 24 import java.io.IOException ; 25 26 import java.io.DataInput ; 27 import java.io.DataOutput ; 28 29 import java.io.ByteArrayOutputStream ; 30 import java.io.ByteArrayInputStream ; 31 import java.io.ObjectOutputStream ; 32 import java.io.ObjectInputStream ; 33 34 import javax.jms.MapMessage ; 35 import javax.jms.JMSException ; 36 import javax.jms.MessageFormatException ; 37 import javax.jms.MessageNotWriteableException ; 38 39 45 public final class JmsMapMessage extends JmsMessage 46 implements MapMessage , java.io.Externalizable 47 { 48 49 private PrimitiveMap messageBody; 50 51 55 public JmsMapMessage() 56 { 57 super(); 58 messageBody = new PrimitiveMap(); 59 } 60 61 public JmsMapMessage(String name) 62 { 63 super(name); 64 messageBody = new PrimitiveMap(); 65 } 66 67 public JmsMapMessage(byte [] msg, int offset, int length) 68 throws IOException 69 { 70 super(msg, offset, length); 71 } 72 73 77 public void clearBody() throws JMSException 78 { 79 checkWrite(); 80 messageBody.clear(); 81 } 82 83 public boolean getBoolean(String name) throws JMSException 84 { 85 return messageBody.getBoolean(name); 86 } 87 88 public byte getByte(String name) throws JMSException 89 { 90 return messageBody.getByte(name); 91 } 92 93 public byte[] getBytes(String name) throws JMSException 94 { 95 return messageBody.getBytes(name); 96 } 97 98 public short getShort(String name) throws JMSException 99 { 100 return messageBody.getShort(name); 101 } 102 103 public char getChar(String name) throws JMSException 104 { 105 return messageBody.getChar(name); 106 } 107 108 public int getInt(String name) throws JMSException 109 { 110 return messageBody.getInt(name); 111 } 112 113 public long getLong(String name) throws JMSException 114 { 115 return messageBody.getLong(name); 116 } 117 118 public float getFloat(String name) throws JMSException 119 { 120 return messageBody.getFloat(name); 121 } 122 123 public double getDouble(String name) throws JMSException 124 { 125 return messageBody.getDouble(name); 126 } 127 128 public String getString(String name) throws JMSException 129 { 130 return messageBody.getString(name); 131 } 132 133 public Object getObject(String name) throws JMSException 134 { 135 return messageBody.getObject(name); 136 } 137 138 public void setBoolean(String name, boolean value) throws JMSException 139 { 140 checkWrite(); 141 messageBody.setBoolean(name, value); 142 } 143 144 public void setByte(String name, byte value) throws JMSException 145 { 146 checkWrite(); 147 messageBody.setByte(name, value); 148 } 149 150 public void setBytes(String name, byte[] value) throws JMSException 151 { 152 checkWrite(); 153 messageBody.setBytes(name, value); 154 } 155 156 public void setBytes(String name, byte[] value, int offset, int length) 157 throws JMSException 158 { 159 checkWrite(); 160 messageBody.setBytes(name, value, offset, length); 161 } 162 163 public void setShort(String name, short value) throws JMSException 164 { 165 checkWrite(); 166 messageBody.setShort(name, value); 167 } 168 169 public void setChar(String name, char value) throws JMSException 170 { 171 checkWrite(); 172 messageBody.setChar(name, value); 173 } 174 175 public void setInt(String name, int value) throws JMSException 176 { 177 checkWrite(); 178 messageBody.setInt(name, value); 179 } 180 181 public void setLong(String name, long value) throws JMSException 182 { 183 checkWrite(); 184 messageBody.setLong(name, value); 185 } 186 187 public void setFloat(String name, float value) throws JMSException 188 { 189 checkWrite(); 190 messageBody.setFloat(name, value); 191 } 192 193 public void setDouble(String name, double value) throws JMSException 194 { 195 checkWrite(); 196 messageBody.setDouble(name, value); 197 } 198 199 public void setString(String name, String value) throws JMSException 200 { 201 checkWrite(); 202 messageBody.setString(name, value); 203 } 204 205 public void setObject(String name, Object value) throws JMSException 206 { 207 checkWrite(); 208 messageBody.setObject(name, value); 209 } 210 211 public java.util.Enumeration getMapNames() throws JMSException 212 { 213 return messageBody.getPrimitiveNames(); 214 } 215 216 public boolean itemExists(String name) throws JMSException 217 { 218 return messageBody.primitiveExists(name); 219 } 220 221 222 225 public final void unmarshal(DataInput in) throws IOException 226 { 227 super.unmarshal(in); 231 if (messageBody == null) 232 messageBody = new PrimitiveMap(); 233 messageBody.unmarshal(in); 234 235 } 236 237 240 public final void marshal(DataOutput out) throws IOException 241 { 242 super.marshal(out); 243 messageBody.marshal(out); 244 } 245 246 247 251 255 byte getMarshalingID() 256 { 257 return MessageEncoder.MAP_MESSAGE; 258 } 259 260 } 261 262 | Popular Tags |