UnmodifiableLazyStringList.java
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 package com.google.protobuf;
32 
33 import java.util.AbstractList;
34 import java.util.Collection;
35 import java.util.Collections;
36 import java.util.Iterator;
37 import java.util.List;
38 import java.util.ListIterator;
39 import java.util.RandomAccess;
40 
47 public class UnmodifiableLazyStringList extends AbstractList<String>
48  implements LazyStringList, RandomAccess {
49 
50  private final LazyStringList list;
51 
53  this.list = list;
54  }
55 
56  @Override
57  public String get(int index) {
58  return list.get(index);
59  }
60 
61  @Override
62  public Object getRaw(int index) {
63  return list.getRaw(index);
64  }
65 
66  @Override
67  public int size() {
68  return list.size();
69  }
70 
71  @Override
73  return list.getByteString(index);
74  }
75 
76  @Override
77  public void add(ByteString element) {
78  throw new UnsupportedOperationException();
79  }
80 
81  @Override
82  public void set(int index, ByteString element) {
83  throw new UnsupportedOperationException();
84  }
85 
86  @Override
87  public boolean addAllByteString(Collection<? extends ByteString> element) {
88  throw new UnsupportedOperationException();
89  }
90 
91  @Override
92  public byte[] getByteArray(int index) {
93  return list.getByteArray(index);
94  }
95 
96  @Override
97  public void add(byte[] element) {
98  throw new UnsupportedOperationException();
99  }
100 
101  @Override
102  public void set(int index, byte[] element) {
103  throw new UnsupportedOperationException();
104  }
105 
106  @Override
107  public boolean addAllByteArray(Collection<byte[]> element) {
108  throw new UnsupportedOperationException();
109  }
110 
111  @Override
112  public ListIterator<String> listIterator(final int index) {
113  return new ListIterator<String>() {
114  ListIterator<String> iter = list.listIterator(index);
115 
116  @Override
117  public boolean hasNext() {
118  return iter.hasNext();
119  }
120 
121  @Override
122  public String next() {
123  return iter.next();
124  }
125 
126  @Override
127  public boolean hasPrevious() {
128  return iter.hasPrevious();
129  }
130 
131  @Override
132  public String previous() {
133  return iter.previous();
134  }
135 
136  @Override
137  public int nextIndex() {
138  return iter.nextIndex();
139  }
140 
141  @Override
142  public int previousIndex() {
143  return iter.previousIndex();
144  }
145 
146  @Override
147  public void remove() {
148  throw new UnsupportedOperationException();
149  }
150 
151  @Override
152  public void set(String o) {
153  throw new UnsupportedOperationException();
154  }
155 
156  @Override
157  public void add(String o) {
158  throw new UnsupportedOperationException();
159  }
160  };
161  }
162 
163  @Override
164  public Iterator<String> iterator() {
165  return new Iterator<String>() {
166  Iterator<String> iter = list.iterator();
167 
168  @Override
169  public boolean hasNext() {
170  return iter.hasNext();
171  }
172 
173  @Override
174  public String next() {
175  return iter.next();
176  }
177 
178  @Override
179  public void remove() {
180  throw new UnsupportedOperationException();
181  }
182  };
183  }
184 
185  @Override
186  public List<?> getUnderlyingElements() {
187  // The returned value is already unmodifiable.
188  return list.getUnderlyingElements();
189  }
190 
191  @Override
192  public void mergeFrom(LazyStringList other) {
193  throw new UnsupportedOperationException();
194  }
195 
196  @Override
197  public List<byte[]> asByteArrayList() {
198  return Collections.unmodifiableList(list.asByteArrayList());
199  }
200 
201  @Override
202  public List<ByteString> asByteStringList() {
203  return Collections.unmodifiableList(list.asByteStringList());
204  }
205 
206  @Override
208  return this;
209  }
210 }
com.google.protobuf.LazyStringList.asByteArrayList
List< byte[]> asByteArrayList()
com.google.protobuf.UnmodifiableLazyStringList.add
void add(byte[] element)
Definition: UnmodifiableLazyStringList.java:97
com.google.protobuf.LazyStringList
Definition: LazyStringList.java:46
com.google.protobuf.UnmodifiableLazyStringList.getRaw
Object getRaw(int index)
Definition: UnmodifiableLazyStringList.java:62
com.google.protobuf.UnmodifiableLazyStringList.list
final LazyStringList list
Definition: UnmodifiableLazyStringList.java:50
com.google.protobuf.UnmodifiableLazyStringList
Definition: UnmodifiableLazyStringList.java:47
generate_changelog.previous
previous
Definition: generate_changelog.py:55
com.google.protobuf.UnmodifiableLazyStringList.UnmodifiableLazyStringList
UnmodifiableLazyStringList(LazyStringList list)
Definition: UnmodifiableLazyStringList.java:52
com.google.protobuf.LazyStringList.getByteString
ByteString getByteString(int index)
com.google.protobuf.UnmodifiableLazyStringList.add
void add(ByteString element)
Definition: UnmodifiableLazyStringList.java:77
com.google.protobuf.UnmodifiableLazyStringList.addAllByteArray
boolean addAllByteArray(Collection< byte[]> element)
Definition: UnmodifiableLazyStringList.java:107
com.google.protobuf.LazyStringList.getByteArray
byte[] getByteArray(int index)
com.google.protobuf.UnmodifiableLazyStringList.size
int size()
Definition: UnmodifiableLazyStringList.java:67
com.google.protobuf.UnmodifiableLazyStringList.getByteArray
byte[] getByteArray(int index)
Definition: UnmodifiableLazyStringList.java:92
com.google.protobuf.UnmodifiableLazyStringList.addAllByteString
boolean addAllByteString(Collection<? extends ByteString > element)
Definition: UnmodifiableLazyStringList.java:87
com.google.protobuf.UnmodifiableLazyStringList.asByteArrayList
List< byte[]> asByteArrayList()
Definition: UnmodifiableLazyStringList.java:197
java
com.google.protobuf.UnmodifiableLazyStringList.asByteStringList
List< ByteString > asByteStringList()
Definition: UnmodifiableLazyStringList.java:202
com.google.protobuf.UnmodifiableLazyStringList.getByteString
ByteString getByteString(int index)
Definition: UnmodifiableLazyStringList.java:72
com.google.protobuf.UnmodifiableLazyStringList.listIterator
ListIterator< String > listIterator(final int index)
Definition: UnmodifiableLazyStringList.java:112
com.google.protobuf.UnmodifiableLazyStringList.getUnderlyingElements
List<?> getUnderlyingElements()
Definition: UnmodifiableLazyStringList.java:186
com.google.protobuf.UnmodifiableLazyStringList.getUnmodifiableView
LazyStringList getUnmodifiableView()
Definition: UnmodifiableLazyStringList.java:207
com.google.protobuf.UnmodifiableLazyStringList.iterator
Iterator< String > iterator()
Definition: UnmodifiableLazyStringList.java:164
com.google.protobuf.ProtocolStringList.asByteStringList
List< ByteString > asByteStringList()
next
static size_t next(const upb_table *t, size_t i)
Definition: php/ext/google/protobuf/upb.c:4889
com.google.protobuf.LazyStringList.getUnderlyingElements
List<?> getUnderlyingElements()
com.google.protobuf.UnmodifiableLazyStringList.mergeFrom
void mergeFrom(LazyStringList other)
Definition: UnmodifiableLazyStringList.java:192
com.google.protobuf.LazyStringList.getRaw
Object getRaw(int index)
index
GLuint index
Definition: glcorearb.h:3055
com.google.protobuf.ByteString
Definition: ByteString.java:67


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:00