public final class TextFormat
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
TextFormat.InvalidEscapeSequence
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.
|
private static class |
TextFormat.Tokenizer
Represents a stream of tokens parsed from a
String. |
| Modifier and Type | Field and Description |
|---|---|
private static int |
BUFFER_SIZE |
| Constructor and Description |
|---|
TextFormat() |
| Modifier and Type | Method and Description |
|---|---|
private static int |
digitValue(char c)
Interpret a character as a digit (in any base up to 36) and return the
numeric value.
|
(package private) static java.lang.String |
escapeBytes(Buffer input)
Escapes bytes in the format used in protocol buffer text format, which
is the same as the format used for C string literals.
|
(package private) static java.lang.String |
escapeText(java.lang.String input)
Like
escapeBytes(Buffer), but escapes a text string. |
private static boolean |
isHex(char c)
Is this a hex digit?
|
private static boolean |
isOctal(char c)
Is this an octal digit?
|
(package private) static int |
parseInt32(java.lang.String text)
Parse a 32-bit signed integer from the text.
|
(package private) static long |
parseInt64(java.lang.String text)
Parse a 64-bit signed integer from the text.
|
private static long |
parseInteger(java.lang.String text,
boolean isSigned,
boolean isLong) |
(package private) static int |
parseUInt32(java.lang.String text)
Parse a 32-bit unsigned integer from the text.
|
(package private) static long |
parseUInt64(java.lang.String text)
Parse a 64-bit unsigned integer from the text.
|
private static java.lang.StringBuilder |
toStringBuilder(java.lang.Readable input) |
(package private) static Buffer |
unescapeBytes(java.lang.CharSequence input)
Un-escape a byte sequence as escaped using
escapeBytes(Buffer). |
(package private) static java.lang.String |
unescapeText(java.lang.String input)
Un-escape a text string as escaped using
escapeText(String). |
private static java.lang.String |
unsignedToString(int value)
Convert an unsigned 32-bit integer to a string.
|
private static java.lang.String |
unsignedToString(long value)
Convert an unsigned 64-bit integer to a string.
|
private static final int BUFFER_SIZE
private static java.lang.String unsignedToString(int value)
private static java.lang.String unsignedToString(long value)
private static java.lang.StringBuilder toStringBuilder(java.lang.Readable input)
throws java.io.IOException
java.io.IOExceptionstatic java.lang.String escapeBytes(Buffer input)
static Buffer unescapeBytes(java.lang.CharSequence input) throws TextFormat.InvalidEscapeSequence
escapeBytes(Buffer). Two-digit hex escapes (starting with
"\x") are also recognized.TextFormat.InvalidEscapeSequencestatic java.lang.String escapeText(java.lang.String input)
escapeBytes(Buffer), but escapes a text string.
Non-ASCII characters are first encoded as UTF-8, then each byte is escaped
individually as a 3-digit octal escape. Yes, it's weird.static java.lang.String unescapeText(java.lang.String input)
throws TextFormat.InvalidEscapeSequence
escapeText(String).
Two-digit hex escapes (starting with "\x") are also recognized.TextFormat.InvalidEscapeSequenceprivate static boolean isOctal(char c)
private static boolean isHex(char c)
private static int digitValue(char c)
Character.digit() but we don't accept
non-ASCII digits.static int parseInt32(java.lang.String text)
throws java.lang.NumberFormatException
Integer.parseInt(), this function recognizes the prefixes "0x"
and "0" to signify hexidecimal and octal numbers, respectively.java.lang.NumberFormatExceptionstatic int parseUInt32(java.lang.String text)
throws java.lang.NumberFormatException
Integer.parseInt(), this function recognizes the prefixes "0x"
and "0" to signify hexidecimal and octal numbers, respectively. The
result is coerced to a (signed) int when returned since Java has
no unsigned integer type.java.lang.NumberFormatExceptionstatic long parseInt64(java.lang.String text)
throws java.lang.NumberFormatException
Integer.parseInt(), this function recognizes the prefixes "0x"
and "0" to signify hexidecimal and octal numbers, respectively.java.lang.NumberFormatExceptionstatic long parseUInt64(java.lang.String text)
throws java.lang.NumberFormatException
Integer.parseInt(), this function recognizes the prefixes "0x"
and "0" to signify hexidecimal and octal numbers, respectively. The
result is coerced to a (signed) long when returned since Java has
no unsigned long type.java.lang.NumberFormatExceptionprivate static long parseInteger(java.lang.String text,
boolean isSigned,
boolean isLong)
throws java.lang.NumberFormatException
java.lang.NumberFormatException