org.apache.lucene.index
Class Payload

java.lang.Object
  extended by org.apache.lucene.index.Payload
All Implemented Interfaces:
Serializable

public class Payload
extends Object
implements Serializable

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 Tokens containing payload data.

Use TermPositions.getPayloadLength() and TermPositions.getPayload(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.

See Also:
Serialized Form

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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected byte[] data
the byte array containing the payload data


offset

protected int offset
the offset within the byte array


length

protected int length
the length of the payload data

Constructor Detail

Payload

protected 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.

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.

Parameters:
data - the data of this payload
offset - the offset in the data byte array
length - the length of the data
Method Detail

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 array
targetOffset - the offset in the target byte array


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.