Module swim.codec
Package swim.codec

Class Format


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

      • display

        public static <T> Output<T> display​(Object object,
                                            Output<T> output)
        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.
      • debug

        public static <T> Output<T> debug​(Object object,
                                          Output<T> output)
        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.
      • displayInt

        public static <T> Output<T> displayInt​(int value,
                                               Output<T> output)
        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​(long value,
                                                Output<T> output)
        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​(float value,
                                                 Output<T> output)
        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​(double value,
                                                  Output<T> output)
        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​(int value,
                                             Output<T> output)
        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​(long value,
                                              Output<T> output)
        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​(float value,
                                               Output<T> output)
        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​(double value,
                                                Output<T> output)
        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​(int character,
                                              Output<T> output)
        Writes the code points of the Java character literal for the given character to output.
        Returns:
        the continuation of the output.
      • debugString

        public static <T> Output<T> debugString​(String string,
                                                Output<T> output)
        Writes the code points of the Java string literal for the given string 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.