Package org.apache.lucene.index
Class Payload
- java.lang.Object
-
- org.apache.lucene.index.Payload
-
- All Implemented Interfaces:
Serializable,Cloneable
public class Payload extends Object implements Serializable, Cloneable
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
TokenStreamhas to be used that produces payload data.Use
TermPositions.getPayloadLength()andTermPositions.getPayload(byte[], int)to retrieve the payloads from the index.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description bytebyteAt(int index)Returns the byte at the given index.Objectclone()Clones this payload by creating a copy of the underlying byte array.voidcopyTo(byte[] target, int targetOffset)Copies the payload data to a byte array.booleanequals(Object obj)byte[]getData()Returns a reference to the underlying byte array that holds this payloads data.intgetOffset()Returns the offset in the underlying byte arrayinthashCode()intlength()Returns the length of the payload data.voidsetData(byte[] data)Sets this payloads data.voidsetData(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.
-
-
-
Constructor Detail
-
Payload
public Payload()
Creates an empty payload and does not allocate a byte array.
-
Payload
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
-
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 payloadoffset- the offset in the data byte arraylength- the length of the data
-
-
Method Detail
-
setData
public void setData(byte[] data)
Sets this payloads data. A reference to the passed-in array is held, i. e. no copy is made.
-
setData
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.
-
getData
public byte[] getData()
Returns a reference to the underlying byte array that holds this payloads data.
-
getOffset
public int getOffset()
Returns the offset in the underlying byte array
-
length
public int length()
Returns the length of the payload data.
-
byteAt
public byte byteAt(int index)
Returns the byte at the given index.
-
toByteArray
public byte[] toByteArray()
Allocates a new byte array, copies the payload data into it and returns it.
-
copyTo
public void copyTo(byte[] target, int targetOffset)Copies the payload data to a byte array.- Parameters:
target- the target byte arraytargetOffset- the offset in the target byte array
-
clone
public Object clone()
Clones this payload by creating a copy of the underlying byte array.
-
-