use of javax.jms.MessageNotReadableException in project activemq-artemis by apache.
the class SimpleJMSStreamMessage method readBoolean.
// Public --------------------------------------------------------
// StreamMessage implementation ----------------------------------
@Override
public boolean readBoolean() 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 Boolean) {
position++;
return ((Boolean) value).booleanValue();
} else if (value instanceof String) {
boolean result = Boolean.valueOf((String) value).booleanValue();
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 readInt.
@Override
public int readInt() 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).intValue();
} else if (value instanceof Short) {
position++;
return ((Short) value).intValue();
} else if (value instanceof Integer) {
position++;
return ((Integer) value).intValue();
} else if (value instanceof String) {
int result = Integer.parseInt((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 readString.
@Override
public String readString() throws JMSException {
if (bodyWriteOnly) {
throw new MessageNotReadableException("The message body is writeonly");
}
try {
Object value = content.get(position);
offset = 0;
if (value == null) {
position++;
return null;
} else if (value instanceof Boolean) {
position++;
return ((Boolean) value).toString();
} else if (value instanceof Byte) {
position++;
return ((Byte) value).toString();
} else if (value instanceof Short) {
position++;
return ((Short) value).toString();
} else if (value instanceof Character) {
position++;
return ((Character) value).toString();
} else if (value instanceof Integer) {
position++;
return ((Integer) value).toString();
} else if (value instanceof Long) {
position++;
return ((Long) value).toString();
} else if (value instanceof Float) {
position++;
return ((Float) value).toString();
} else if (value instanceof Double) {
position++;
return ((Double) value).toString();
} else if (value instanceof String) {
position++;
return (String) value;
} else {
throw new MessageFormatException("Invalid conversion");
}
} catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
use of javax.jms.MessageNotReadableException in project rabbitmq-jms-client by rabbitmq.
the class RMQBytesMessage method readShort.
/**
* {@inheritDoc}
*/
@Override
public short readShort() throws JMSException {
if (!this.reading)
throw new MessageNotReadableException(NOT_READABLE);
if (this.pos + Bits.NUM_BYTES_IN_SHORT > this.buf.length)
throw new MessageEOFException(MSG_EOF);
short s = Bits.getShort(this.buf, this.pos);
this.pos += Bits.NUM_BYTES_IN_SHORT;
return s;
}
use of javax.jms.MessageNotReadableException in project rabbitmq-jms-client by rabbitmq.
the class RMQBytesMessage method readUnsignedShort.
/**
* {@inheritDoc}
*/
@Override
public int readUnsignedShort() throws JMSException {
if (!this.reading)
throw new MessageNotReadableException(NOT_READABLE);
if (this.pos + Bits.NUM_BYTES_IN_SHORT > this.buf.length)
throw new MessageEOFException(MSG_EOF);
short s = Bits.getShort(this.buf, this.pos);
this.pos += Bits.NUM_BYTES_IN_SHORT;
return ((int) s) & 0xFFFF;
}
Aggregations