Class ByteArrayUtf8CharSequence

  • All Implemented Interfaces:
    CharSequence, Comparable, 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
    • 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()
      • getStringOrNull

        public String getStringOrNull()
      • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • charAt

        public char charAt​(int index)
        Specified by:
        charAt in interface CharSequence
      • convertCharSeq

        public static Object convertCharSeq​(Object o)
      • _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
      • isValid

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