Package com.google.protobuf
Class ByteString.BoundedByteString
- java.lang.Object
-
- com.google.protobuf.ByteString
-
- com.google.protobuf.ByteString.LeafByteString
-
- com.google.protobuf.ByteString.LiteralByteString
-
- com.google.protobuf.ByteString.BoundedByteString
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<java.lang.Byte>
- Enclosing class:
- ByteString
private static final class ByteString.BoundedByteString extends ByteString.LiteralByteString
This class is used to represent the substring of aByteString
over a single byte array. In terms of the public API ofByteString
, you end up here by callingByteString.copyFrom(byte[])
followed byByteString.substring(int, int)
.This class contains most of the overhead involved in creating a substring from a
ByteString.LiteralByteString
. The overhead involves some range-checking and two extra fields.
-
-
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 Modifier and Type Field Description private int
bytesLength
private int
bytesOffset
private static long
serialVersionUID
-
Fields inherited from class com.google.protobuf.ByteString.LiteralByteString
bytes
-
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 BoundedByteString(byte[] bytes, int offset, int length)
Creates aBoundedByteString
backed by the sub-range of given array, without copying.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
byteAt(int index)
Gets the byte at the given index.protected void
copyToInternal(byte[] target, int sourceOffset, int targetOffset, int numberToCopy)
Internal (package private) implementation ofByteString.copyTo(byte[],int,int,int)
.protected int
getOffsetIntoBytes()
Offset intobytes[]
to use, non-zero for substrings.(package private) byte
internalByteAt(int index)
Gets the byte at the given index, assumes bounds checking has already been performed.private void
readObject(java.io.ObjectInputStream in)
int
size()
Gets the number of bytes.(package private) java.lang.Object
writeReplace()
-
Methods inherited from class com.google.protobuf.ByteString.LiteralByteString
asReadOnlyByteBuffer, asReadOnlyByteBufferList, copyTo, equals, equalsRange, isValidUtf8, newCodedInput, newInput, partialHash, partialIsValidUtf8, substring, toStringInternal, writeTo, writeTo, writeToInternal
-
Methods inherited from class com.google.protobuf.ByteString.LeafByteString
getTreeDepth, isBalanced, writeToReverse
-
Methods inherited from class com.google.protobuf.ByteString
checkIndex, checkRange, concat, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFromUtf8, copyTo, copyTo, endsWith, hashCode, isEmpty, iterator, newCodedBuilder, newOutput, newOutput, peekCachedHashCode, readFrom, readFrom, readFrom, startsWith, substring, toByteArray, toString, toString, toString, toStringUtf8, unsignedLexicographicalComparator, wrap, wrap, wrap, writeTo
-
-
-
-
Field Detail
-
bytesOffset
private final int bytesOffset
-
bytesLength
private final int bytesLength
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BoundedByteString
BoundedByteString(byte[] bytes, int offset, int length)
Creates aBoundedByteString
backed by the sub-range of given array, without copying.- Parameters:
bytes
- array to wrapoffset
- index to first byte to use in byteslength
- number of bytes to use from bytes- Throws:
java.lang.IllegalArgumentException
- ifoffset < 0
,length < 0
, or ifoffset + length > bytes.length
.
-
-
Method Detail
-
byteAt
public byte byteAt(int index)
Gets the byte at the given index. ThrowsArrayIndexOutOfBoundsException
for backwards-compatibility reasons although it would more properly beIndexOutOfBoundsException
.- Overrides:
byteAt
in classByteString.LiteralByteString
- Parameters:
index
- index of byte- Returns:
- the value
- Throws:
java.lang.ArrayIndexOutOfBoundsException
-index
is < 0 or >= size
-
internalByteAt
byte internalByteAt(int index)
Description copied from class:ByteString
Gets the byte at the given index, assumes bounds checking has already been performed.- Overrides:
internalByteAt
in classByteString.LiteralByteString
- Parameters:
index
- index of byte- Returns:
- the value
-
size
public int size()
Description copied from class:ByteString
Gets the number of bytes.- Overrides:
size
in classByteString.LiteralByteString
- Returns:
- size in bytes
-
getOffsetIntoBytes
protected int getOffsetIntoBytes()
Description copied from class:ByteString.LiteralByteString
Offset intobytes[]
to use, non-zero for substrings.- Overrides:
getOffsetIntoBytes
in classByteString.LiteralByteString
- Returns:
- always 0 for this class
-
copyToInternal
protected void copyToInternal(byte[] target, int sourceOffset, int targetOffset, int numberToCopy)
Description copied from class:ByteString
Internal (package private) implementation ofByteString.copyTo(byte[],int,int,int)
. It assumes that all error checking has already been performed and thatnumberToCopy > 0
.- Overrides:
copyToInternal
in classByteString.LiteralByteString
-
writeReplace
java.lang.Object writeReplace()
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
-