static ChunkIndex fromBytes(ChunkKey key, byte[] index, int ptr, int len) throws DhtException { int v = index[ptr] & 0xff; switch (v) { case V1: { final int offsetFormat = index[ptr + 1] & 7; switch (offsetFormat) { case 1: return new Offset1(index, ptr, len, key); case 2: return new Offset2(index, ptr, len, key); case 3: return new Offset3(index, ptr, len, key); case 4: return new Offset4(index, ptr, len, key); default: throw new DhtException(MessageFormat.format( DhtText.get().unsupportedChunkIndex, Integer.toHexString(NB.decodeUInt16(index, ptr)), key)); } } default: throw new DhtException(MessageFormat.format( DhtText.get().unsupportedChunkIndex, Integer.toHexString(v), key)); } }
static ChunkIndex fromBytes(ChunkKey key, byte[] index, int ptr, int len) throws DhtException { int v = index[ptr] & 0xff; switch (v) { case V1: { final int offsetFormat = index[ptr + 1] & 7; switch (offsetFormat) { case 1: return new Offset1(index, ptr, len, key); case 2: return new Offset2(index, ptr, len, key); case 3: return new Offset3(index, ptr, len, key); case 4: return new Offset4(index, ptr, len, key); default: throw new DhtException(MessageFormat.format( DhtText.get().unsupportedChunkIndex, Integer.toHexString(NB.decodeUInt16(index, ptr)), key)); } } default: throw new DhtException(MessageFormat.format( DhtText.get().unsupportedChunkIndex, Integer.toHexString(v), key)); } }