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 aByteStringover 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 intbytesLengthprivate intbytesOffsetprivate static longserialVersionUID-
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 aBoundedByteStringbacked by the sub-range of given array, without copying.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description bytebyteAt(int index)Gets the byte at the given index.protected voidcopyToInternal(byte[] target, int sourceOffset, int targetOffset, int numberToCopy)Internal (package private) implementation ofByteString.copyTo(byte[],int,int,int).protected intgetOffsetIntoBytes()Offset intobytes[]to use, non-zero for substrings.(package private) byteinternalByteAt(int index)Gets the byte at the given index, assumes bounds checking has already been performed.private voidreadObject(java.io.ObjectInputStream in)intsize()Gets the number of bytes.(package private) java.lang.ObjectwriteReplace()-
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, empty, endsWith, fromHex, hashCode, isEmpty, iterator, newCodedBuilder, newOutput, newOutput, nioByteString, 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 aBoundedByteStringbacked 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. ThrowsArrayIndexOutOfBoundsExceptionfor backwards-compatibility reasons although it would more properly beIndexOutOfBoundsException.- Overrides:
byteAtin classByteString.LiteralByteString- Parameters:
index- index of byte- Returns:
- the value
- Throws:
java.lang.ArrayIndexOutOfBoundsException-indexis < 0 or >= size
-
internalByteAt
byte internalByteAt(int index)
Description copied from class:ByteStringGets the byte at the given index, assumes bounds checking has already been performed.- Overrides:
internalByteAtin classByteString.LiteralByteString- Parameters:
index- index of byte- Returns:
- the value
-
size
public int size()
Description copied from class:ByteStringGets the number of bytes.- Overrides:
sizein classByteString.LiteralByteString- Returns:
- size in bytes
-
getOffsetIntoBytes
protected int getOffsetIntoBytes()
Description copied from class:ByteString.LiteralByteStringOffset intobytes[]to use, non-zero for substrings.- Overrides:
getOffsetIntoBytesin classByteString.LiteralByteString- Returns:
- always 0 for this class
-
copyToInternal
protected void copyToInternal(byte[] target, int sourceOffset, int targetOffset, int numberToCopy)Description copied from class:ByteStringInternal (package private) implementation ofByteString.copyTo(byte[],int,int,int). It assumes that all error checking has already been performed and thatnumberToCopy > 0.- Overrides:
copyToInternalin classByteString.LiteralByteString
-
writeReplace
java.lang.Object writeReplace()
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException- Throws:
java.io.IOException
-
-