Class JsonFormat.PrinterImpl

  • Enclosing class:
    JsonFormat

    private static final class JsonFormat.PrinterImpl
    extends java.lang.Object
    A Printer converts protobuf messages to the proto3 JSON format.
    • Field Detail

      • alwaysOutputDefaultValueFields

        private final boolean alwaysOutputDefaultValueFields
      • preservingProtoFieldNames

        private final boolean preservingProtoFieldNames
      • printingEnumsAsInts

        private final boolean printingEnumsAsInts
      • sortingMapKeys

        private final boolean sortingMapKeys
      • gson

        private final com.google.gson.Gson gson
      • blankOrSpace

        private final java.lang.CharSequence blankOrSpace
      • blankOrNewLine

        private final java.lang.CharSequence blankOrNewLine
    • Constructor Detail

      • PrinterImpl

        PrinterImpl​(TypeRegistry registry,
                    JsonFormat.TypeRegistry oldRegistry,
                    boolean alwaysOutputDefaultValueFields,
                    java.util.Set<Descriptors.FieldDescriptor> includingDefaultValueFields,
                    boolean preservingProtoFieldNames,
                    java.lang.Appendable jsonOutput,
                    boolean omittingInsignificantWhitespace,
                    boolean printingEnumsAsInts,
                    boolean sortingMapKeys)
    • Method Detail

      • print

        void print​(MessageOrBuilder message)
            throws java.io.IOException
        Throws:
        java.io.IOException
      • printAny

        private void printAny​(MessageOrBuilder message)
                       throws java.io.IOException
        Prints google.protobuf.Any
        Throws:
        java.io.IOException
      • printWrapper

        private void printWrapper​(MessageOrBuilder message)
                           throws java.io.IOException
        Prints wrapper types (e.g., google.protobuf.Int32Value)
        Throws:
        java.io.IOException
      • printTimestamp

        private void printTimestamp​(MessageOrBuilder message)
                             throws java.io.IOException
        Prints google.protobuf.Timestamp
        Throws:
        java.io.IOException
      • printDuration

        private void printDuration​(MessageOrBuilder message)
                            throws java.io.IOException
        Prints google.protobuf.Duration
        Throws:
        java.io.IOException
      • printFieldMask

        private void printFieldMask​(MessageOrBuilder message)
                             throws java.io.IOException
        Prints google.protobuf.FieldMask
        Throws:
        java.io.IOException
      • printStruct

        private void printStruct​(MessageOrBuilder message)
                          throws java.io.IOException
        Prints google.protobuf.Struct
        Throws:
        java.io.IOException
      • printValue

        private void printValue​(MessageOrBuilder message)
                         throws java.io.IOException
        Prints google.protobuf.Value
        Throws:
        java.io.IOException
      • printListValue

        private void printListValue​(MessageOrBuilder message)
                             throws java.io.IOException
        Prints google.protobuf.ListValue
        Throws:
        java.io.IOException
      • print

        private void print​(MessageOrBuilder message,
                           @Nullable
                           java.lang.String typeUrl)
                    throws java.io.IOException
        Prints a regular message with an optional type URL.
        Throws:
        java.io.IOException
      • printField

        private void printField​(Descriptors.FieldDescriptor field,
                                java.lang.Object value)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • printRepeatedFieldValue

        private void printRepeatedFieldValue​(Descriptors.FieldDescriptor field,
                                             java.lang.Object value)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • printMapFieldValue

        private void printMapFieldValue​(Descriptors.FieldDescriptor field,
                                        java.lang.Object value)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • printSingleFieldValue

        private void printSingleFieldValue​(Descriptors.FieldDescriptor field,
                                           java.lang.Object value)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • printSingleFieldValue

        private void printSingleFieldValue​(Descriptors.FieldDescriptor field,
                                           java.lang.Object value,
                                           boolean alwaysWithQuotes)
                                    throws java.io.IOException
        Prints a field's value in the proto3 JSON format.
        Parameters:
        alwaysWithQuotes - whether to always add double-quotes to primitive types
        Throws:
        java.io.IOException