Package io.etcd.jetcd
Class ByteSequence
java.lang.Object
io.etcd.jetcd.ByteSequence
Etcd binary bytes, easy to convert between byte[], String and ByteString.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionconcat(com.google.protobuf.ByteString other) Concatenate the givenByteSequenceto this one.concat(ByteSequence other) Concatenate the givenByteSequenceto this one.booleanstatic ByteSequencefrom(byte[] source) Create new ByteSequence from raw bytes.static ByteSequencefrom(com.google.protobuf.ByteString source) Create new ByteSequence from aByteString.static ByteSequenceCreate new ByteSequence from a String.byte[]getBytes()inthashCode()booleanisEmpty()intsize()booleanstartsWith(ByteSequence prefix) Tests if thisByteSequencestarts with the specified prefix.substring(int beginIndex) Return the substring fromByteSequence, inclusive, to the end of the string.substring(int beginIndex, int endIndex) Return the substring frombeginIndex, inclusive, toendIndex, exclusive.toString()
-
Field Details
-
EMPTY
-
NAMESPACE_DELIMITER
-
-
Method Details
-
startsWith
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
Concatenate the givenByteSequenceto this one.- Parameters:
other- string to concatenate- Returns:
- a new
ByteSequenceinstance
-
concat
Concatenate the givenByteSequenceto this one.- Parameters:
other- string to concatenate- Returns:
- a new
ByteSequenceinstance
-
substring
Return the substring fromByteSequence, inclusive, to the end of the string.- Parameters:
beginIndex- start at this index- Returns:
- substring sharing underlying data
- Throws:
IndexOutOfBoundsException- ifbeginIndex < 0orbeginIndex > size().
-
substring
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:
IndexOutOfBoundsException- ifbeginIndex < 0,endIndex > size(), orbeginIndex > endIndex.
-
equals
-
hashCode
public int hashCode() -
toString
-
getBytes
public byte[] getBytes() -
isEmpty
public boolean isEmpty() -
size
public int size() -
toString
-
from
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
Create new ByteSequence from aByteString.- Parameters:
source- inputByteString- Returns:
- the ByteSequence
-
from
Create new ByteSequence from raw bytes.- Parameters:
source- input bytes- Returns:
- the ByteSequence
-