Package: org.codehaus.groovy.runtime

## [Java] Class FormatHelper

- org.codehaus.groovy.runtime.FormatHelper

-     public class FormatHelper
      extends Object

  Formatting methods

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static MetaClassRegistry` | `metaRegistry` |

  - ### Methods Summary

    Methods
    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.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### public static final MetaClassRegistry metaRegistry

  - ### Method Detail

    - #### public static void append(Appendable out, Object object)

      Appends an object to an Appendable using Groovy's default representation for the object.

      throws:
        IOException if an I/O error occurs
      Parameters:
        `out` - the appendable to write to
        `object` - the object to append

    - #### public static String escapeBackslashes(String orig)

      Escapes special characters in the given string, converting them to their escaped representations. Converts backslash, newline, carriage return, tab, and form feed characters.

      Parameters:
        `orig` - the string to escape
      Returns:
        the string with special characters escaped

    - #### public static String format(Object arguments, boolean verbose)

      Formats the given object as a string with optional verbosity.

      Parameters:
        `arguments` - the object to format
        `verbose` - if true, uses inspect mode with escaped backslashes
      Returns:
        a formatted string representation

    - #### public static String format(Object arguments, boolean inspect, boolean escapeBackslashes)

      Formats the given object as a string with inspect and escape options.

      Parameters:
        `arguments` - the object to format
        `inspect` - if true, uses inspect mode; if false, uses toString
        `escapeBackslashes` - if true, escapes special characters like tabs and newlines
      Returns:
        a formatted string representation

    - #### public static String format(Object arguments, boolean verbose, int maxSize)

      Formats the given object as a string with a maximum size constraint.

      Parameters:
        `arguments` - the object to format
        `verbose` - if true, uses inspect mode with escaped backslashes
        `maxSize` - maximum characters to include, or -1 for no limit
      Returns:
        a formatted string representation

    - #### public static String format(Object arguments, boolean inspect, boolean escapeBackslashes, int maxSize)

      Formats the given object as a string with multiple options.

      Parameters:
        `arguments` - the object to format
        `inspect` - if true, uses inspect mode; if false, uses toString
        `escapeBackslashes` - if true, escapes special characters
        `maxSize` - maximum characters to include, or -1 for no limit
      Returns:
        a formatted string representation

    - #### public static String format(Object arguments, boolean verbose, int maxSize, boolean safe)

      Formats the given object as a string with verbose and safe options.

      Parameters:
        `arguments` - the object to format
        `verbose` - if true, uses inspect mode with escaped backslashes
        `maxSize` - maximum characters to include, or -1 for no limit
        `safe` - if true, exceptions during formatting are caught and handled gracefully
      Returns:
        a formatted string representation

    - #### 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.

      Parameters:
        `arguments` - the object to format
        `inspect` - if true, uses inspect mode; if false, uses toString
        `escapeBackslashes` - if true, escapes special characters like tabs and newlines
        `maxSize` - maximum characters to include, or -1 for no limit
        `safe` - if true, exceptions during formatting are caught and handled gracefully
      Returns:
        a formatted string representation

    - #### public static String inspect(Object self)

      Returns an inspectable string representation of the given object.

      Parameters:
        `self` - the object to inspect
      Returns:
        a detailed string representation

    - #### public static String toArrayString(Object[] arguments)

      A helper method to return the string representation of an array of objects with brace boundaries "[" and "]".

      Parameters:
        `arguments` - the array to process
      Returns:
        the string representation of the array

    - #### 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 "]".

      Parameters:
        `arguments` - the array to process
        `maxSize` - 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 toString
      Returns:
        the string representation of the array

    - #### public static String toListString(Collection arg)

      A helper method to return the string representation of a list with bracket boundaries "[" and "]".

      Parameters:
        `arg` - the collection to process
      Returns:
        the string representation of the collection

    - #### public static String toListString(Collection arg, int maxSize)

      A helper method to return the string representation of a list with bracket boundaries "[" and "]".

      Parameters:
        `arg` - the collection to process
        `maxSize` - stop after approximately this many characters and append '...'
      Returns:
        the string representation of the collection

    - #### 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 "]".

      Parameters:
        `arg` - the collection to process
        `maxSize` - stop after approximately this many characters and append '...', -1 means don't stop
        `safe` - whether to use a default object representation for any item in the collection if an exception occurs when generating its toString
      Returns:
        the string representation of the collection

    - #### public static String toMapString(Map arg)

      A helper method to return the string representation of a map with bracket boundaries "[" and "]".

      Parameters:
        `arg` - the map to process
      Returns:
        the string representation of the map

    - #### public static String toMapString(Map arg, int maxSize)

      A helper method to return the string representation of a map with bracket boundaries "[" and "]".

      Parameters:
        `arg` - the map to process
        `maxSize` - stop after approximately this many characters and append '...', -1 means don't stop
      Returns:
        the string representation of the map

    - #### public static String toString(Object arguments)

      Returns a string representation of the given object.

      Parameters:
        `arguments` - the object to convert to a string
      Returns:
        a string representation

    - #### public static String toString(@NamedParams({ @NamedParam(value = "safe", type = Boolean.class), @NamedParam(value = "maxSize", type = Integer.class), @NamedParam(value = "verbose", type = Boolean.class), @NamedParam(value = "escapeBackslashes", type = Boolean.class), @NamedParam(value = "inspect", type = Boolean.class) })
      Map<String, Object> options, Object arguments)

      Output the `toString` for the argument(s) with various options to configure. Configuration options:

               safeprovides protection if the toString throws an exception, in which case the exception is swallowed and a dumber default toString is used
               maxSizewill attempt to truncate the output to fit approx the maxSize number of characters, -1 means don't truncate
               inspectif false, render a value by its toString, otherwise use its inspect value
               escapeBackSlasheswhether characters like tab, newline, etc. are converted to their escaped rendering ('\t', '\n', etc.)
               verboseshorthand to turn on both inspect and escapeBackslashes

      Parameters:
        `options` - a map of configuration options
        `arguments` - the argument(s) to calculate the `toString` for
      Returns:
        the string rendering of the argument(s)
      See Also:
        DefaultGroovyMethods.inspect

    - #### public static String toTypeString(Object[] arguments)

      A helper method to format the arguments types as a comma-separated list.

      Parameters:
        `arguments` - the type to process
      Returns:
        the string representation of the type

    - #### public static String toTypeString(Object[] arguments, int maxSize)

      A helper method to format the arguments types as a comma-separated list.

      Parameters:
        `arguments` - the type to process
        `maxSize` - stop after approximately this many characters and append '...', -1 means don't stop
      Returns:
        the string representation of the type

    - #### public static void write(Writer out, Object object)

      Writes an object to a Writer using Groovy's default representation for the object.

      throws:
        IOException if an I/O error occurs
      Parameters:
        `out` - the writer to write to
        `object` - the object to write