Serializable
, Cloneable
public class Payload extends Object implements Serializable, Cloneable
To store payloads in the index a TokenStream
has to be used that
produces payload data.
Use TermPositions.getPayloadLength()
and TermPositions.getPayload(byte[], int)
to retrieve the payloads from the index.
Modifier and Type | Field | Description |
---|---|---|
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 | 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.
|
Modifier and Type | Method | Description |
---|---|---|
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.
|
protected byte[] data
protected int offset
protected int length
public Payload()
public Payload(byte[] data)
data
- the data of this payloadpublic Payload(byte[] data, int offset, int length)
data
- the data of this payloadoffset
- the offset in the data byte arraylength
- the length of the datapublic void setData(byte[] data)
public void setData(byte[] data, int offset, int length)
public byte[] getData()
public int getOffset()
public int length()
public byte byteAt(int index)
public byte[] toByteArray()
public void copyTo(byte[] target, int targetOffset)
target
- the target byte arraytargetOffset
- the offset in the target byte arraypublic Object clone()
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.