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`

    public class ByteArrayUtf8CharSequence
    extends Object
    implements 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

Fields
`protected byte[]` `buf`
`protected int` `hashCode`
`protected int` `length`
`protected int` `offset`
`Function<ByteArrayUtf8CharSequence,​String>` `stringProvider`
`protected String` `utf16`

### Constructor Summary

Constructors
`ByteArrayUtf8CharSequence​(byte[] buf, int offset, int length)`
`ByteArrayUtf8CharSequence​(String utf16)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static boolean` `_equals​(byte[] a, int aFromIndex, int aToIndex, byte[] b, int bFromIndex, int bToIndex)` Behaves like Java 9's Arrays.equals
`byte` `byteAt​(int idx)`
`char` `charAt​(int index)`
`ByteArrayUtf8CharSequence` `clone()`
`static Object` `convertCharSeq​(Object o)`
`static Collection` `convertCharSeq​(Collection<?> vals)`
`static Map.Entry` `convertCharSeq​(Map.Entry e)`
`ByteArrayUtf8CharSequence` `deepCopy()`
`boolean` `equals​(Object other)`
`byte[]` `getBuf()`
`String` `getStringOrNull()` this is for internal use, to get a cached string value.
`int` `hashCode()`
`boolean` `isValid()` Performs internal consistency checks.
`int` `length()`
`int` `offset()`
`ByteArrayUtf8CharSequence` `reset​(byte[] bytes, int offset, int length, String str)`
`int` `size()` The size of utf8 bytes
`CharSequence` `subSequence​(int start, int end)`
`String` `toString()`
`static boolean` `utf8Equals​(Utf8CharSequence utf8_1, Utf8CharSequence utf8_2)`
`int` `write​(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, wait`

### Methods inherited from interface java.lang.CharSequence

`chars, codePoints`

### Methods inherited from interface org.apache.solr.common.util.Utf8CharSequence

`compareTo, write`

### Field Detail

#### buf

    protected byte[] buf

#### offset

    protected int offset

#### hashCode

    protected int hashCode

#### length

    protected int length

#### utf16

    protected volatile String utf16

#### stringProvider

    public Function<ByteArrayUtf8CharSequence,​String> stringProvider

### Constructor Detail

#### ByteArrayUtf8CharSequence

    public ByteArrayUtf8CharSequence​(String utf16)

#### ByteArrayUtf8CharSequence

    public ByteArrayUtf8CharSequence​(byte[] buf,
                                     int offset,
                                     int length)

### Method Detail

#### getBuf

    public byte[] getBuf()

#### offset

    public int offset()

#### byteAt

    public byte byteAt​(int idx)

Specified by:
  `byteAt` in interface `Utf8CharSequence`

#### getStringOrNull

    public String 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: `Utf8CharSequence`
Write 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:
  `write` in interface `Utf8CharSequence`
Parameters:
  `start` - position from which to start writing
  `buffer` - the buffer to which to write to
  `pos` - position to start writing
Returns:
  no:of bytes written

#### size

    public int size()

Description copied from interface: `Utf8CharSequence`
The size of utf8 bytes

Specified by:
  `size` in interface `Utf8CharSequence`
Returns:
  the size

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### length

    public int length()

Specified by:
  `length` in interface `CharSequence`

#### equals

    public boolean equals​(Object other)

Overrides:
  `equals` in class `Object`

#### utf8Equals

    public static boolean utf8Equals​(Utf8CharSequence utf8_1,
                                     Utf8CharSequence utf8_2)

#### charAt

    public char charAt​(int index)

Specified by:
  `charAt` in interface `CharSequence`

#### subSequence

    public CharSequence subSequence​(int start,
                                    int end)

Specified by:
  `subSequence` in interface `CharSequence`

#### clone

    public ByteArrayUtf8CharSequence clone()

Specified by:
  `clone` in interface `Utf8CharSequence`
Overrides:
  `clone` in class `Object`

#### deepCopy

    public ByteArrayUtf8CharSequence deepCopy()

#### convertCharSeq

    public static Map.Entry convertCharSeq​(Map.Entry e)

#### convertCharSeq

    public static Collection convertCharSeq​(Collection<?> vals)

#### convertCharSeq

    public static Object convertCharSeq​(Object o)

#### toString

    public String toString()

Specified by:
  `toString` in interface `CharSequence`
Overrides:
  `toString` in class `Object`

#### _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:
  Arrays.equals

#### reset

    public ByteArrayUtf8CharSequence reset​(byte[] bytes,
                                           int offset,
                                           int length,
                                           String str)

#### isValid

    public boolean isValid()

Performs internal consistency checks. Always returns true (or throws IllegalStateException)