@Override
    public int encode(ByteBuffer buffer) {
        encodeThis(buffer);
        int itemCount = 1;

        for (Iterator<Item> i = getItemIterator(); i.hasNext();) {
            Item subitem = i.next();

            if (subitem instanceof PhraseSegmentItem) {
                PhraseSegmentItem seg = (PhraseSegmentItem) subitem;

                // "What encode does, minus what encodeThis does"
                itemCount += seg.encodeContent(buffer);
            } else {
                itemCount += subitem.encode(buffer);
            }
        }
        return itemCount;
    }
Returns a subitem as a block item,

@param index
           the (0-base) index of the item to return
@throws IndexOutOfBoundsException
            if there is no subitem at index
container-search/src/main/java/com/yahoo/prelude/query/PhraseItem.java