@Test public void testSerializeIndexed() { int index = 7; BagOptions options = BagOptions.defaultOptions(); int level = 4; ByteBuffer buf = HeaderSerialization.serialize(indexed(index, options), level); assertEquals(IndexedHeaderPrefix.prefixFor(level, options).prefix, buf.get(0)); assertEquals(index, buf.get(1)); }
public static ByteBuffer serialize(BagKey bagKey, int level) { if (bagKey instanceof BagKey.Indexed) { return serialize((BagKey.Indexed) bagKey, level); } else if (bagKey instanceof BagKey.Keyed) { return serialize((BagKey.Keyed) bagKey, level); } else { throw new BaggageLayerRuntimeException("Cannot serialize unsupported bagKey " + bagKey); } }
HeaderSerialization { public static ByteBuffer serialize(BagKey bagKey, int level) { if (bagKey instanceof BagKey.Indexed) { return serialize((BagKey.Indexed) bagKey, level); } else if (bagKey instanceof BagKey.Keyed) { return serialize((BagKey.Keyed) bagKey, level); } else { throw new BaggageLayerRuntimeException("Cannot serialize unsupported bagKey " + bagKey); } } }
HeaderSerialization { public static ByteBuffer serialize(BagKey bagKey, int level) { if (bagKey instanceof BagKey.Indexed) { return serialize((BagKey.Indexed) bagKey, level); } else if (bagKey instanceof BagKey.Keyed) { return serialize((BagKey.Keyed) bagKey, level); } else { throw new BaggageLayerRuntimeException("Cannot serialize unsupported bagKey " + bagKey); } } private  HeaderSerialization(); }
HeaderSerialization { public static ByteBuffer serialize(BagKey bagKey, int level) { if (bagKey instanceof BagKey.Indexed) { return serialize((BagKey.Indexed) bagKey, level); } else if (bagKey instanceof BagKey.Keyed) { return serialize((BagKey.Keyed) bagKey, level); } else { throw new BaggageLayerRuntimeException("Cannot serialize unsupported bagKey " + bagKey); } } private  HeaderSerialization(); static int serializedSize(BagKey.Indexed bagKey); static int serializedSize(BagKey.Keyed bagKey); static void writeAtom(ByteBuffer buf, BagKey.Indexed bagKey, int level); static void writeAtom(ByteBuffer buf, BagKey.Keyed bagKey, int level); static void writeAtomPrefix(ByteBuffer buf, BagKey.Indexed bagKey, int level); static void writeAtomPrefix(ByteBuffer buf, BagKey.Keyed bagKey, int level); static void writeAtomPayload(ByteBuffer buf, BagKey.Indexed bagKey); static void writeAtomPayload(ByteBuffer buf, BagKey.Keyed bagKey); static ByteBuffer serialize(BagKey bagKey, int level); static ByteBuffer serialize(BagKey.Indexed bagKey, int level); static ByteBuffer serialize(BagKey.Keyed bagKey, int level); static ByteBuffer serializePayload(BagKey.Indexed bagKey); static ByteBuffer serializePayload(BagKey.Keyed bagKey); static BagKey parse(ByteBuffer atom); static BagKey parse(HeaderPrefix prefix, ByteBuffer buf); static BagKey parseIndexedHeaderPayload(HeaderPrefix prefix, ByteBuffer buf); static BagKey parseKeyedHeaderPayload(HeaderPrefix prefix, ByteBuffer buf); }
HeaderSerialization { public static ByteBuffer serialize(BagKey bagKey, int level) { if (bagKey instanceof BagKey.Indexed) { return serialize((BagKey.Indexed) bagKey, level); } else if (bagKey instanceof BagKey.Keyed) { return serialize((BagKey.Keyed) bagKey, level); } else { throw new BaggageLayerRuntimeException("Cannot serialize unsupported bagKey " + bagKey); } } private  HeaderSerialization(); static int serializedSize(BagKey.Indexed bagKey); static int serializedSize(BagKey.Keyed bagKey); static void writeAtom(ByteBuffer buf, BagKey.Indexed bagKey, int level); static void writeAtom(ByteBuffer buf, BagKey.Keyed bagKey, int level); static void writeAtomPrefix(ByteBuffer buf, BagKey.Indexed bagKey, int level); static void writeAtomPrefix(ByteBuffer buf, BagKey.Keyed bagKey, int level); static void writeAtomPayload(ByteBuffer buf, BagKey.Indexed bagKey); static void writeAtomPayload(ByteBuffer buf, BagKey.Keyed bagKey); static ByteBuffer serialize(BagKey bagKey, int level); static ByteBuffer serialize(BagKey.Indexed bagKey, int level); static ByteBuffer serialize(BagKey.Keyed bagKey, int level); static ByteBuffer serializePayload(BagKey.Indexed bagKey); static ByteBuffer serializePayload(BagKey.Keyed bagKey); static BagKey parse(ByteBuffer atom); static BagKey parse(HeaderPrefix prefix, ByteBuffer buf); static BagKey parseIndexedHeaderPayload(HeaderPrefix prefix, ByteBuffer buf); static BagKey parseKeyedHeaderPayload(HeaderPrefix prefix, ByteBuffer buf); static final int PREFIX_SIZE; }