Package io.etcd.jetcd

Class ByteSequence


  • public final class ByteSequence
    extends java.lang.Object
    Etcd binary bytes, easy to convert between byte[], String and ByteString.
    • Method Detail

      • startsWith

        public boolean startsWith​(ByteSequence prefix)
        Tests if this ByteSequence starts with the specified prefix.
        Parameters:
        prefix - the prefix.
        Returns:
        true if the byte sequence represented by the argument is a prefix of the byte sequence represented by this string; false otherwise.
      • concat

        public ByteSequence concat​(ByteSequence other)
        Concatenate the given ByteSequence to this one.
        Parameters:
        other - string to concatenate
        Returns:
        a new ByteSequence instance
      • concat

        public ByteSequence concat​(com.google.protobuf.ByteString other)
        Concatenate the given ByteSequence to this one.
        Parameters:
        other - string to concatenate
        Returns:
        a new ByteSequence instance
      • substring

        public ByteSequence substring​(int beginIndex)
        Return the substring from ByteSequence, inclusive, to the end of the string.
        Parameters:
        beginIndex - start at this index
        Returns:
        substring sharing underlying data
        Throws:
        java.lang.IndexOutOfBoundsException - if beginIndex < 0 or beginIndex > size().
      • substring

        public ByteSequence substring​(int beginIndex,
                                      int endIndex)
        Return the substring from beginIndex, inclusive, to endIndex, exclusive.
        Parameters:
        beginIndex - start at this index
        endIndex - the last character is the one before this index
        Returns:
        substring sharing underlying data
        Throws:
        java.lang.IndexOutOfBoundsException - if beginIndex < 0, endIndex > size(), or beginIndex > endIndex.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString​(java.nio.charset.Charset charset)
      • getBytes

        public byte[] getBytes()
      • isEmpty

        public boolean isEmpty()
      • size

        public int size()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • from

        public static ByteSequence from​(java.lang.String source,
                                        java.nio.charset.Charset charset)
        Create new ByteSequence from a String.
        Parameters:
        source - input String
        charset - the character set to use to transform the String into bytes
        Returns:
        the ByteSequence
      • from

        public static ByteSequence from​(com.google.protobuf.ByteString source)