public class

Payload

extends Object
implements Serializable Cloneable
java.lang.Object
   ↳ org.apache.lucene.index.Payload

Class Overview

A Payload is metadata that can be stored together with each occurrence of a term. This metadata is stored inline in the posting list of the specific term.

To store payloads in the index a TokenStream has to be used that produces payload data.

Use getPayloadLength() and getPayload(byte[], int) to retrieve the payloads from the index.

Summary

Fields
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
Public Constructors
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.
Public Methods
byte byteAt(int index)
Returns the byte at the given index.
Object clone()
Clones this payload by creating a copy of the underlying byte array.
void copyTo(byte[] target, int targetOffset)
Copies the payload data to a byte array.
boolean equals(Object obj)
byte[] getData()
Returns a reference to the underlying byte array that holds this payloads data.
int getOffset()
Returns the offset in the underlying byte array
int hashCode()
int length()
Returns the length of the payload data.
void setData(byte[] data)
Sets this payloads data.
void setData(byte[] data, int offset, int length)
Sets this payloads data.
byte[] toByteArray()
Allocates a new byte array, copies the payload data into it and returns it.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

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

Public Constructors

public Payload ()

Creates an empty payload and does not allocate a byte array.

public Payload (byte[] data)

Creates a new payload with the the given array as data. A reference to the passed-in array is held, i. e. no copy is made.

Parameters
data the data of this payload

public Payload (byte[] data, int offset, int length)

Creates a new payload with the the given array as data. A reference to the passed-in array is held, i. e. no copy is made.

Parameters
data the data of this payload
offset the offset in the data byte array
length the length of the data

Public Methods

public byte byteAt (int index)

Returns the byte at the given index.

public Object clone ()

Clones this payload by creating a copy of the underlying byte array.

public void copyTo (byte[] target, int targetOffset)

Copies the payload data to a byte array.

Parameters
target the target byte array
targetOffset the offset in the target byte array

public boolean equals (Object obj)

public byte[] getData ()

Returns a reference to the underlying byte array that holds this payloads data.

public int getOffset ()

Returns the offset in the underlying byte array

public int hashCode ()

public int length ()

Returns the length of the payload data.

public void setData (byte[] data)

Sets this payloads data. A reference to the passed-in array is held, i. e. no copy is made.

public void setData (byte[] data, int offset, int length)

Sets this payloads data. A reference to the passed-in array is held, i. e. no copy is made.

public byte[] toByteArray ()

Allocates a new byte array, copies the payload data into it and returns it.