CompoundKey extends Key { public static byte[][] decode(byte[] key) { int num = key[0] & 0xFF; byte[][] keyParts = new byte[num][]; int pos = 1; for (int i = 0; i < num; ++i) { int length = Bytes.toInt(key, pos); pos += 4; byte[] keyPart = new byte[length]; System.arraycopy(key, pos, keyPart, 0, length); pos += length; keyParts[i] = keyPart; } return keyParts; } private  CompoundKey(boolean encoded, byte[]... keyParts); static byte[][] decode(byte[] key); static byte[] encode(byte[]... keyParts); static CompoundKey create(byte[]... keyParts); static CompoundKey of(byte[] compoundKey); static CompoundKey create(Key... keyParts); static CompoundKey of(Key compoundKey); int getPartNum(); byte[] getPart(int i);  }
@Test public void testDecode() { byte[][] keyParts = CompoundKey .decode(new byte[] { 3, 0, 0, 0, 1, 42, 0, 0, 0, 2, 12, 13, 0, 0, 0, 3, 1, 2, 3 }); assertEquals(3, keyParts.length); assertEquals(1, keyParts[0].length); assertEquals(42, keyParts[0][0]); assertEquals(2, keyParts[1].length); assertEquals(12, keyParts[1][0]); assertEquals(13, keyParts[1][1]); assertEquals(3, keyParts[2].length); assertEquals(1, keyParts[2][0]); assertEquals(2, keyParts[2][1]); assertEquals(3, keyParts[2][2]); }