use of javax.jms.MessageNotReadableException in project activemq-artemis by apache.
the class SimpleJMSStreamMessage method readFloat.
@Override
public float readFloat() throws JMSException {
if (bodyWriteOnly) {
throw new MessageNotReadableException("The message body is writeonly");
}
try {
Object value = content.get(position);
offset = 0;
if (value == null) {
throw new NullPointerException("Value is null");
} else if (value instanceof Float) {
position++;
return ((Float) value).floatValue();
} else if (value instanceof String) {
float result = Float.parseFloat((String) value);
position++;
return result;
} else {
throw new MessageFormatException("Invalid conversion");
}
} catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
use of javax.jms.MessageNotReadableException in project activemq-artemis by apache.
the class SimpleJMSStreamMessage method readShort.
@Override
public short readShort() throws JMSException {
if (bodyWriteOnly) {
throw new MessageNotReadableException("The message body is writeonly");
}
try {
Object value = content.get(position);
offset = 0;
if (value == null) {
throw new NullPointerException("Value is null");
} else if (value instanceof Byte) {
position++;
return ((Byte) value).shortValue();
} else if (value instanceof Short) {
position++;
return ((Short) value).shortValue();
} else if (value instanceof String) {
short result = Short.parseShort((String) value);
position++;
return result;
} else {
throw new MessageFormatException("Invalid conversion");
}
} catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
use of javax.jms.MessageNotReadableException in project activemq-artemis by apache.
the class SimpleJMSStreamMessage method readBytes.
@Override
public int readBytes(final byte[] value) throws JMSException {
if (bodyWriteOnly) {
throw new MessageNotReadableException("The message body is writeonly");
}
try {
Object myObj = content.get(position);
if (myObj == null) {
throw new NullPointerException("Value is null");
} else if (!(myObj instanceof byte[])) {
throw new MessageFormatException("Invalid conversion");
}
byte[] obj = (byte[]) myObj;
if (obj.length == 0) {
position++;
offset = 0;
return 0;
}
if (offset >= obj.length) {
position++;
offset = 0;
return -1;
}
if (obj.length - offset < value.length) {
System.arraycopy(obj, offset, value, 0, obj.length);
position++;
offset = 0;
return obj.length - offset;
} else {
System.arraycopy(obj, offset, value, 0, value.length);
offset += value.length;
return value.length;
}
} catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
use of javax.jms.MessageNotReadableException in project activemq-artemis by apache.
the class SimpleJMSStreamMessage method readObject.
@Override
public Object readObject() throws JMSException {
if (bodyWriteOnly) {
throw new MessageNotReadableException("The message body is writeonly");
}
try {
Object value = content.get(position);
position++;
offset = 0;
return value;
} catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
Aggregations