本文整理汇总了Java中org.apache.activemq.artemis.api.core.ActiveMQBuffer.readByte方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQBuffer.readByte方法的具体用法?Java ActiveMQBuffer.readByte怎么用?Java ActiveMQBuffer.readByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.artemis.api.core.ActiveMQBuffer
的用法示例。
在下文中一共展示了ActiveMQBuffer.readByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: streamReadByte
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static byte streamReadByte(ActiveMQBuffer buff) {
int index = buff.readerIndex();
try {
byte type = buff.readByte();
switch (type) {
case DataConstants.BYTE:
return buff.readByte();
case DataConstants.STRING:
String s = buff.readNullableString();
return Byte.parseByte(s);
default:
throw new IllegalStateException("Invalid conversion");
}
} catch (NumberFormatException e) {
buff.readerIndex(index);
throw e;
}
}
示例2: streamReadChar
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static char streamReadChar(ActiveMQBuffer buff) {
byte type = buff.readByte();
switch (type) {
case DataConstants.CHAR:
return (char) buff.readShort();
case DataConstants.STRING:
String str = buff.readNullableString();
if (str == null) {
throw new NullPointerException("Invalid conversion");
} else {
throw new IllegalStateException("Invalid conversion");
}
default:
throw new IllegalStateException("Invalid conversion");
}
}
示例3: streamReadInteger
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static int streamReadInteger(ActiveMQBuffer buff) {
byte type = buff.readByte();
switch (type) {
case DataConstants.BYTE:
return buff.readByte();
case DataConstants.SHORT:
return buff.readShort();
case DataConstants.INT:
return buff.readInt();
case DataConstants.STRING:
String s = buff.readNullableString();
return Integer.parseInt(s);
default:
throw new IllegalStateException("Invalid conversion");
}
}
示例4: streamReadLong
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static long streamReadLong(ActiveMQBuffer buff) {
byte type = buff.readByte();
switch (type) {
case DataConstants.BYTE:
return buff.readByte();
case DataConstants.SHORT:
return buff.readShort();
case DataConstants.INT:
return buff.readInt();
case DataConstants.LONG:
return buff.readLong();
case DataConstants.STRING:
String s = buff.readNullableString();
return Long.parseLong(s);
default:
throw new IllegalStateException("Invalid conversion");
}
}
示例5: streamReadString
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static String streamReadString(ActiveMQBuffer buff) {
byte type = buff.readByte();
switch (type) {
case DataConstants.BOOLEAN:
return String.valueOf(buff.readBoolean());
case DataConstants.BYTE:
return String.valueOf(buff.readByte());
case DataConstants.SHORT:
return String.valueOf(buff.readShort());
case DataConstants.CHAR:
return String.valueOf((char) buff.readShort());
case DataConstants.INT:
return String.valueOf(buff.readInt());
case DataConstants.LONG:
return String.valueOf(buff.readLong());
case DataConstants.FLOAT:
return String.valueOf(Float.intBitsToFloat(buff.readInt()));
case DataConstants.DOUBLE:
return String.valueOf(Double.longBitsToDouble(buff.readLong()));
case DataConstants.STRING:
return buff.readNullableString();
default:
throw new IllegalStateException("Invalid conversion");
}
}
示例6: streamReadBytes
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
/**
* Utility for reading bytes out of streaming.
* It will return remainingBytes, bytesRead
*
* @param remainingBytes remaining Bytes from previous read. Send it to 0 if it was the first call for the message
* @param buff
* @return a pair of remaining bytes and bytes read
*/
public static Pair<Integer, Integer> streamReadBytes(ActiveMQBuffer buff, int remainingBytes, byte[] value) {
if (remainingBytes == -1) {
return new Pair<>(0, -1);
} else if (remainingBytes == 0) {
byte type = buff.readByte();
if (type != DataConstants.BYTES) {
throw new IllegalStateException("Invalid conversion");
}
remainingBytes = buff.readInt();
}
int read = Math.min(value.length, remainingBytes);
buff.readBytes(value, 0, read);
remainingBytes -= read;
if (remainingBytes == 0) {
remainingBytes = -1;
}
return new Pair<>(remainingBytes, read);
}
示例7: streamReadBoolean
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
/**
* Method to read boolean values out of the Stream protocol existent on JMS Stream Messages
* Throws IllegalStateException if the type was invalid
*
* @param buff
* @return
*/
public static boolean streamReadBoolean(ActiveMQBuffer buff) {
byte type = buff.readByte();
switch (type) {
case DataConstants.BOOLEAN:
return buff.readBoolean();
case DataConstants.STRING:
String s = buff.readNullableString();
return Boolean.valueOf(s);
default:
throw new IllegalStateException("Invalid conversion, type byte was " + type);
}
}
示例8: streamReadFloat
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static float streamReadFloat(ActiveMQBuffer buff) {
byte type = buff.readByte();
switch (type) {
case DataConstants.FLOAT:
return Float.intBitsToFloat(buff.readInt());
case DataConstants.STRING:
String s = buff.readNullableString();
return Float.parseFloat(s);
default:
throw new IllegalStateException("Invalid conversion");
}
}
示例9: decode
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decode(final ActiveMQBuffer buffer) {
name = buffer.readSimpleString();
address = buffer.readSimpleString();
filterString = buffer.readNullableSimpleString();
String metadata = buffer.readNullableSimpleString().toString();
if (metadata != null) {
String[] elements = metadata.split(";");
for (String element : elements) {
String[] keyValuePair = element.split("=");
if (keyValuePair.length == 2) {
if (keyValuePair[0].equals("user")) {
user = SimpleString.toSimpleString(keyValuePair[1]);
}
}
}
}
autoCreated = buffer.readBoolean();
if (buffer.readableBytes() > 0) {
maxConsumers = buffer.readInt();
purgeOnNoConsumers = buffer.readBoolean();
routingType = buffer.readByte();
} else {
maxConsumers = ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
purgeOnNoConsumers = ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers();
routingType = ActiveMQDefaultConfiguration.getDefaultRoutingType().getType();
}
}
示例10: streamReadObject
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static Object streamReadObject(ActiveMQBuffer buff) {
byte type = buff.readByte();
switch (type) {
case DataConstants.BOOLEAN:
return buff.readBoolean();
case DataConstants.BYTE:
return buff.readByte();
case DataConstants.SHORT:
return buff.readShort();
case DataConstants.CHAR:
return (char) buff.readShort();
case DataConstants.INT:
return buff.readInt();
case DataConstants.LONG:
return buff.readLong();
case DataConstants.FLOAT:
return Float.intBitsToFloat(buff.readInt());
case DataConstants.DOUBLE:
return Double.longBitsToDouble(buff.readLong());
case DataConstants.STRING:
return buff.readNullableString();
case DataConstants.BYTES:
int bufferLen = buff.readInt();
byte[] bytes = new byte[bufferLen];
buff.readBytes(bytes);
return bytes;
default:
throw new IllegalStateException("Invalid conversion");
}
}
示例11: read
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private int read(StorageManager storage, ActiveMQBuffer fileBuffer, List<PagedMessage> messages) {
int readMessages = 0;
while (fileBuffer.readable()) {
final int position = fileBuffer.readerIndex();
byte byteRead = fileBuffer.readByte();
if (byteRead == Page.START_BYTE) {
if (fileBuffer.readerIndex() + DataConstants.SIZE_INT < fileBuffer.capacity()) {
int messageSize = fileBuffer.readInt();
int oldPos = fileBuffer.readerIndex();
if (fileBuffer.readerIndex() + messageSize < fileBuffer.capacity() && fileBuffer.getByte(oldPos + messageSize) == Page.END_BYTE) {
PagedMessage msg = new PagedMessageImpl(storageManager);
msg.decode(fileBuffer);
byte b = fileBuffer.readByte();
if (b != Page.END_BYTE) {
// Sanity Check: This would only happen if there is a bug on decode or any internal code, as
// this
// constraint was already checked
throw new IllegalStateException("Internal error, it wasn't possible to locate END_BYTE " + b);
}
msg.initMessage(storage);
if (logger.isTraceEnabled()) {
logger.trace("Reading message " + msg + " on pageId=" + this.pageId + " for address=" + storeName);
}
readMessages++;
messages.add(msg);
} else {
markFileAsSuspect(file.getFileName(), position, messages.size());
break;
}
}
} else {
markFileAsSuspect(file.getFileName(), position, messages.size());
break;
}
}
return readMessages;
}
示例12: decode
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public Message decode(ActiveMQBuffer buffer, Message record) {
byte protocol = buffer.readByte();
Persister<Message> persister = getPersister(protocol);
if (persister == null) {
throw new NullPointerException("couldn't find factory for type=" + protocol);
}
return persister.decode(buffer, record);
}
示例13: assertEqualsBuffers
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
public static void assertEqualsBuffers(final int size, final ActiveMQBuffer expected, final ActiveMQBuffer actual) {
// assertEquals(expected.length, actual.length);
expected.readerIndex(0);
actual.readerIndex(0);
for (int i = 0; i < size; i++) {
byte b1 = expected.readByte();
byte b2 = actual.readByte();
Assert.assertEquals("byte at index " + i, b1, b2);
}
expected.resetReaderIndex();
actual.resetReaderIndex();
}
示例14: decodeRest
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decodeRest(final ActiveMQBuffer buffer) {
journalID = buffer.readByte();
txId = buffer.readLong();
int size = buffer.readInt();
recordData = new byte[size];
buffer.readBytes(recordData);
}
示例15: decodeRest
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void decodeRest(final ActiveMQBuffer buffer) {
journalID = buffer.readByte();
txId = buffer.readLong();
id = buffer.readLong();
int size1 = buffer.readInt();
recordData = new byte[size1];
buffer.readBytes(recordData);
}