Package org.apache.lucene.util
Class BytesRefBuilder
- java.lang.Object
-
- org.apache.lucene.util.BytesRefBuilder
-
-
Constructor Summary
Constructors Constructor Description BytesRefBuilder()Sole constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(byte b)Append a single byte to this builder.voidappend(byte[] b, int off, int len)Append the provided bytes to this builder.voidappend(BytesRef ref)Append the provided bytes to this builder.voidappend(BytesRefBuilder builder)Append the provided bytes to this builder.bytebyteAt(int offset)Return the byte at the given offset.byte[]bytes()Return a reference to the bytes of this builder.voidclear()Reset this builder to the empty state.voidcopyBytes(byte[] b, int off, int len)Replace the content of this builder with the provided bytes.voidcopyBytes(BytesRef ref)Replace the content of this builder with the provided bytes.voidcopyBytes(BytesRefBuilder builder)Replace the content of this builder with the provided bytes.voidcopyChars(char[] text, int off, int len)Replace the content of this buffer with UTF-8 encoded bytes that would represent the provided text.voidcopyChars(CharSequence text)Replace the content of this buffer with UTF-8 encoded bytes that would represent the provided text.voidcopyChars(CharSequence text, int off, int len)Replace the content of this buffer with UTF-8 encoded bytes that would represent the provided text.booleanequals(Object obj)BytesRefget()Return aBytesRefthat points to the internal content of this builder.voidgrow(int capacity)Ensure that this builder can hold at leastcapacitybytes without resizing.voidgrowNoCopy(int capacity)Used to grow the builder without copying bytes.inthashCode()intlength()Return the number of bytes in this buffer.voidsetByteAt(int offset, byte b)Set a byte.voidsetLength(int length)Set the length.BytesReftoBytesRef()Build a newBytesRefthat has the same content as this buffer.
-
-
-
Method Detail
-
bytes
public byte[] bytes()
Return a reference to the bytes of this builder.
-
length
public int length()
Return the number of bytes in this buffer.
-
setLength
public void setLength(int length)
Set the length.
-
byteAt
public byte byteAt(int offset)
Return the byte at the given offset.
-
setByteAt
public void setByteAt(int offset, byte b)Set a byte.
-
grow
public void grow(int capacity)
Ensure that this builder can hold at leastcapacitybytes without resizing.
-
growNoCopy
public void growNoCopy(int capacity)
Used to grow the builder without copying bytes. seeArrayUtil.growNoCopy(byte[], int).
-
append
public void append(byte b)
Append a single byte to this builder.
-
append
public void append(byte[] b, int off, int len)Append the provided bytes to this builder.
-
append
public void append(BytesRef ref)
Append the provided bytes to this builder.
-
append
public void append(BytesRefBuilder builder)
Append the provided bytes to this builder.
-
clear
public void clear()
Reset this builder to the empty state.
-
copyBytes
public void copyBytes(byte[] b, int off, int len)Replace the content of this builder with the provided bytes. Equivalent to callingclear()and thenappend(byte[], int, int).
-
copyBytes
public void copyBytes(BytesRef ref)
Replace the content of this builder with the provided bytes. Equivalent to callingclear()and thenappend(BytesRef).
-
copyBytes
public void copyBytes(BytesRefBuilder builder)
Replace the content of this builder with the provided bytes. Equivalent to callingclear()and thenappend(BytesRefBuilder).
-
copyChars
public void copyChars(CharSequence text)
Replace the content of this buffer with UTF-8 encoded bytes that would represent the provided text.
-
copyChars
public void copyChars(CharSequence text, int off, int len)
Replace the content of this buffer with UTF-8 encoded bytes that would represent the provided text.
-
copyChars
public void copyChars(char[] text, int off, int len)Replace the content of this buffer with UTF-8 encoded bytes that would represent the provided text.
-
get
public BytesRef get()
Return aBytesRefthat points to the internal content of this builder. Any update to the content of this builder might invalidate the providedrefand vice-versa.
-
toBytesRef
public BytesRef toBytesRef()
Build a newBytesRefthat has the same content as this buffer.
-
-