|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.util.BytesRef
public final class BytesRef
Represents byte[], as a slice (offset + length) into an existing byte[].
Field Summary | |
---|---|
byte[] |
bytes
The contents of the BytesRef. |
static byte[] |
EMPTY_BYTES
An empty byte array for convenience |
int |
length
Length of used bytes. |
int |
offset
Offset of first valid byte. |
Constructor Summary | |
---|---|
BytesRef()
Create a BytesRef with EMPTY_BYTES |
|
BytesRef(byte[] bytes)
This instance will directly reference bytes w/o making a copy. |
|
BytesRef(byte[] bytes,
int offset,
int length)
This instance will directly reference bytes w/o making a copy. |
|
BytesRef(CharSequence text)
Initialize the byte[] from the UTF8 bytes for the provided String. |
|
BytesRef(int capacity)
Create a BytesRef pointing to a new array of size capacity . |
Method Summary | |
---|---|
void |
append(BytesRef other)
Appends the bytes from the given BytesRef |
boolean |
bytesEquals(BytesRef other)
Expert: compares the bytes against another BytesRef, returning true if the bytes are equal. |
BytesRef |
clone()
|
int |
compareTo(BytesRef other)
Unsigned byte order comparison |
void |
copyBytes(BytesRef other)
Copies the bytes from the given BytesRef |
void |
copyChars(char[] text,
int offset,
int length)
Copies the UTF8 bytes for this string. |
void |
copyChars(CharSequence text)
Copies the UTF8 bytes for this string. |
static BytesRef |
deepCopyOf(BytesRef other)
Creates a new BytesRef that points to a copy of the bytes from other |
boolean |
endsWith(BytesRef other)
|
boolean |
equals(Object other)
|
static Comparator<BytesRef> |
getUTF8SortedAsUnicodeComparator()
|
static Comparator<BytesRef> |
getUTF8SortedAsUTF16Comparator()
|
void |
grow(int newLength)
|
int |
hashCode()
Calculates the hash code as required by TermsHash during indexing. |
boolean |
startsWith(BytesRef other)
|
String |
toString()
Returns hex encoded bytes, eg [0x6c 0x75 0x63 0x65 0x6e 0x65] |
String |
utf8ToString()
Interprets stored bytes as UTF8 bytes, returning the resulting string |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final byte[] EMPTY_BYTES
public byte[] bytes
null
.
public int offset
public int length
Constructor Detail |
---|
public BytesRef()
EMPTY_BYTES
public BytesRef(byte[] bytes, int offset, int length)
public BytesRef(byte[] bytes)
public BytesRef(int capacity)
capacity
.
Offset and length will both be zero.
public BytesRef(CharSequence text)
text
- This must be well-formed
unicode text, with no unpaired surrogates.Method Detail |
---|
public void copyChars(CharSequence text)
text
- Must be well-formed unicode text, with no
unpaired surrogates.public void copyChars(char[] text, int offset, int length)
text
- Must be well-formed unicode text, with no
unpaired surrogates.public boolean bytesEquals(BytesRef other)
other
- Another BytesRef, should not be null.public BytesRef clone()
clone
in class Object
public boolean startsWith(BytesRef other)
public boolean endsWith(BytesRef other)
public int hashCode()
It is defined as:
int hash = 0; for (int i = offset; i < offset + length; i++) { hash = 31*hash + bytes[i]; }
hashCode
in class Object
public boolean equals(Object other)
equals
in class Object
public String utf8ToString()
public String toString()
toString
in class Object
public void copyBytes(BytesRef other)
BytesRef
NOTE: if this would exceed the array size, this method creates a new reference array.
public void append(BytesRef other)
BytesRef
NOTE: if this would exceed the array size, this method creates a new reference array.
public void grow(int newLength)
public int compareTo(BytesRef other)
compareTo
in interface Comparable<BytesRef>
public static Comparator<BytesRef> getUTF8SortedAsUnicodeComparator()
public static Comparator<BytesRef> getUTF8SortedAsUTF16Comparator()
public static BytesRef deepCopyOf(BytesRef other)
other
The returned BytesRef will have a length of other.length and an offset of zero.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |