## org.apache.lucene.facet.search
Class PayloadIterator

    java.lang.Object
      org.apache.lucene.facet.search.PayloadIterator

Direct Known Subclasses:
  EnhancementsPayloadIterator

    public class PayloadIterator

extends Object

A utility class for iterating through a posting list of a given term and retrieving the payload of the first occurrence in every document. Comes with its own working space (buffer).

WARNING: This API is experimental and might change in incompatible ways in the next release.

Field Summary
`protected byte[]` `buffer`
`protected int` `payloadLength`

Constructor Summary
`PayloadIterator(IndexReader indexReader, Term term)`
`PayloadIterator(IndexReader indexReader, Term term, byte[] buffer)`

Method Summary
`byte[]` `getBuffer()` Get the buffer with the content of the last read payload.
`int` `getPayloadLength()` Get the length of the last read payload.
`boolean` `init()` (re)initialize the iterator.
`boolean` `setdoc(int docId)` Skip forward to document docId.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### buffer

    protected byte[] buffer

### payloadLength

    protected int payloadLength

Constructor Detail

### PayloadIterator

    public PayloadIterator(IndexReader indexReader,
                           Term term)
                    throws IOException

Throws:
  `IOException`

### PayloadIterator

    public PayloadIterator(IndexReader indexReader,
                           Term term,
                           byte[] buffer)
                    throws IOException

Throws:
  `IOException`

Method Detail

### init

    public boolean init()
                 throws IOException

  (re)initialize the iterator. Should be done before the first call to `setdoc(int)`. Returns false if there is no category list found (no setdoc() will never return true).

  Throws:
    `IOException`

### setdoc

    public boolean setdoc(int docId)
                   throws IOException

  Skip forward to document docId. Return true if this document exists and has any payload.

  Users should call this method with increasing docIds, and implementations can assume that this is the case.

  Throws:
    `IOException`

### getBuffer

    public byte[] getBuffer()

  Get the buffer with the content of the last read payload.

### getPayloadLength

    public int getPayloadLength()

  Get the length of the last read payload.