/** * Decodes the specified {@link ByteBuffer} into a {@link Sector} object. * * @param buf The buffer. * @return The sector. */ public static Sector decodeExtended(ByteBuffer buf) { if (buf.remaining() != SIZE) throw new IllegalArgumentException(); int id = buf.getInt(); int chunk = buf.getShort() & 0xFFFF; int nextSector = ByteBufferUtils.getMedium(buf); int type = buf.get() & 0xFF; byte[] data = new byte[EXTENDED_DATA_SIZE]; buf.get(data); return new Sector(type, id, chunk, nextSector, data); }