public final class MessageSerializationHelper extends Object
Modifier and Type | Method and Description |
---|---|
static String |
extractIndexName(int startingOffset,
byte[] rawBuffer)
Extracts the string only from the header of a byte array.
|
static byte[] |
extractSerializedQueue(int startingOffset,
int bufferLength,
byte[] rawBuffer)
Inverse operation of
prependString(String, byte[]) : extracts
the original buffer discarding the prefixed string. |
static int |
fromByteToInt(byte b) |
static byte |
fromIntToByte(int i) |
static byte[] |
prependString(String name,
byte[] data)
Byte encodes a String as a prefix for an existing byte buffer
|
public static byte[] prependString(String name, byte[] data)
name
- the string to encodedata
- the existing bufferpublic static String extractIndexName(int startingOffset, byte[] rawBuffer)
prependString(String, byte[])
The buffer is not altered.startingOffset
- the starting offset of our message in the larger network bufferrawBuffer
- an array of byte.public static byte[] extractSerializedQueue(int startingOffset, int bufferLength, byte[] rawBuffer)
prependString(String, byte[])
: extracts
the original buffer discarding the prefixed string.
The buffer is not altered.startingOffset
- the starting offset of our message in the larger network bufferbufferLength
- we won't attempt to access the buffer beyond this indexrawBuffer
- an array of byte.public static int fromByteToInt(byte b)
public static byte fromIntToByte(int i)
Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved