Module swim.codec
Package swim.codec

Class Format

java.lang.Object
swim.codec.Format

public final class Format extends Object
Text format utility functions.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    debug(Object object)
    Returns the human-readable Debug string for the givem object, output using standard settings.
    static String
    debug(Object object, OutputSettings settings)
    Returns the developer-readable Display string for the givem object, output using the given settings.
    static <T> Output<T>
    debug(Output<T> output, Object object)
    Writes the code points of the developer-readable Debug string for the given object to output.
    static <T> Output<T>
    debugChar(Output<T> output, int value)
    Writes the code points of the Java character literal for the given value to output.
    static <T> Output<T>
    debugDouble(Output<T> output, double value)
    Writes the code points of the Java numeric literal for the given value to output.
    static <T> Output<T>
    debugFloat(Output<T> output, float value)
    Writes the code points of the Java numeric literal for the given value to output.
    static <T> Output<T>
    debugInt(Output<T> output, int value)
    Writes the code points of the Java numeric literal for the given value to output.
    static <T> Output<T>
    debugLong(Output<T> output, long value)
    Writes the code points of the Java numeric literal for the given value to output.
    static <T> Output<T>
    debugString(Output<T> output, String value)
    Writes the code points of the Java string literal for the given value to output.
    static String
    display(Object object)
    Returns the human-readable Display string for the givem object, output using standard settings.
    static String
    display(Object object, OutputSettings settings)
    Returns the human-readable Display string for the givem object, output using the given settings.
    static <T> Output<T>
    display(Output<T> output, Object object)
    Writes the code points of the human-readable Display string for the given object to output.
    static <T> Output<T>
    displayDouble(Output<T> output, double value)
    Writes the code points of the numeric string for the given value to output.
    static <T> Output<T>
    displayFloat(Output<T> output, float value)
    Writes the code points of the numeric string for the given value to output.
    static <T> Output<T>
    displayInt(Output<T> output, int value)
    Writes the code points of the numeric string for the given value to output.
    static <T> Output<T>
    displayLong(Output<T> output, long value)
    Writes the code points of the numeric string for the given value to output.
    static String
    Returns the operting system specific string used to separate lines of text.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • display

      public static <T> Output<T> display(Output<T> output, Object object)
      Writes the code points of the human-readable Display string for the given object to output. Assumes output is a Unicode Output writer with sufficient capacity. Delegates to Display.display(Output), if object implements Display; otherwise writes the result of Object.toString().
      Returns:
      the continuation of the output.
    • display

      public static String display(Object object, OutputSettings settings)
      Returns the human-readable Display string for the givem object, output using the given settings. Delegates to Display.display(Output), if object implements Display; otherwise returns the result of Object.toString().
      Throws:
      OutputException - if the output exits the cont state before the full display string has been written.
    • display

      public static String display(Object object)
      Returns the human-readable Display string for the givem object, output using standard settings.
      Throws:
      OutputException - if the output exits the cont state before the full display string has been written.
      See Also:
    • debug

      public static <T> Output<T> debug(Output<T> output, Object object)
      Writes the code points of the developer-readable Debug string for the given object to output. Assumes output is a Unicode Output writer with sufficient capacity. Delegates to Debug.debug(Output), if object implements Debug; writes a Java string literal, if object is a String, and writes a Java number literal, if object is a Number; otherwise writes the result of Object.toString().
      Returns:
      the continuation of the output.
    • debug

      public static String debug(Object object, OutputSettings settings)
      Returns the developer-readable Display string for the givem object, output using the given settings. Delegates to Debug.debug(Output), if object implements Debug; returns a Java string literal, if object is a String, and returns a Java number literal, if object is a Number; otherwise returns the result of Object.toString().
      Throws:
      OutputException - if the output exits the cont state before the full display string has been written.
    • debug

      public static String debug(Object object)
      Returns the human-readable Debug string for the givem object, output using standard settings.
      Throws:
      OutputException - if the output exits the cont state before the full display string has been written.
      See Also:
    • displayInt

      public static <T> Output<T> displayInt(Output<T> output, int value)
      Writes the code points of the numeric string for the given value to output.
      Returns:
      the continuation of the output.
    • displayLong

      public static <T> Output<T> displayLong(Output<T> output, long value)
      Writes the code points of the numeric string for the given value to output.
      Returns:
      the continuation of the output.
    • displayFloat

      public static <T> Output<T> displayFloat(Output<T> output, float value)
      Writes the code points of the numeric string for the given value to output.
      Returns:
      the continuation of the output.
    • displayDouble

      public static <T> Output<T> displayDouble(Output<T> output, double value)
      Writes the code points of the numeric string for the given value to output.
      Returns:
      the continuation of the output.
    • debugInt

      public static <T> Output<T> debugInt(Output<T> output, int value)
      Writes the code points of the Java numeric literal for the given value to output.
      Returns:
      the continuation of the output.
    • debugLong

      public static <T> Output<T> debugLong(Output<T> output, long value)
      Writes the code points of the Java numeric literal for the given value to output.
      Returns:
      the continuation of the output.
    • debugFloat

      public static <T> Output<T> debugFloat(Output<T> output, float value)
      Writes the code points of the Java numeric literal for the given value to output.
      Returns:
      the continuation of the output.
    • debugDouble

      public static <T> Output<T> debugDouble(Output<T> output, double value)
      Writes the code points of the Java numeric literal for the given value to output.
      Returns:
      the continuation of the output.
    • debugChar

      public static <T> Output<T> debugChar(Output<T> output, int value)
      Writes the code points of the Java character literal for the given value to output.
      Returns:
      the continuation of the output.
    • debugString

      public static <T> Output<T> debugString(Output<T> output, String value)
      Writes the code points of the Java string literal for the given value to output.
      Returns:
      the continuation of the output.
    • lineSeparator

      public static String lineSeparator()
      Returns the operting system specific string used to separate lines of text.