Top Description Methods
com.google.protobuf

public Interface LazyStringList

extends ProtocolStringList
Known Direct Implementers
com.google.protobuf.UnmodifiableLazyStringList, com.google.protobuf.LazyStringArrayList
Imports
java.util.Collection, .List

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.
Author
[email protected] (Jon Perlow)

Method Summary

Modifier and TypeMethod and Description
public void
add(ByteString
element to be appended to this list
element
)

Redeclares java.util.List.add.

Appends the specified element to the end of this list (optional operation).
public void
add(byte[]
element to be appended to this list
element
)

Redeclares java.util.List.add.

Appends the specified element to the end of this list (optional operation).
public boolean

Returns:

true if this list changed as a result of the call
addAllByteArray
(Collection<byte[]>
collection whose elements are to be added to this list
c
)

Appends all elements in the specified byte[] collection to the end of this list.

public boolean

Returns:

true if this list changed as a result of the call
addAllByteString
(Collection<? extends ByteString>
collection whose elements are to be added to this list
c
)

Appends all elements in the specified ByteString collection to the end of this list.

public List<byte[]>
asByteArrayList()

Returns a mutable view of this list.

public byte[]

Returns:

the element at the specified position in this list
getByteArray
(int
index of the element to return
index
)

Returns the element at the specified position in this list as byte[].

public ByteString

Returns:

the element at the specified position in this list
getByteString
(int
index of the element to return
index
)

Returns the element at the specified position in this list as a ByteString.

public Object

Returns:

the element at the specified position in this list
getRaw
(int
index of the element to return
index
)

Returns the element at the specified position in this list as an Object that will either be a String or a ByteString.

public 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[].

public LazyStringList
getUnmodifiableView()

Returns an unmodifiable view of the list.

public void
mergeFrom(LazyStringList other)

Merges all elements from another LazyStringList into this one.

public void
set(int
index of the element to replace
index
,
ByteString
the element to be stored at the specified position
element
)

Redeclares java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).
public void
set(int
index of the element to replace
index
,
byte[]
the element to be stored at the specified position
element
)

Redeclares java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).
Inherited from com.google.protobuf.ProtocolStringList:
asByteStringList

Method Detail

addback to summary
public void add(ByteString element)

Redeclares java.util.List.add.

Appends the specified element to the end of this list (optional operation).

Parameters
element:ByteString

element to be appended to this list

Returns:void

Doc from java.util.List.add.

true (as specified by Collection#add)

Exceptions
UnsupportedOperationException:
if the add operation is not supported by this list
addback to summary
public void add(byte[] element)

Redeclares java.util.List.add.

Appends the specified element to the end of this list (optional operation).

Parameters
element:byte[]

element to be appended to this list

Returns:void

Doc from java.util.List.add.

true (as specified by Collection#add)

Exceptions
UnsupportedOperationException:
if the add operation is not supported by this list
addAllByteArrayback to summary
public boolean addAllByteArray(Collection<byte[]> c)

Appends all elements in the specified byte[] collection to the end of this list.

Parameters
c:Collection<byte[]>

collection whose elements are to be added to this list

Returns:boolean

true if this list changed as a result of the call

Exceptions
UnsupportedOperationException:
if the addAllByteArray operation is not supported by this list
addAllByteStringback to summary
public boolean addAllByteString(Collection<? extends ByteString> c)

Appends all elements in the specified ByteString collection to the end of this list.

Parameters
c:Collection<? extends ByteString>

collection whose elements are to be added to this list

Returns:boolean

true if this list changed as a result of the call

Exceptions
UnsupportedOperationException:
if the addAllByteString operation is not supported by this list
asByteArrayListback to summary
public 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.

getByteArrayback to summary
public byte[] getByteArray(int index)

Returns the element at the specified position in this list as byte[].

Parameters
index:int

index of the element to return

Returns:byte[]

the element at the specified position in this list

Exceptions
IndexOutOfBoundsException:
if the index is out of range (index < 0 || index >= size())
getByteStringback to summary
public ByteString getByteString(int index)

Returns the element at the specified position in this list as a ByteString.

Parameters
index:int

index of the element to return

Returns:ByteString

the element at the specified position in this list

Exceptions
IndexOutOfBoundsException:
if the index is out of range (index < 0 || index >= size())
getRawback to summary
public 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.

Parameters
index:int

index of the element to return

Returns:Object

the element at the specified position in this list

Exceptions
IndexOutOfBoundsException:
if the index is out of range (index < 0 || index >= size())
getUnderlyingElementsback to summary
public 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.

getUnmodifiableViewback to summary
public LazyStringList getUnmodifiableView()

Returns an unmodifiable view of the list.

mergeFromback to summary
public 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.

setback to summary
public void set(int index, ByteString element)

Redeclares java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

Parameters
index:int

index of the element to replace

element:ByteString

the element to be stored at the specified position

Returns:void

Doc from java.util.List.set.

the element previously at the specified position

Exceptions
UnsupportedOperationException:
if the set operation is not supported by this list IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
setback to summary
public void set(int index, byte[] element)

Redeclares java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

Parameters
index:int

index of the element to replace

element:byte[]

the element to be stored at the specified position

Returns:void

Doc from java.util.List.set.

the element previously at the specified position

Exceptions
UnsupportedOperationException:
if the set operation is not supported by this list IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())