public class HeaderSerialization
extends java.lang.Object
AtomPrefixes.IndexedHeaderPrefix
and
AtomPrefixes.KeyedHeaderPrefix
atoms)Modifier and Type | Field and Description |
---|---|
static int |
PREFIX_SIZE
Atom prefixes are 1 byte long
|
Modifier and Type | Method and Description |
---|---|
static BagKey |
parse(AtomPrefixes.HeaderPrefix prefix,
java.nio.ByteBuffer buf)
Parses a bag key
|
static BagKey |
parse(java.nio.ByteBuffer atom)
Parses a bag key from the provided atom
|
static BagKey |
parseIndexedHeaderPayload(AtomPrefixes.HeaderPrefix prefix,
java.nio.ByteBuffer buf)
Parse the payload of an indexed header
|
static BagKey |
parseKeyedHeaderPayload(AtomPrefixes.HeaderPrefix prefix,
java.nio.ByteBuffer buf)
Parse the payload of a keyed header
|
static java.nio.ByteBuffer |
serialize(BagKey.Indexed bagKey,
int level)
Serialize the header atom, including prefix byte, for the provided bagKey and level
|
static java.nio.ByteBuffer |
serialize(BagKey.Keyed bagKey,
int level)
Serialize the header atom, including prefix byte, for the provided bagKey and level
|
static java.nio.ByteBuffer |
serialize(BagKey bagKey,
int level)
Serialize the header atom, including prefix byte, for the provided bagKey and level
|
static int |
serializedSize(BagKey.Indexed bagKey)
Calculates the serialized size of an Indexed header atom including its prefix
|
static int |
serializedSize(BagKey.Keyed bagKey)
Calculates the serialized size of a Keyed header atom including its prefix
|
static java.nio.ByteBuffer |
serializePayload(BagKey.Indexed bagKey)
Serialize the atom payload for the provided bagkey, excluding atom prefix.
|
static java.nio.ByteBuffer |
serializePayload(BagKey.Keyed bagKey)
Serialize the atom payload for the provided bagkey, excluding atom prefix.
|
static void |
writeAtom(java.nio.ByteBuffer buf,
BagKey.Indexed bagKey,
int level)
Write an atom to the provided buffer for the specified bagKey and level.
|
static void |
writeAtom(java.nio.ByteBuffer buf,
BagKey.Keyed bagKey,
int level)
Write an atom to the provided buffer for the specified bagKey and level.
|
static void |
writeAtomPayload(java.nio.ByteBuffer buf,
BagKey.Indexed bagKey)
Write the payload of an Indexed header atom to the provided buf
|
static void |
writeAtomPayload(java.nio.ByteBuffer buf,
BagKey.Keyed bagKey)
Write the payload of an Keyed header atom to the provided buf
|
static void |
writeAtomPrefix(java.nio.ByteBuffer buf,
BagKey.Indexed bagKey,
int level)
Write the prefix byte of an Indexed header atom to the provided buf
|
static void |
writeAtomPrefix(java.nio.ByteBuffer buf,
BagKey.Keyed bagKey,
int level)
Write the prefix byte of a Keyed header atom to the provided buf
|
public static final int PREFIX_SIZE
public static int serializedSize(BagKey.Indexed bagKey)
bagKey
- an Indexed bagkeypublic static int serializedSize(BagKey.Keyed bagKey)
bagKey
- a Keyed header bagKeypublic static void writeAtom(java.nio.ByteBuffer buf, BagKey.Indexed bagKey, int level)
buf
- the buffer to write tobagKey
- the bagKey to writelevel
- the level of the bagKeypublic static void writeAtom(java.nio.ByteBuffer buf, BagKey.Keyed bagKey, int level)
buf
- the buffer to write tobagKey
- the bagKey to writelevel
- the level of the bagKeypublic static void writeAtomPrefix(java.nio.ByteBuffer buf, BagKey.Indexed bagKey, int level)
buf
- the buffer to write tobagKey
- the key of this headerlevel
- the header levelpublic static void writeAtomPrefix(java.nio.ByteBuffer buf, BagKey.Keyed bagKey, int level)
buf
- the buffer to write tobagKey
- the key of this headerlevel
- the header levelpublic static void writeAtomPayload(java.nio.ByteBuffer buf, BagKey.Indexed bagKey)
buf
- the buffer to write tobagKey
- the key of this headerbagKey
- the bagKey to writepublic static void writeAtomPayload(java.nio.ByteBuffer buf, BagKey.Keyed bagKey)
buf
- the buffer to write tobagKey
- the bagKey to writepublic static java.nio.ByteBuffer serialize(BagKey bagKey, int level)
bagKey
- the key to write a header forlevel
- the level of this keypublic static java.nio.ByteBuffer serialize(BagKey.Indexed bagKey, int level)
bagKey
- the key to write a header forlevel
- the level of this keypublic static java.nio.ByteBuffer serialize(BagKey.Keyed bagKey, int level)
bagKey
- the key to write a header forlevel
- the level of this keypublic static java.nio.ByteBuffer serializePayload(BagKey.Indexed bagKey)
bagKey
- the key to write a header forpublic static java.nio.ByteBuffer serializePayload(BagKey.Keyed bagKey)
bagKey
- the key to write a header forpublic static BagKey parse(java.nio.ByteBuffer atom) throws AtomLayerException, BaggageLayerException
atom
- a buffer containing both the prefix of the atom and its payloadAtomLayerException
- if the header payload could not be parsedBaggageLayerException
- if the atom is not a header atompublic static BagKey parse(AtomPrefixes.HeaderPrefix prefix, java.nio.ByteBuffer buf) throws BaggageLayerException
prefix
- the prefix of the atombuf
- the payload of the atomBaggageLayerException
- if the atom is not a header atom or if the header payload could not be parsedpublic static BagKey parseIndexedHeaderPayload(AtomPrefixes.HeaderPrefix prefix, java.nio.ByteBuffer buf) throws BaggageLayerException
prefix
- the prefix of this atombuf
- the payload of the atomBaggageLayerException
- if the atom payload could not be parsedpublic static BagKey parseKeyedHeaderPayload(AtomPrefixes.HeaderPrefix prefix, java.nio.ByteBuffer buf) throws BaggageLayerException
prefix
- the prefix of this atombuf
- the payload of the atomBaggageLayerException
- if the atom payload could not be parsed