@Override
    public void encode(final ByteBuffer buf, final StringBuilder log)
    {
        final int start = buf.position();
        
        final short count = (short) services.length;
        // Encode service count
        buf.putShort(count);
        if (log != null)
            log.append("UINT count              : ").append(count).append("\n");
        
        // Encode offsets to individual requests
        // Offset to 1st item:
        // 2 bytes for 'count', 2 bytes for each offset
        short offset = (short) (2 + 2 * count);
        for (int i=0; i<count; ++i)
        {
            buf.putShort(offset);
            if (log != null)
                log.append("UINT offset             : ").append(offset).append("\n");
            // Next offset: After bytes for this request
            offset += services[i].getRequestSize();
        }
        
        for (int i=0; i<count; ++i)
        {
            if (log != null)
                log.append("    \\/\\/ request ").append(i+1).append(" \\/\\/ (offset ").append(buf.position() - start).append(" bytes)\n");
            services[i].encode(buf, log);
            if (log != null)
                log.append("    /\\/\\ request ").append(i+1).append(" /\\/\\\n");
        }
    }