Package io.etcd.jetcd

Class ByteSequence

java.lang.Object
io.etcd.jetcd.ByteSequence

public final class ByteSequence extends Object
Etcd binary bytes, easy to convert between byte[], String and ByteString.
  • Field Details

    • EMPTY

      public static final ByteSequence EMPTY
    • NAMESPACE_DELIMITER

      public static final ByteSequence NAMESPACE_DELIMITER
  • Method Details

    • 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:
      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:
      IndexOutOfBoundsException - if beginIndex < 0, endIndex > size(), or beginIndex > endIndex.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString(Charset charset)
    • getBytes

      public byte[] getBytes()
    • isEmpty

      public boolean isEmpty()
    • size

      public int size()
    • toString

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

      public static ByteSequence from(String source, 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)
      Create new ByteSequence from a ByteString.
      Parameters:
      source - input ByteString
      Returns:
      the ByteSequence
    • from

      public static ByteSequence from(byte[] source)
      Create new ByteSequence from raw bytes.
      Parameters:
      source - input bytes
      Returns:
      the ByteSequence