本文整理匯總了Java中javax.jms.BytesMessage.readByte方法的典型用法代碼示例。如果您正苦於以下問題:Java BytesMessage.readByte方法的具體用法?Java BytesMessage.readByte怎麽用?Java BytesMessage.readByte使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jms.BytesMessage
的用法示例。
在下文中一共展示了BytesMessage.readByte方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isSame
import javax.jms.BytesMessage; //導入方法依賴的package包/類
protected boolean isSame(BytesMessage msg1) throws Exception {
boolean result = false;
((ActiveMQMessage) msg1).setReadOnlyBody(true);
for (int i = 0; i < LARGE_MESSAGE_SIZE; i++) {
result = msg1.readByte() == largeMessageData[i];
if (!result) {
break;
}
}
return result;
}
示例2: castTo
import javax.jms.BytesMessage; //導入方法依賴的package包/類
public static <T> T castTo(Class<T> c, Message message) throws JMSException {
if (message == null) {
throw new MessageFormatRuntimeException("empty body");
}
if (!isBodyAssignableTo(message, c)) {
throw new MessageFormatRuntimeException("the message body cannot be assigned to the specified type "
+ c
+ " and the Message type "
+ StreamMessage.class
+ " cannot be used");
}
if (message instanceof ObjectMessage) {
return c.cast(((ObjectMessage) message).getObject());
} else if (message instanceof MapMessage) {
return c.cast(resolveMapMessage((MapMessage) message));
} else if (message instanceof BytesMessage) {
BytesMessage bytesMessage = (BytesMessage) message;
bytesMessage.reset();
try {
byte[] bytes = new byte[(int) bytesMessage.getBodyLength()];
for (int i = 0; i < bytes.length; i++) {
bytes[i] = bytesMessage.readByte();
}
return c.cast(bytes);
} finally {
bytesMessage.reset();
}
} else if (message instanceof TextMessage) {
return c.cast(((TextMessage) message).getText());
} else {
throw new MessageFormatRuntimeException("internal error. unknown message type "
+ message.getClass() + " or empty body");
}
}