public interface LazyStringList extends ProtocolStringList
An interface extending List<String>
that also provides access to the items of the list as
UTF8-encoded ByteString or byte[] objects. This is used by the protocol buffer implementation to
support lazily converting bytes parsed over the wire to String objects until needed and also
increases the efficiency of serialization if the String was never requested as the ByteString or
byte[] is already cached. The ByteString methods are used in immutable API only and byte[]
methods used in mutable API only for they use different representations for string/bytes fields.
Implements
ProtocolStringListMethods
add(byte[] element)
public abstract void add(byte[] element)
Appends the specified element to the end of this list (optional operation).
Parameter | |
---|---|
Name | Description |
element |
byte[] element to be appended to this list |
add(ByteString element)
public abstract void add(ByteString element)
Appends the specified element to the end of this list (optional operation).
Parameter | |
---|---|
Name | Description |
element |
ByteString element to be appended to this list |
addAllByteArray(Collection<byte[]> c)
public abstract boolean addAllByteArray(Collection<byte[]> c)
Appends all elements in the specified byte[] collection to the end of this list.
Parameter | |
---|---|
Name | Description |
c |
Collection<byte[]> collection whose elements are to be added to this list |
Returns | |
---|---|
Type | Description |
boolean |
true if this list changed as a result of the call |
addAllByteString(Collection<? extends ByteString> c)
public abstract boolean addAllByteString(Collection<? extends ByteString> c)
Appends all elements in the specified ByteString collection to the end of this list.
Parameter | |
---|---|
Name | Description |
c |
Collection<? extends com.google.protobuf.ByteString> collection whose elements are to be added to this list |
Returns | |
---|---|
Type | Description |
boolean |
true if this list changed as a result of the call |
asByteArrayList()
public abstract List<byte[]> asByteArrayList()
Returns a mutable view of this list. Changes to the view will be made into the original list. This method is used in mutable API only.
Returns | |
---|---|
Type | Description |
List<byte[]> |
getByteArray(int index)
public abstract byte[] getByteArray(int index)
Returns the element at the specified position in this list as byte[].
Parameter | |
---|---|
Name | Description |
index |
int index of the element to return |
Returns | |
---|---|
Type | Description |
byte[] |
the element at the specified position in this list |
getByteString(int index)
public abstract ByteString getByteString(int index)
Returns the element at the specified position in this list as a ByteString.
Parameter | |
---|---|
Name | Description |
index |
int index of the element to return |
Returns | |
---|---|
Type | Description |
ByteString |
the element at the specified position in this list |
getRaw(int index)
public abstract Object getRaw(int index)
Returns the element at the specified position in this list as an Object that will either be a String or a ByteString.
Parameter | |
---|---|
Name | Description |
index |
int index of the element to return |
Returns | |
---|---|
Type | Description |
Object |
the element at the specified position in this list |
getUnderlyingElements()
public abstract List<?> getUnderlyingElements()
Returns an unmodifiable List of the underlying elements, each of which is either a
String
or its equivalent UTF-8 encoded ByteString
or byte[]. It is an error for the
caller to modify the returned List, and attempting to do so will result in an UnsupportedOperationException.
Returns | |
---|---|
Type | Description |
List<?> |
getUnmodifiableView()
public abstract LazyStringList getUnmodifiableView()
Returns an unmodifiable view of the list.
Returns | |
---|---|
Type | Description |
LazyStringList |
mergeFrom(LazyStringList other)
public abstract void mergeFrom(LazyStringList other)
Merges all elements from another LazyStringList into this one. This method differs from #addAll(Collection) on that underlying byte arrays are copied instead of reference shared. Immutable API doesn't need to use this method as byte[] is not used there at all.
Parameter | |
---|---|
Name | Description |
other |
LazyStringList |
set(int index, byte[] element)
public abstract void set(int index, byte[] element)
Replaces the element at the specified position in this list with the specified element (optional operation).
Parameters | |
---|---|
Name | Description |
index |
int index of the element to replace |
element |
byte[] the element to be stored at the specified position |
set(int index, ByteString element)
public abstract void set(int index, ByteString element)
Replaces the element at the specified position in this list with the specified element (optional operation).
Parameters | |
---|---|
Name | Description |
index |
int index of the element to replace |
element |
ByteString the element to be stored at the specified position |