Package org.apache.solr.common.util
Class ByteArrayUtf8CharSequence
java.lang.Object
org.apache.solr.common.util.ByteArrayUtf8CharSequence
- All Implemented Interfaces:
CharSequence,Cloneable,Comparable<Utf8CharSequence>,Utf8CharSequence
A mutable byte[] backed Utf8CharSequence. This is quite similar to the BytesRef of Lucene Do not
alter the contents of the byte[] . it may be inconsistent with the cached String This is designed
for single-threaded use
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]protected intprotected intprotected intprotected String -
Constructor Summary
ConstructorsConstructorDescriptionByteArrayUtf8CharSequence(byte[] buf, int offset, int length) ByteArrayUtf8CharSequence(String utf16) -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean_equals(byte[] a, int aFromIndex, int aToIndex, byte[] b, int bFromIndex, int bToIndex) Behaves like Java 9's Arrays.equalsbytebyteAt(int idx) charcharAt(int index) clone()static Objectstatic CollectionconvertCharSeq(Collection<?> vals) static Map.EntrydeepCopy()booleanbyte[]getBuf()this is for internal use, to get a cached string value.inthashCode()booleanisValid()Performs internal consistency checks.intlength()intoffset()intsize()The size of utf8 bytessubSequence(int start, int end) toString()static booleanutf8Equals(Utf8CharSequence utf8_1, Utf8CharSequence utf8_2) intwrite(int start, byte[] buffer, int pos) Write the bytes into a buffer.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmptyMethods inherited from interface org.apache.solr.common.util.Utf8CharSequence
compareTo, write
-
Field Details
-
buf
protected byte[] buf -
offset
protected int offset -
hashCode
protected int hashCode -
length
protected int length -
utf16
-
stringProvider
-
-
Constructor Details
-
ByteArrayUtf8CharSequence
-
ByteArrayUtf8CharSequence
public ByteArrayUtf8CharSequence(byte[] buf, int offset, int length)
-
-
Method Details
-
getBuf
public byte[] getBuf() -
offset
public int offset() -
byteAt
public byte byteAt(int idx) - Specified by:
byteAtin interfaceUtf8CharSequence
-
getStringOrNull
this is for internal use, to get a cached string value. returns null if there is no cached String value -
write
public int write(int start, byte[] buffer, int pos) Description copied from interface:Utf8CharSequenceWrite the bytes into a buffer. The objective is to avoid the local bytes being exposed to other classes if the implementation is expected to be immutable. It writes as many bytes as possible into the buffer and then return how many bytes were written. It's the responsibility of the caller to call this method repeatedly and ensure that everything is completely written- Specified by:
writein interfaceUtf8CharSequence- Parameters:
start- position from which to start writingbuffer- the buffer to which to write topos- position to start writing- Returns:
- no:of bytes written
-
size
public int size()Description copied from interface:Utf8CharSequenceThe size of utf8 bytes- Specified by:
sizein interfaceUtf8CharSequence- Returns:
- the size
-
hashCode
public int hashCode() -
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
equals
-
utf8Equals
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
clone
- Specified by:
clonein interfaceUtf8CharSequence- Overrides:
clonein classObject
-
deepCopy
-
convertCharSeq
-
convertCharSeq
-
convertCharSeq
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
_equals
public static boolean _equals(byte[] a, int aFromIndex, int aToIndex, byte[] b, int bFromIndex, int bToIndex) Behaves like Java 9's Arrays.equals- See Also:
-
reset
-
isValid
public boolean isValid()Performs internal consistency checks. Always returns true (or throws IllegalStateException)
-