package org.mockejb.jms;
import java.util.*;
import javax.jms.*;
public class MapMessageImpl extends MessageImpl implements MapMessage {
private final PrimitiveMap map = new PrimitiveMap();
public MapMessageImpl() {
super();
}
public MapMessageImpl(MapMessage msg) throws JMSException {
super(msg);
Enumeration e = msg.getMapNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
setObject(name, msg.getObject(name));
}
}
public boolean getBoolean(String name) throws JMSException {
return map.getBoolean(name);
}
public byte getByte(String name) throws JMSException {
return map.getByte(name);
}
public short getShort(String name) throws JMSException {
return map.getShort(name);
}
public char getChar(String name) throws JMSException {
return map.getChar(name);
}
public int getInt(String name) throws JMSException {
return map.getInt(name);
}
public long getLong(String name) throws JMSException {
return map.getLong(name);
}
public float getFloat(String name) throws JMSException {
return map.getFloat(name);
}
public double getDouble(String name) throws JMSException {
return map.getDouble(name);
}
public String getString(String name) throws JMSException {
return map.getString(name);
}
public byte[] getBytes(String name) throws JMSException {
return map.getBytes(name);
}
public Object getObject(String name) throws JMSException {
return map.getObject(name);
}
public Enumeration getMapNames() throws JMSException {
return map.getNames();
}
public void setBoolean(String name, boolean value) throws JMSException {
checkBodyWriteable();
map.setBoolean(name, value);
}
public void setByte(String name, byte value) throws JMSException {
checkBodyWriteable();
map.setByte(name, value);
}
public void setShort(String name, short value) throws JMSException {
checkBodyWriteable();
map.setShort(name, value);
}
public void setChar(String name, char value) throws JMSException {
checkBodyWriteable();
map.setChar(name, value);
}
public void setInt(String name, int value) throws JMSException {
checkBodyWriteable();
map.setInt(name, value);
}
public void setLong(String name, long value) throws JMSException {
checkBodyWriteable();
map.setLong(name, value);
}
public void setFloat(String name, float value) throws JMSException {
checkBodyWriteable();
map.setFloat(name, value);
}
public void setDouble(String name, double value) throws JMSException {
checkBodyWriteable();
map.setDouble(name, value);
}
public void setString(String name, String value) throws JMSException {
checkBodyWriteable();
map.setString(name, value);
}
public void setBytes(String name, byte[] value) throws JMSException {
checkBodyWriteable();
map.setBytes(name, value);
}
public void setBytes(String name, byte[] value, int offset, int length)
throws JMSException {
checkBodyWriteable();
if (value == null
|| length < 0
|| offset < 0
|| (offset + length) > value.length) {
throw new IllegalArgumentException();
}
byte[] valueToSet = new byte[length];
int i = 0;
while (length > 0) {
valueToSet[i++] = value[offset++];
length--;
}
map.setBytes(name, valueToSet);
}
public void setObject(String name, Object value) throws JMSException {
checkBodyWriteable();
map.setObject(name, value);
}
public boolean itemExists(String name) throws JMSException {
return map.containsKey(name);
}
void resetBody() throws JMSException {
setBodyReadOnly();
}
}