org.apache.lucene.index
public class Payload extends Object implements Serializable
To store payloads in the index a TokenStream has to be used that produces Tokens containing payload data.
Use getPayloadLength and (byte[], int)
to retrieve the payloads from the index.
WARNING: The status of the Payloads feature is experimental. The APIs introduced here might change in the future and will not be supported anymore in such a case.
| Field Summary | |
|---|---|
| protected byte[] | data the byte array containing the payload data |
| protected int | length the length of the payload data |
| protected int | offset the offset within the byte array |
| Constructor Summary | |
|---|---|
| protected | Payload() Creates an empty payload and does not allocate a byte array. |
| Payload(byte[] data)
Creates a new payload with the the given array as data.
| |
| Payload(byte[] data, int offset, int length)
Creates a new payload with the the given array as data.
| |
| Method Summary | |
|---|---|
| byte | byteAt(int index)
Returns the byte at the given index. |
| void | copyTo(byte[] target, int targetOffset)
Copies the payload data to a byte array.
|
| int | length()
Returns the length of the payload data. |
| byte[] | toByteArray()
Allocates a new byte array, copies the payload data into it and returns it. |
Parameters: data the data of this payload
Parameters: data the data of this payload offset the offset in the data byte array length the length of the data
Parameters: target the target byte array targetOffset the offset in the target byte array