Package com.google.protobuf
Class TextFormatParseInfoTree
java.lang.Object
com.google.protobuf.TextFormatParseInfoTree
Data structure which is populated with the locations of each field value parsed from the text.
The locations of primary fields values are retrieved by getLocation
or
getLocations
. The locations of sub message values are within nested
TextFormatParseInfoTree
s and are retrieve by getNestedTree
or getNestedTrees
.
The TextFormatParseInfoTree
is created by a Builder.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) Map
<Descriptors.FieldDescriptor, List<TextFormatParseInfoTree>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
TextFormatParseInfoTree
(Map<Descriptors.FieldDescriptor, List<TextFormatParseLocation>> locationsFromField, Map<Descriptors.FieldDescriptor, List<TextFormatParseInfoTree.Builder>> subtreeBuildersFromField) Construct aTextFormatParseInfoTree
. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Create a builder for aParseInfoTree
.private static <T> T
getFromList
(List<T> list, int index, Descriptors.FieldDescriptor fieldDescriptor) getLocation
(Descriptors.FieldDescriptor fieldDescriptor, int index) Get the location in the source of a field's value.getLocations
(Descriptors.FieldDescriptor fieldDescriptor) Retrieve all the locations of a field.getNestedTree
(Descriptors.FieldDescriptor fieldDescriptor, int index) Returns the parse info tree for the given field, which must be a message type.getNestedTrees
(Descriptors.FieldDescriptor fieldDescriptor) Retrieve a list of all the location information trees for a sub message field.
-
Field Details
-
locationsFromField
-
subtreesFromField
Map<Descriptors.FieldDescriptor,List<TextFormatParseInfoTree>> subtreesFromField
-
-
Constructor Details
-
TextFormatParseInfoTree
private TextFormatParseInfoTree(Map<Descriptors.FieldDescriptor, List<TextFormatParseLocation>> locationsFromField, Map<Descriptors.FieldDescriptor, List<TextFormatParseInfoTree.Builder>> subtreeBuildersFromField) Construct aTextFormatParseInfoTree
.- Parameters:
locationsFromField
- a map of fields to location in the source codesubtreeBuildersFromField
- a map of fields to parse tree location information builders
-
-
Method Details
-
getLocations
Retrieve all the locations of a field.- Parameters:
fieldDescriptor
- theDescriptors.FieldDescriptor
of the desired field- Returns:
- a list of the locations of values of the field. If there are not values or the field doesn't exist, an empty list is returned.
-
getLocation
Get the location in the source of a field's value.Returns the
TextFormatParseLocation
for index-th value of the field in the parsed text.- Parameters:
fieldDescriptor
- theDescriptors.FieldDescriptor
of the desired fieldindex
- the index of the value.- Returns:
- the
TextFormatParseLocation
of the value - Throws:
IllegalArgumentException
- index is out of range
-
getNestedTrees
Retrieve a list of all the location information trees for a sub message field.- Parameters:
fieldDescriptor
- theDescriptors.FieldDescriptor
of the desired field- Returns:
- A list of
TextFormatParseInfoTree
-
getNestedTree
public TextFormatParseInfoTree getNestedTree(Descriptors.FieldDescriptor fieldDescriptor, int index) Returns the parse info tree for the given field, which must be a message type.- Parameters:
fieldDescriptor
- theDescriptors.FieldDescriptor
of the desired sub messageindex
- the index of message value.- Returns:
- the
ParseInfoTree
of the message value.null
is returned if the field doesn't exist or the index is out of range. - Throws:
IllegalArgumentException
- if index is out of range
-
builder
Create a builder for aParseInfoTree
.- Returns:
- the builder
-
getFromList
private static <T> T getFromList(List<T> list, int index, Descriptors.FieldDescriptor fieldDescriptor)
-