Package io.etcd.jetcd
Class ByteSequence
- java.lang.Object
-
- io.etcd.jetcd.ByteSequence
-
public final class ByteSequence extends java.lang.ObjectEtcd binary bytes, easy to convert between byte[], String and ByteString.
-
-
Field Summary
Fields Modifier and Type Field Description static ByteSequenceEMPTYstatic ByteSequenceNAMESPACE_DELIMITER
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteSequenceconcat(com.google.protobuf.ByteString other)Concatenate the givenByteSequenceto this one.ByteSequenceconcat(ByteSequence other)Concatenate the givenByteSequenceto this one.booleanequals(java.lang.Object obj)static ByteSequencefrom(byte[] source)static ByteSequencefrom(com.google.protobuf.ByteString source)static ByteSequencefrom(java.lang.String source, java.nio.charset.Charset charset)Create new ByteSequence from a String.byte[]getBytes()inthashCode()booleanisEmpty()intsize()booleanstartsWith(ByteSequence prefix)Tests if thisByteSequencestarts with the specified prefix.ByteSequencesubstring(int beginIndex)Return the substring fromByteSequence, inclusive, to the end of the string.ByteSequencesubstring(int beginIndex, int endIndex)Return the substring frombeginIndex, inclusive, toendIndex, exclusive.java.lang.StringtoString()java.lang.StringtoString(java.nio.charset.Charset charset)
-
-
-
Field Detail
-
EMPTY
public static final ByteSequence EMPTY
-
NAMESPACE_DELIMITER
public static final ByteSequence NAMESPACE_DELIMITER
-
-
Method Detail
-
startsWith
public boolean startsWith(ByteSequence prefix)
Tests if thisByteSequencestarts with the specified prefix.- Parameters:
prefix- the prefix.- Returns:
trueif the byte sequence represented by the argument is a prefix of the byte sequence represented by this string;falseotherwise.
-
concat
public ByteSequence concat(ByteSequence other)
Concatenate the givenByteSequenceto this one.- Parameters:
other- string to concatenate- Returns:
- a new
ByteSequenceinstance
-
concat
public ByteSequence concat(com.google.protobuf.ByteString other)
Concatenate the givenByteSequenceto this one.- Parameters:
other- string to concatenate- Returns:
- a new
ByteSequenceinstance
-
substring
public ByteSequence substring(int beginIndex)
Return the substring fromByteSequence, inclusive, to the end of the string.- Parameters:
beginIndex- start at this index- Returns:
- substring sharing underlying data
- Throws:
java.lang.IndexOutOfBoundsException- ifbeginIndex < 0orbeginIndex > size().
-
substring
public ByteSequence substring(int beginIndex, int endIndex)
Return the substring frombeginIndex, inclusive, toendIndex, exclusive.- Parameters:
beginIndex- start at this indexendIndex- the last character is the one before this index- Returns:
- substring sharing underlying data
- Throws:
java.lang.IndexOutOfBoundsException- ifbeginIndex < 0,endIndex > size(), orbeginIndex > endIndex.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.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:
toStringin classjava.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 Stringcharset- the character set to use to transform the String into bytes- Returns:
- the ByteSequence
-
from
public static ByteSequence from(com.google.protobuf.ByteString source)
-
from
public static ByteSequence from(byte[] source)
-
-