| Method from org.apache.lucene.index.Payload Detail: |
public byte byteAt(int index) {
if (0 < = index && index < this.length) {
return this.data[this.offset + index];
}
throw new ArrayIndexOutOfBoundsException(index);
}
Returns the byte at the given index. |
public Object clone() {
try {
// Start with a shallow copy of data
Payload clone = (Payload) super.clone();
// Only copy the part of data that belongs to this Payload
if (offset == 0 && length == data.length) {
// It is the whole thing, so just clone it.
clone.data = (byte[]) data.clone();
}
else {
// Just get the part
clone.data = this.toByteArray();
clone.offset = 0;
}
return clone;
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e); // shouldn't happen
}
}
Clones this payload by creating a copy of the underlying
byte array. |
public void copyTo(byte[] target,
int targetOffset) {
if (this.length > target.length + targetOffset) {
throw new ArrayIndexOutOfBoundsException();
}
System.arraycopy(this.data, this.offset, target, targetOffset, this.length);
}
Copies the payload data to a byte array. |
public boolean equals(Object obj) {
if (obj == this)
return true;
if (obj instanceof Payload) {
Payload other = (Payload) obj;
if (length == other.length) {
for(int i=0;i< length;i++)
if (data[offset+i] != other.data[other.offset+i])
return false;
return true;
} else
return false;
} else
return false;
}
|
public byte[] getData() {
return this.data;
}
Returns a reference to the underlying byte array
that holds this payloads data. |
public int getOffset() {
return this.offset;
}
Returns the offset in the underlying byte array |
public int hashCode() {
return ArrayUtil.hashCode(data, offset, offset+length);
}
|
public int length() {
return this.length;
}
Returns the length of the payload data. |
public void setData(byte[] data) {
setData(data, 0, data.length);
}
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) {
this.data = data;
this.offset = offset;
this.length = length;
}
Sets this payloads data.
A reference to the passed-in array is held, i. e. no
copy is made. |
public byte[] toByteArray() {
byte[] retArray = new byte[this.length];
System.arraycopy(this.data, this.offset, retArray, 0, this.length);
return retArray;
}
Allocates a new byte array, copies the payload data into it and returns it. |