31 package com.google.protobuf;
34 import java.util.ArrayList;
35 import java.util.Collections;
36 import java.util.HashMap;
37 import java.util.List;
39 import java.util.Map.Entry;
58 Map<FieldDescriptor, List<TextFormatParseInfoTree>> subtreesFromField;
68 Map<
FieldDescriptor, List<TextFormatParseInfoTree.Builder>> subtreeBuildersFromField) {
71 Map<FieldDescriptor, List<TextFormatParseLocation>> locs =
72 new HashMap<FieldDescriptor, List<TextFormatParseLocation>>();
74 locs.put(kv.getKey(), Collections.unmodifiableList(kv.getValue()));
76 this.locationsFromField = Collections.unmodifiableMap(locs);
78 Map<FieldDescriptor, List<TextFormatParseInfoTree>> subs =
79 new HashMap<FieldDescriptor, List<TextFormatParseInfoTree>>();
80 for (Entry<
FieldDescriptor, List<Builder>> kv : subtreeBuildersFromField.entrySet()) {
81 List<TextFormatParseInfoTree> submessagesOfField =
new ArrayList<TextFormatParseInfoTree>();
82 for (
Builder subBuilder : kv.getValue()) {
83 submessagesOfField.add(subBuilder.build());
85 subs.put(kv.getKey(), Collections.unmodifiableList(submessagesOfField));
87 this.subtreesFromField = Collections.unmodifiableMap(subs);
124 List<TextFormatParseInfoTree> result = subtreesFromField.get(fieldDescriptor);
152 throw new IllegalArgumentException(
154 "Illegal index field: %s, index %d",
155 fieldDescriptor ==
null ?
"<null>" : fieldDescriptor.
getName(),
index));
157 return list.get(
index);
183 List<TextFormatParseLocation> fieldLocations =
locationsFromField.get(fieldDescriptor);
184 if (fieldLocations ==
null) {
185 fieldLocations =
new ArrayList<TextFormatParseLocation>();
203 if (submessageBuilders ==
null) {
204 submessageBuilders =
new ArrayList<Builder>();
208 submessageBuilders.add(subtreeBuilder);
209 return subtreeBuilder;