Package com.google.protobuf
Class ByteString.LeafByteString
- java.lang.Object
-
- com.google.protobuf.ByteString
-
- com.google.protobuf.ByteString.LeafByteString
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<java.lang.Byte>
- Direct Known Subclasses:
ByteString.LiteralByteString
,NioByteString
- Enclosing class:
- ByteString
abstract static class ByteString.LeafByteString extends ByteString
Base class for leafByteString
s (i.e. non-ropes).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.protobuf.ByteString
ByteString.AbstractByteIterator, ByteString.ByteIterator, ByteString.CodedBuilder, ByteString.LeafByteString, ByteString.Output
-
-
Field Summary
-
Fields inherited from class com.google.protobuf.ByteString
CONCATENATE_BY_COPY_SIZE, EMPTY, MAX_READ_FROM_CHUNK_SIZE, MIN_READ_FROM_CHUNK_SIZE
-
-
Constructor Summary
Constructors Constructor Description LeafByteString()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract boolean
equalsRange(ByteString other, int offset, int length)
Check equality of the substring of given length of this object starting at zero with anotherByteString
substring starting at offset.protected int
getTreeDepth()
Return the depth of the tree representing thisByteString
, if any, whose root is this node.protected boolean
isBalanced()
Returntrue
if this ByteString is literal (a leaf node) or a flat-enough tree in the sense ofRopeByteString
.(package private) void
writeToReverse(ByteOutput byteOutput)
This method behaves exactly the same asByteString.writeTo(ByteOutput)
unless theByteString
is a rope.-
Methods inherited from class com.google.protobuf.ByteString
asReadOnlyByteBuffer, asReadOnlyByteBufferList, byteAt, checkIndex, checkRange, concat, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFromUtf8, copyTo, copyTo, copyTo, copyToInternal, endsWith, equals, hashCode, internalByteAt, isEmpty, isValidUtf8, iterator, newCodedBuilder, newCodedInput, newInput, newOutput, newOutput, partialHash, partialIsValidUtf8, peekCachedHashCode, readFrom, readFrom, readFrom, size, startsWith, substring, substring, toByteArray, toString, toString, toString, toStringInternal, toStringUtf8, unsignedLexicographicalComparator, wrap, wrap, wrap, writeTo, writeTo, writeTo, writeToInternal
-
-
-
-
Method Detail
-
getTreeDepth
protected final int getTreeDepth()
Description copied from class:ByteString
Return the depth of the tree representing thisByteString
, if any, whose root is this node. If this is a leaf node, return 0.- Specified by:
getTreeDepth
in classByteString
- Returns:
- tree depth or zero
-
isBalanced
protected final boolean isBalanced()
Description copied from class:ByteString
Returntrue
if this ByteString is literal (a leaf node) or a flat-enough tree in the sense ofRopeByteString
.- Specified by:
isBalanced
in classByteString
- Returns:
- true if the tree is flat enough
-
writeToReverse
void writeToReverse(ByteOutput byteOutput) throws java.io.IOException
Description copied from class:ByteString
This method behaves exactly the same asByteString.writeTo(ByteOutput)
unless theByteString
is a rope. For ropes, the leaf nodes are written in reverse order to thebyteOutput
.- Specified by:
writeToReverse
in classByteString
- Parameters:
byteOutput
- the output target to receive the bytes- Throws:
java.io.IOException
- if an I/O error occurs- See Also:
UnsafeByteOperations#unsafeWriteToReverse(ByteString, ByteOutput)
-
equalsRange
abstract boolean equalsRange(ByteString other, int offset, int length)
Check equality of the substring of given length of this object starting at zero with anotherByteString
substring starting at offset.- Parameters:
other
- what to compare a substring inoffset
- offset into otherlength
- number of bytes to compare- Returns:
- true for equality of substrings, else false.
-
-