public class FormatHelper
extends Object
Formatting methods
| Modifiers | Name | Description |
|---|---|---|
static MetaClassRegistry |
metaRegistry |
The registry returned by GroovySystem.getMetaClassRegistry when this class is initialized. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static void |
append(Appendable out, Object object)Appends an object to an Appendable using Groovy's default representation for the object. |
|
public static String |
escapeBackslashes(String orig)Escapes special characters in the given string, converting them to their escaped representations. |
|
public static String |
format(Object arguments, boolean verbose)Formats the given object as a string with optional verbosity. |
|
public static String |
format(Object arguments, boolean inspect, boolean escapeBackslashes)Formats the given object as a string with inspect and escape options. |
|
public static String |
format(Object arguments, boolean verbose, int maxSize)Formats the given object as a string with a maximum size constraint. |
|
public static String |
format(Object arguments, boolean inspect, boolean escapeBackslashes, int maxSize)Formats the given object as a string with multiple options. |
|
public static String |
format(Object arguments, boolean verbose, int maxSize, boolean safe)Formats the given object as a string with verbose and safe options. |
|
public static String |
format(Object arguments, boolean inspect, boolean escapeBackslashes, int maxSize, boolean safe)Formats the given object as a string with full control over all options. |
|
public static String |
inspect(Object self)Returns an inspectable string representation of the given object. |
|
public static String |
toArrayString(Object[] arguments)A helper method to return the string representation of an array of objects with brace boundaries "[" and "]". |
|
public static String |
toArrayString(Object[] arguments, int maxSize, boolean safe)A helper method to return the string representation of an array of objects with brace boundaries "[" and "]". |
|
public static String |
toListString(Collection arg)A helper method to return the string representation of a list with bracket boundaries "[" and "]". |
|
public static String |
toListString(Collection arg, int maxSize)A helper method to return the string representation of a list with bracket boundaries "[" and "]". |
|
public static String |
toListString(Collection arg, int maxSize, boolean safe)A helper method to return the string representation of a list with bracket boundaries "[" and "]". |
|
public static String |
toMapString(Map arg)A helper method to return the string representation of a map with bracket boundaries "[" and "]". |
|
public static String |
toMapString(Map arg, int maxSize)A helper method to return the string representation of a map with bracket boundaries "[" and "]". |
|
public static String |
toString(Object arguments)Returns a string representation of the given object. |
|
public static String |
toString(Map<String, Object> options, Object arguments)Output the toString for the argument(s) with various options to configure.
|
|
public static String |
toTypeString(Object[] arguments)A helper method to format the arguments types as a comma-separated list. |
|
public static String |
toTypeString(Object[] arguments, int maxSize)A helper method to format the arguments types as a comma-separated list. |
|
public static void |
write(Writer out, Object object)Writes an object to a Writer using Groovy's default representation for the object. |
The registry returned by GroovySystem.getMetaClassRegistry when this class is initialized. The formatting methods in this class do not read it.
Appends an object to an Appendable using Groovy's default representation for the object.
out - the appendable to write toobject - the object to appendEscapes special characters in the given string, converting them to their escaped representations. Converts backslash, newline, carriage return, tab, and form feed characters.
orig - the string to escapeFormats the given object as a string with optional verbosity.
arguments - the object to formatverbose - if true, uses inspect mode with escaped backslashesFormats the given object as a string with inspect and escape options.
arguments - the object to formatinspect - if true, uses inspect mode; if false, uses toStringescapeBackslashes - if true, escapes special characters like tabs and newlinesFormats the given object as a string with a maximum size constraint.
arguments - the object to formatverbose - if true, uses inspect mode with escaped backslashesmaxSize - maximum characters to include, or -1 for no limitFormats the given object as a string with multiple options.
arguments - the object to formatinspect - if true, uses inspect mode; if false, uses toStringescapeBackslashes - if true, escapes special charactersmaxSize - maximum characters to include, or -1 for no limitFormats the given object as a string with verbose and safe options.
arguments - the object to formatverbose - if true, uses inspect mode with escaped backslashesmaxSize - maximum characters to include, or -1 for no limitsafe - if true, exceptions during formatting are caught and handled gracefullyFormats the given object as a string with full control over all options.
arguments - the object to formatinspect - if true, uses inspect mode; if false, uses toStringescapeBackslashes - if true, escapes special characters like tabs and newlinesmaxSize - maximum characters to include, or -1 for no limitsafe - if true, exceptions during formatting are caught and handled gracefullyReturns an inspectable string representation of the given object.
self - the object to inspectA helper method to return the string representation of an array of objects with brace boundaries "[" and "]".
arguments - the array to processA helper method to return the string representation of an array of objects with brace boundaries "[" and "]".
arguments - the array to processmaxSize - stop after approximately this many characters and append '...'safe - whether to use a default object representation for any item in the array if an exception occurs when generating its toStringA helper method to return the string representation of a list with bracket boundaries "[" and "]".
arg - the collection to processA helper method to return the string representation of a list with bracket boundaries "[" and "]".
arg - the collection to processmaxSize - stop after approximately this many characters and append '...'A helper method to return the string representation of a list with bracket boundaries "[" and "]".
arg - the collection to processmaxSize - stop after approximately this many characters and append '...', -1 means don't stopsafe - whether to use a default object representation for any item in the collection if an exception occurs when generating its toStringA helper method to return the string representation of a map with bracket boundaries "[" and "]".
arg - the map to processA helper method to return the string representation of a map with bracket boundaries "[" and "]".
arg - the map to processmaxSize - stop after approximately this many characters and append '...', -1 means don't stopReturns a string representation of the given object.
arguments - the object to convert to a string Output the toString for the argument(s) with various options to configure.
Configuration options:
toString throws an exception, in which case the exception is swallowed and a dumber default toString is usedtoString, otherwise use its inspect valueinspect and escapeBackslashesoptions - a map of configuration optionsarguments - the argument(s) to calculate the toString forA helper method to format the arguments types as a comma-separated list.
arguments - the type to processA helper method to format the arguments types as a comma-separated list.
arguments - the type to processmaxSize - stop after approximately this many characters and append '...', -1 means don't stop