@Generated(value="proto")
public final class TextFormat
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
TextFormat.InvalidEscapeSequenceException
Thrown by
unescapeBytes(java.lang.CharSequence) and unescapeText(java.lang.String) when an invalid
escape sequence is seen. |
static class |
TextFormat.ParseException
Thrown when parsing an invalid text format message.
|
static class |
TextFormat.Parser
Parser for text-format proto2 instances.
|
static class |
TextFormat.UnknownFieldParseException
Thrown when encountering an unknown field while parsing a text format message.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
escapeBytes(byte[] input)
Like
escapeBytes(ByteString) , but used for byte array. |
static java.lang.String |
escapeBytes(ByteString input)
Escapes bytes in the format used in protocol buffer text format, which is the same as the
format used for C string literals.
|
static java.lang.String |
escapeDoubleQuotesAndBackslashes(java.lang.String input)
Escape double quotes and backslashes in a String for unicode output of a message.
|
static TextFormat.Parser |
getParser()
Return a
Parser instance which can parse text-format messages. |
static void |
merge(java.lang.CharSequence input,
ExtensionRegistry extensionRegistry,
Message.Builder builder)
Parse a text-format message from
input and merge the contents into builder . |
static void |
merge(java.lang.CharSequence input,
Message.Builder builder)
Parse a text-format message from
input and merge the contents into builder . |
static void |
merge(java.lang.Readable input,
ExtensionRegistry extensionRegistry,
Message.Builder builder)
Parse a text-format message from
input and merge the contents into builder . |
static void |
merge(java.lang.Readable input,
Message.Builder builder)
Parse a text-format message from
input and merge the contents into builder . |
static <T extends Message> |
parse(java.lang.CharSequence input,
java.lang.Class<T> protoClass)
Parse a text-format message from
input . |
static <T extends Message> |
parse(java.lang.CharSequence input,
ExtensionRegistry extensionRegistry,
java.lang.Class<T> protoClass)
Parse a text-format message from
input . |
static void |
print(MessageOrBuilder message,
java.lang.Appendable output)
Outputs a textual representation of the Protocol Message supplied into the parameter output.
|
static void |
print(UnknownFieldSet fields,
java.lang.Appendable output)
Outputs a textual representation of
fields to output . |
static void |
printField(Descriptors.FieldDescriptor field,
java.lang.Object value,
java.lang.Appendable output) |
static java.lang.String |
printFieldToString(Descriptors.FieldDescriptor field,
java.lang.Object value) |
static void |
printFieldValue(Descriptors.FieldDescriptor field,
java.lang.Object value,
java.lang.Appendable output)
Outputs a textual representation of the value of given field value.
|
static java.lang.String |
printToString(MessageOrBuilder message)
Like
print() , but writes directly to a String and returns it. |
static java.lang.String |
printToString(UnknownFieldSet fields)
Like
print() , but writes directly to a String and returns it. |
static java.lang.String |
printToUnicodeString(MessageOrBuilder message)
Same as
printToString() , except that non-ASCII characters in string type fields are not
escaped in backslash+octals. |
static java.lang.String |
printToUnicodeString(UnknownFieldSet fields)
Same as
printToString() , except that non-ASCII characters in string type fields are not
escaped in backslash+octals. |
static void |
printUnicode(MessageOrBuilder message,
java.lang.Appendable output)
Same as
print() , except that non-ASCII characters are not escaped. |
static void |
printUnicode(UnknownFieldSet fields,
java.lang.Appendable output)
Same as
print() , except that non-ASCII characters are not escaped. |
static void |
printUnicodeFieldValue(Descriptors.FieldDescriptor field,
java.lang.Object value,
java.lang.Appendable output)
Outputs a unicode textual representation of the value of given field value.
|
static void |
printUnknownFieldValue(int tag,
java.lang.Object value,
java.lang.Appendable output)
Outputs a textual representation of the value of an unknown field.
|
static java.lang.String |
shortDebugString(Descriptors.FieldDescriptor field,
java.lang.Object value)
Generates a human readable form of the field, useful for debugging and other purposes, with no
newline characters.
|
static java.lang.String |
shortDebugString(MessageOrBuilder message)
Generates a human readable form of this message, useful for debugging and other purposes, with
no newline characters.
|
static java.lang.String |
shortDebugString(UnknownFieldSet fields)
Generates a human readable form of the unknown fields, useful for debugging and other purposes,
with no newline characters.
|
static ByteString |
unescapeBytes(java.lang.CharSequence charString)
Un-escape a byte sequence as escaped using
escapeBytes(ByteString) . |
static java.lang.String |
unsignedToString(int value)
Convert an unsigned 32-bit integer to a string.
|
static java.lang.String |
unsignedToString(long value)
Convert an unsigned 64-bit integer to a string.
|
public static void print(MessageOrBuilder message, java.lang.Appendable output) throws java.io.IOException
java.io.IOException
public static void print(UnknownFieldSet fields, java.lang.Appendable output) throws java.io.IOException
fields
to output
.java.io.IOException
public static void printUnicode(MessageOrBuilder message, java.lang.Appendable output) throws java.io.IOException
print()
, except that non-ASCII characters are not escaped.java.io.IOException
public static void printUnicode(UnknownFieldSet fields, java.lang.Appendable output) throws java.io.IOException
print()
, except that non-ASCII characters are not escaped.java.io.IOException
public static java.lang.String shortDebugString(MessageOrBuilder message)
public static java.lang.String shortDebugString(Descriptors.FieldDescriptor field, java.lang.Object value)
public static java.lang.String shortDebugString(UnknownFieldSet fields)
public static java.lang.String printToString(MessageOrBuilder message)
print()
, but writes directly to a String
and returns it.public static java.lang.String printToString(UnknownFieldSet fields)
print()
, but writes directly to a String
and returns it.public static java.lang.String printToUnicodeString(MessageOrBuilder message)
printToString()
, except that non-ASCII characters in string type fields are not
escaped in backslash+octals.public static java.lang.String printToUnicodeString(UnknownFieldSet fields)
printToString()
, except that non-ASCII characters in string type fields are not
escaped in backslash+octals.public static void printField(Descriptors.FieldDescriptor field, java.lang.Object value, java.lang.Appendable output) throws java.io.IOException
java.io.IOException
public static java.lang.String printFieldToString(Descriptors.FieldDescriptor field, java.lang.Object value)
public static void printUnicodeFieldValue(Descriptors.FieldDescriptor field, java.lang.Object value, java.lang.Appendable output) throws java.io.IOException
Same as printFieldValue()
, except that non-ASCII characters in string type fields
are not escaped in backslash+octals.
field
- the descriptor of the fieldvalue
- the value of the fieldoutput
- the output to which to append the formatted valuejava.lang.ClassCastException
- if the value is not appropriate for the given field descriptorjava.io.IOException
- if there is an exception writing to the outputpublic static void printFieldValue(Descriptors.FieldDescriptor field, java.lang.Object value, java.lang.Appendable output) throws java.io.IOException
field
- the descriptor of the fieldvalue
- the value of the fieldoutput
- the output to which to append the formatted valuejava.lang.ClassCastException
- if the value is not appropriate for the given field descriptorjava.io.IOException
- if there is an exception writing to the outputpublic static void printUnknownFieldValue(int tag, java.lang.Object value, java.lang.Appendable output) throws java.io.IOException
tag
- the field's tag numbervalue
- the value of the fieldoutput
- the output to which to append the formatted valuejava.lang.ClassCastException
- if the value is not appropriate for the given field descriptorjava.io.IOException
- if there is an exception writing to the outputpublic static java.lang.String unsignedToString(int value)
public static java.lang.String unsignedToString(long value)
public static TextFormat.Parser getParser()
Parser
instance which can parse text-format messages. The returned instance is
thread-safe.public static void merge(java.lang.Readable input, Message.Builder builder) throws java.io.IOException
input
and merge the contents into builder
.java.io.IOException
public static void merge(java.lang.CharSequence input, Message.Builder builder) throws TextFormat.ParseException
input
and merge the contents into builder
.TextFormat.ParseException
public static <T extends Message> T parse(java.lang.CharSequence input, java.lang.Class<T> protoClass) throws TextFormat.ParseException
input
.TextFormat.ParseException
public static void merge(java.lang.Readable input, ExtensionRegistry extensionRegistry, Message.Builder builder) throws java.io.IOException
input
and merge the contents into builder
.
Extensions will be recognized if they are registered in extensionRegistry
.java.io.IOException
public static void merge(java.lang.CharSequence input, ExtensionRegistry extensionRegistry, Message.Builder builder) throws TextFormat.ParseException
input
and merge the contents into builder
.
Extensions will be recognized if they are registered in extensionRegistry
.TextFormat.ParseException
public static <T extends Message> T parse(java.lang.CharSequence input, ExtensionRegistry extensionRegistry, java.lang.Class<T> protoClass) throws TextFormat.ParseException
input
. Extensions will be recognized if they are
registered in extensionRegistry
.TextFormat.ParseException
public static java.lang.String escapeBytes(ByteString input)
public static java.lang.String escapeBytes(byte[] input)
escapeBytes(ByteString)
, but used for byte array.public static ByteString unescapeBytes(java.lang.CharSequence charString) throws TextFormat.InvalidEscapeSequenceException
escapeBytes(ByteString)
. Two-digit hex
escapes (starting with "\x") are also recognized.public static java.lang.String escapeDoubleQuotesAndBackslashes(java.lang.String input)
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.