Classes | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
com.google.protobuf.TextFormat Class Reference

Classes

class  InvalidEscapeSequenceException
 
class  ParseException
 
class  Parser
 
class  Printer
 
class  TextGenerator
 
class  Tokenizer
 
class  UnknownFieldParseException
 

Static Public Member Functions

static String escapeBytes (byte[] input)
 
static String escapeBytes (ByteString input)
 
static String escapeDoubleQuotesAndBackslashes (final String input)
 
static Parser getParser ()
 
static void merge (final CharSequence input, final ExtensionRegistry extensionRegistry, final Message.Builder builder) throws ParseException
 
static void merge (final CharSequence input, final Message.Builder builder) throws ParseException
 
static void merge (final Readable input, final ExtensionRegistry extensionRegistry, final Message.Builder builder) throws IOException
 
static void merge (final Readable input, final Message.Builder builder) throws IOException
 
static< T extends Message > T parse (final CharSequence input, final Class< T > protoClass) throws ParseException
 
static< T extends Message > T parse (final CharSequence input, final ExtensionRegistry extensionRegistry, final Class< T > protoClass) throws ParseException
 
static void print (final MessageOrBuilder message, final Appendable output) throws IOException
 
static void print (final UnknownFieldSet fields, final Appendable output) throws IOException
 
static Printer printer ()
 
static void printField (final FieldDescriptor field, final Object value, final Appendable output) throws IOException
 
static String printFieldToString (final FieldDescriptor field, final Object value)
 
static void printFieldValue (final FieldDescriptor field, final Object value, final Appendable output) throws IOException
 
static String printToString (final MessageOrBuilder message)
 
static String printToString (final UnknownFieldSet fields)
 
static String printToUnicodeString (final MessageOrBuilder message)
 
static String printToUnicodeString (final UnknownFieldSet fields)
 
static void printUnicode (final MessageOrBuilder message, final Appendable output) throws IOException
 
static void printUnicode (final UnknownFieldSet fields, final Appendable output) throws IOException
 
static void printUnicodeFieldValue (final FieldDescriptor field, final Object value, final Appendable output) throws IOException
 
static void printUnknownFieldValue (final int tag, final Object value, final Appendable output) throws IOException
 
static String shortDebugString (final FieldDescriptor field, final Object value)
 
static String shortDebugString (final MessageOrBuilder message)
 
static String shortDebugString (final UnknownFieldSet fields)
 
static ByteString unescapeBytes (final CharSequence charString) throws InvalidEscapeSequenceException
 
static String unsignedToString (final int value)
 
static String unsignedToString (final long value)
 

Private Member Functions

 TextFormat ()
 

Static Private Member Functions

static int digitValue (final byte c)
 
static boolean isHex (final byte c)
 
static boolean isOctal (final byte c)
 
static TextGenerator multiLineOutput (Appendable output)
 
static long parseInteger (final String text, final boolean isSigned, final boolean isLong) throws NumberFormatException
 
static void printUnknownFieldValue (final int tag, final Object value, final TextGenerator generator) throws IOException
 
static TextGenerator singleLineOutput (Appendable output)
 

Static Private Attributes

static final Logger logger = Logger.getLogger(TextFormat.class.getName())
 
static final Parser PARSER = Parser.newBuilder().build()
 

Detailed Description

Provide text parsing and formatting support for proto2 instances. The implementation largely follows google/protobuf/text_format.cc.

Author
wenbo.nosp@m.z@go.nosp@m.ogle..nosp@m.com Wenbo Zhu
kento.nosp@m.n@go.nosp@m.ogle..nosp@m.com Kenton Varda

Definition at line 55 of file TextFormat.java.

Constructor & Destructor Documentation

◆ TextFormat()

com.google.protobuf.TextFormat.TextFormat ( )
inlineprivate

Definition at line 56 of file TextFormat.java.

Member Function Documentation

◆ digitValue()

static int com.google.protobuf.TextFormat.digitValue ( final byte  c)
inlinestaticprivate

Interpret a character as a digit (in any base up to 36) and return the numeric value. This is like

Character.digit()

but we don't accept non-ASCII digits.

Definition at line 2192 of file TextFormat.java.

◆ escapeBytes() [1/2]

static String com.google.protobuf.TextFormat.escapeBytes ( byte[]  input)
inlinestatic

Like escapeBytes(ByteString), but used for byte array.

Definition at line 2035 of file TextFormat.java.

◆ escapeBytes() [2/2]

static String com.google.protobuf.TextFormat.escapeBytes ( ByteString  input)
inlinestatic

Escapes bytes in the format used in protocol buffer text format, which is the same as the format used for C string literals. All bytes that are not printable 7-bit ASCII characters are escaped, as well as backslash, single-quote, and double-quote characters. Characters for which no defined short-hand escape sequence is defined will be escaped using 3-digit octal sequences.

Definition at line 2030 of file TextFormat.java.

◆ escapeDoubleQuotesAndBackslashes()

static String com.google.protobuf.TextFormat.escapeDoubleQuotesAndBackslashes ( final String  input)
inlinestatic

Escape double quotes and backslashes in a String for emittingUnicode output of a message.

Definition at line 2166 of file TextFormat.java.

◆ getParser()

static Parser com.google.protobuf.TextFormat.getParser ( )
inlinestatic

Return a Parser instance which can parse text-format messages. The returned instance is thread-safe.

Definition at line 1283 of file TextFormat.java.

◆ isHex()

static boolean com.google.protobuf.TextFormat.isHex ( final byte  c)
inlinestaticprivate

Is this a hex digit?

Definition at line 2184 of file TextFormat.java.

◆ isOctal()

static boolean com.google.protobuf.TextFormat.isOctal ( final byte  c)
inlinestaticprivate

Is this an octal digit?

Definition at line 2179 of file TextFormat.java.

◆ merge() [1/4]

static void com.google.protobuf.TextFormat.merge ( final CharSequence  input,
final ExtensionRegistry  extensionRegistry,
final Message.Builder  builder 
) throws ParseException
inlinestatic

Parse a text-format message from

and merge the contents into

builder

. Extensions will be recognized if they are registered in

extensionRegistry

.

Definition at line 1329 of file TextFormat.java.

◆ merge() [2/4]

static void com.google.protobuf.TextFormat.merge ( final CharSequence  input,
final Message.Builder  builder 
) throws ParseException
inlinestatic

Parse a text-format message from

and merge the contents into

builder

.

Definition at line 1293 of file TextFormat.java.

◆ merge() [3/4]

static void com.google.protobuf.TextFormat.merge ( final Readable  input,
final ExtensionRegistry  extensionRegistry,
final Message.Builder  builder 
) throws IOException
inlinestatic

Parse a text-format message from

and merge the contents into

builder

. Extensions will be recognized if they are registered in

extensionRegistry

.

Definition at line 1316 of file TextFormat.java.

◆ merge() [4/4]

static void com.google.protobuf.TextFormat.merge ( final Readable  input,
final Message.Builder  builder 
) throws IOException
inlinestatic

Parse a text-format message from

and merge the contents into

builder

.

Definition at line 1288 of file TextFormat.java.

◆ multiLineOutput()

static TextGenerator com.google.protobuf.TextFormat.multiLineOutput ( Appendable  output)
inlinestaticprivate

Definition at line 648 of file TextFormat.java.

◆ parse() [1/2]

static <T extends Message> T com.google.protobuf.TextFormat.parse ( final CharSequence  input,
final Class< T protoClass 
) throws ParseException
inlinestatic

Parse a text-format message from

.

Returns
the parsed message, guaranteed initialized

Definition at line 1303 of file TextFormat.java.

◆ parse() [2/2]

static <T extends Message> T com.google.protobuf.TextFormat.parse ( final CharSequence  input,
final ExtensionRegistry  extensionRegistry,
final Class< T protoClass 
) throws ParseException
inlinestatic

Parse a text-format message from

. Extensions will be recognized if they are registered in

extensionRegistry

.

Returns
the parsed message, guaranteed initialized

Definition at line 1343 of file TextFormat.java.

◆ parseInteger()

static long com.google.protobuf.TextFormat.parseInteger ( final String  text,
final boolean  isSigned,
final boolean  isLong 
) throws NumberFormatException
inlinestaticprivate

Definition at line 2240 of file TextFormat.java.

◆ print() [1/2]

static void com.google.protobuf.TextFormat.print ( final MessageOrBuilder  message,
final Appendable  output 
) throws IOException
inlinestatic

Outputs a textual representation of the Protocol Message supplied into the parameter output. (This representation is the new version of the classic "ProtocolPrinter" output from the original Protocol Buffer system)

Deprecated:
Use
printer().print(MessageOrBuilder, Appendable)

Definition at line 68 of file TextFormat.java.

◆ print() [2/2]

static void com.google.protobuf.TextFormat.print ( final UnknownFieldSet  fields,
final Appendable  output 
) throws IOException
inlinestatic

Outputs a textual representation of

to

.

Deprecated:
Use
printer().print(UnknownFieldSet, Appendable)

Definition at line 79 of file TextFormat.java.

◆ printer()

static Printer com.google.protobuf.TextFormat.printer ( )
inlinestatic

Printer instance which escapes non-ASCII characters.

Definition at line 280 of file TextFormat.java.

◆ printField()

static void com.google.protobuf.TextFormat.printField ( final FieldDescriptor  field,
final Object  value,
final Appendable  output 
) throws IOException
inlinestatic
Deprecated:
Use
printer().printField(FieldDescriptor, Object, Appendable)


Definition at line 181 of file TextFormat.java.

◆ printFieldToString()

static String com.google.protobuf.TextFormat.printFieldToString ( final FieldDescriptor  field,
final Object  value 
)
inlinestatic
Deprecated:
Use


Definition at line 188 of file TextFormat.java.

◆ printFieldValue()

static void com.google.protobuf.TextFormat.printFieldValue ( final FieldDescriptor  field,
final Object  value,
final Appendable  output 
) throws IOException
inlinestatic

Outputs a textual representation of the value of given field value.

Deprecated:
Use
printer().printFieldValue(FieldDescriptor, Object, Appendable)
Parameters
fieldthe descriptor of the field
valuethe value of the field
outputthe output to which to append the formatted value
Exceptions
ClassCastExceptionif the value is not appropriate for the given field descriptor
IOExceptionif there is an exception writing to the output

Definition at line 223 of file TextFormat.java.

◆ printToString() [1/2]

static String com.google.protobuf.TextFormat.printToString ( final MessageOrBuilder  message)
inlinestatic

Like

, but writes directly to a

String

and returns it.

Deprecated:
Use MessageOrBuilder#toString()

Definition at line 143 of file TextFormat.java.

◆ printToString() [2/2]

static String com.google.protobuf.TextFormat.printToString ( final UnknownFieldSet  fields)
inlinestatic

Like

, but writes directly to a

String

and returns it.

Deprecated:
Use UnknownFieldSet#toString()

Definition at line 153 of file TextFormat.java.

◆ printToUnicodeString() [1/2]

static String com.google.protobuf.TextFormat.printToUnicodeString ( final MessageOrBuilder  message)
inlinestatic

Same as

, except that non-ASCII characters in string type fields are not escaped in backslash+octals.

Deprecated:
Use
printer().escapingNonAscii(false).printToString(MessageOrBuilder)

Definition at line 164 of file TextFormat.java.

◆ printToUnicodeString() [2/2]

static String com.google.protobuf.TextFormat.printToUnicodeString ( final UnknownFieldSet  fields)
inlinestatic

Same as

, except that non-ASCII characters in string type fields are not escaped in backslash+octals.

Deprecated:
Use

Definition at line 175 of file TextFormat.java.

◆ printUnicode() [1/2]

static void com.google.protobuf.TextFormat.printUnicode ( final MessageOrBuilder  message,
final Appendable  output 
) throws IOException
inlinestatic

Same as

, except that non-ASCII characters are not escaped.

Deprecated:
Use
printer().escapingNonAscii(false).print(MessageOrBuilder, Appendable)

Definition at line 90 of file TextFormat.java.

◆ printUnicode() [2/2]

static void com.google.protobuf.TextFormat.printUnicode ( final UnknownFieldSet  fields,
final Appendable  output 
) throws IOException
inlinestatic

Same as

, except that non-ASCII characters are not escaped.

Deprecated:
Use

Definition at line 101 of file TextFormat.java.

◆ printUnicodeFieldValue()

static void com.google.protobuf.TextFormat.printUnicodeFieldValue ( final FieldDescriptor  field,
final Object  value,
final Appendable  output 
) throws IOException
inlinestatic

Outputs a unicode textual representation of the value of given field value.

Same as

, except that non-ASCII characters in string type fields are not escaped in backslash+octals.

Deprecated:
Use
Parameters
fieldthe descriptor of the field
valuethe value of the field
outputthe output to which to append the formatted value
Exceptions
ClassCastExceptionif the value is not appropriate for the given field descriptor
IOExceptionif there is an exception writing to the output

Definition at line 207 of file TextFormat.java.

◆ printUnknownFieldValue() [1/2]

static void com.google.protobuf.TextFormat.printUnknownFieldValue ( final int  tag,
final Object  value,
final Appendable  output 
) throws IOException
inlinestatic

Outputs a textual representation of the value of an unknown field.

Parameters
tagthe field's tag number
valuethe value of the field
outputthe output to which to append the formatted value
Exceptions
ClassCastExceptionif the value is not appropriate for the given field descriptor
IOExceptionif there is an exception writing to the output

Definition at line 237 of file TextFormat.java.

◆ printUnknownFieldValue() [2/2]

static void com.google.protobuf.TextFormat.printUnknownFieldValue ( final int  tag,
final Object  value,
final TextGenerator  generator 
) throws IOException
inlinestaticprivate

Definition at line 242 of file TextFormat.java.

◆ shortDebugString() [1/3]

static String com.google.protobuf.TextFormat.shortDebugString ( final FieldDescriptor  field,
final Object  value 
)
inlinestatic

Generates a human readable form of the field, useful for debugging and other purposes, with no newline characters.

Deprecated:
Use

Definition at line 122 of file TextFormat.java.

◆ shortDebugString() [2/3]

static String com.google.protobuf.TextFormat.shortDebugString ( final MessageOrBuilder  message)
inlinestatic

Generates a human readable form of this message, useful for debugging and other purposes, with no newline characters. This is just a trivial wrapper around TextFormat.Printer#shortDebugString(MessageOrBuilder).

Definition at line 111 of file TextFormat.java.

◆ shortDebugString() [3/3]

static String com.google.protobuf.TextFormat.shortDebugString ( final UnknownFieldSet  fields)
inlinestatic

Generates a human readable form of the unknown fields, useful for debugging and other purposes, with no newline characters.

Deprecated:
Use

Definition at line 133 of file TextFormat.java.

◆ singleLineOutput()

static TextGenerator com.google.protobuf.TextFormat.singleLineOutput ( Appendable  output)
inlinestaticprivate

Definition at line 652 of file TextFormat.java.

◆ unescapeBytes()

static ByteString com.google.protobuf.TextFormat.unescapeBytes ( final CharSequence  charString) throws InvalidEscapeSequenceException
inlinestatic

Un-escape a byte sequence as escaped using escapeBytes(ByteString). Two-digit hex escapes (starting with "\x") are also recognized.

Definition at line 2043 of file TextFormat.java.

◆ unsignedToString() [1/2]

static String com.google.protobuf.TextFormat.unsignedToString ( final int  value)
inlinestatic

Convert an unsigned 32-bit integer to a string.

Definition at line 629 of file TextFormat.java.

◆ unsignedToString() [2/2]

static String com.google.protobuf.TextFormat.unsignedToString ( final long  value)
inlinestatic

Convert an unsigned 64-bit integer to a string.

Definition at line 638 of file TextFormat.java.

Member Data Documentation

◆ logger

final Logger com.google.protobuf.TextFormat.logger = Logger.getLogger(TextFormat.class.getName())
staticprivate

Definition at line 58 of file TextFormat.java.

◆ PARSER

final Parser com.google.protobuf.TextFormat.PARSER = Parser.newBuilder().build()
staticprivate

Definition at line 1277 of file TextFormat.java.


The documentation for this class was generated from the following file:
com.google.protobuf.TextFormat.printToString
static String printToString(final MessageOrBuilder message)
Definition: TextFormat.java:143
input
std::string input
Definition: tokenizer_unittest.cc:197
com.google.protobuf.TextFormat.Printer.escapingNonAscii
Printer escapingNonAscii(boolean escapeNonAscii)
Definition: TextFormat.java:306
com.google.protobuf.TextFormat.Printer.printFieldValue
void printFieldValue(final FieldDescriptor field, final Object value, final Appendable output)
Definition: TextFormat.java:366
google::protobuf::python::cmessage::UnknownFieldSet
static PyObject * UnknownFieldSet(CMessage *self)
Definition: python/google/protobuf/pyext/message.cc:2501
com.google.protobuf.TextFormat.Printer.print
void print(final MessageOrBuilder message, final Appendable output)
Definition: TextFormat.java:315
FieldDescriptor
Definition: ruby/ext/google/protobuf_c/protobuf.h:129
com.google.protobuf.TextFormat.print
static void print(final MessageOrBuilder message, final Appendable output)
Definition: TextFormat.java:68
com.google.protobuf.TextFormat.printer
static Printer printer()
Definition: TextFormat.java:280
fields
static const upb_fielddef fields[107]
Definition: ruby/ext/google/protobuf_c/upb.c:7671
com.google.protobuf.TextFormat.Printer.printFieldToString
String printFieldToString(final FieldDescriptor field, final Object value)
Definition: TextFormat.java:329
com.google.protobuf.TextFormat.Printer.printField
void printField(final FieldDescriptor field, final Object value, final Appendable output)
Definition: TextFormat.java:339
com.google.protobuf.TextFormat.Printer.printToString
String printToString(final MessageOrBuilder message)
Definition: TextFormat.java:441
com.google.protobuf.TextFormat.printFieldValue
static void printFieldValue(final FieldDescriptor field, final Object value, final Appendable output)
Definition: TextFormat.java:223
output
const upb_json_parsermethod const upb_symtab upb_sink * output
Definition: ruby/ext/google/protobuf_c/upb.h:10503
com.google.protobuf.TextFormat.Printer.shortDebugString
String shortDebugString(final MessageOrBuilder message)
Definition: TextFormat.java:465


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