private static int computeAndValidateOffsets(final Node node, final List<Field> fields, final int blockLength)
    {
        boolean variableLengthBlock = false;
        int offset = 0;

        for (final Field field : fields)
        {
            if (0 != field.offset() && field.offset() < offset)
            {
                handleError(node, "Offset provides insufficient space at field: " + field.name());
            }

            if (Token.VARIABLE_LENGTH != offset)
            {
                if (0 != field.offset())
                {
                    offset = field.offset();
                }
                else if (null != field.dimensionType() && 0 != blockLength)
                {
                    offset = blockLength;
                }
                else if (field.isVariableLength() && 0 != blockLength)
                {
                    offset = blockLength;
                }
            }

            field.computedOffset(variableLengthBlock ? Token.VARIABLE_LENGTH : offset);

            if (null != field.groupFields())
            {
                final int groupBlockLength = computeAndValidateOffsets(node, field.groupFields(), 0);

                validateBlockLength(node, field.blockLength(), groupBlockLength);
                field.computedBlockLength(Math.max(field.blockLength(), groupBlockLength));

                variableLengthBlock = true;
            }
            else if (null != field.type() && Presence.CONSTANT != field.presence())
            {
                final int size = field.type().encodedLength();

                if (Token.VARIABLE_LENGTH == size)
                {
                    variableLengthBlock = true;
                }
                else
                {
                    field.computedBlockLength(size);
                }

                if (!variableLengthBlock)
                {
                    offset += size;
                }
            }
        }

        return offset;
    }
Return the encodedLength of the {@link Message} in bytes including any padding.

@return the encodedLength of the {@link Message} in bytes including any padding.
sbe-tool/src/main/java/uk/co/real_logic/sbe/xml/Message.java