public final class MessageNanoPrinter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
INDENT |
private static int |
MAX_STRING_LEN |
Modifier | Constructor and Description |
---|---|
private |
MessageNanoPrinter() |
Modifier and Type | Method and Description |
---|---|
private static void |
appendQuotedBytes(byte[] bytes,
java.lang.StringBuffer builder)
Appends a quoted byte array to the provided
StringBuffer . |
private static java.lang.String |
deCamelCaseify(java.lang.String identifier)
Converts an identifier of the format "FieldName" into "field_name".
|
private static java.lang.String |
escapeString(java.lang.String str)
Escape everything except for low ASCII code points.
|
private static void |
print(java.lang.String identifier,
java.lang.Object object,
java.lang.StringBuffer indentBuf,
java.lang.StringBuffer buf)
Function that will print the given message/field into the StringBuffer.
|
static <T extends MessageNano> |
print(T message)
Returns an text representation of a MessageNano suitable for debugging.
|
private static java.lang.String |
sanitizeString(java.lang.String str)
Shortens and escapes the given string.
|
private static final java.lang.String INDENT
private static final int MAX_STRING_LEN
public static <T extends MessageNano> java.lang.String print(T message)
Employs Java reflection on the given object and recursively prints primitive fields, groups, and messages.
private static void print(java.lang.String identifier, java.lang.Object object, java.lang.StringBuffer indentBuf, java.lang.StringBuffer buf) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
identifier
- the identifier to use, or null
if this is the root message to
print.object
- the value to print. May in fact be a primitive value or byte array and not a
message.indentBuf
- the indentation each line should begin with.buf
- the output buffer.java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
private static java.lang.String deCamelCaseify(java.lang.String identifier)
private static java.lang.String sanitizeString(java.lang.String str)
private static java.lang.String escapeString(java.lang.String str)
private static void appendQuotedBytes(byte[] bytes, java.lang.StringBuffer builder)
StringBuffer
.