Class TextFormatParseInfoTree


  • public class TextFormatParseInfoTree
    extends java.lang.Object
    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 TextFormatParseInfoTrees and are retrieve by getNestedTree or getNestedTrees.

    The TextFormatParseInfoTree is created by a Builder.

    • Method Detail

      • getLocations

        public java.util.List<TextFormatParseLocation> getLocations​(Descriptors.FieldDescriptor fieldDescriptor)
        Retrieve all the locations of a field.
        Parameters:
        fieldDescriptor - the @{link 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

        public TextFormatParseLocation getLocation​(Descriptors.FieldDescriptor fieldDescriptor,
                                                   int index)
        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 - the @{link FieldDescriptor} of the desired field
        index - the index of the value.
        Returns:
        the TextFormatParseLocation of the value
        Throws:
        java.lang.IllegalArgumentException - index is out of range
      • 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 - the @{link FieldDescriptor} of the desired sub message
        index - 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:
        java.lang.IllegalArgumentException - if index is out of range