Class ValueFormatter

java.lang.Object
org.ujorm.tools.msg.MsgFormatter
org.ujorm.tools.msg.ValueFormatter
Direct Known Subclasses:
ValuePrinter

@Unmodifiable public class ValueFormatter extends MsgFormatter
Formatter of log messages where argument is located by the {} characters. See the next correct asserts:
  assertEquals("TEST"    , MsgFormatter.format("TE{}T", "S"));
  assertEquals("TE, S, T", MsgFormatter.format("TE", "S", "T"));
  assertEquals("TES{}"   , MsgFormatter.format("TE{}{}", "S"));
 
Since:
1.73
Author:
Pavel Ponec
  • Field Details

    • valueBorder

      protected final String valueBorder
      Border of the byte array
  • Constructor Details

    • ValueFormatter

      protected ValueFormatter()
      Static methods are available only
    • ValueFormatter

      protected ValueFormatter(@NotNull @NotNull String mark, @NotNull @NotNull String textBorder)
      Static methods are available only
  • Method Details

    • writeValue

      protected void writeValue(@Nullable @Nullable Object value, @NotNull @NotNull Appendable out, boolean marked) throws IOException
      Print argument to the Writter with an optional format.
      Overrides:
      writeValue in class MsgFormatter
      Parameters:
      out - Appendable
      value - A one value where the Supplier interface is supported.
      Throws:
      IOException
    • writeByteArray

      protected void writeByteArray(@NotNull @org.jetbrains.annotations.NotNull byte[] bytes, @NotNull @NotNull Appendable out) throws IOException
      Write bytes as hexa
      Throws:
      IOException
    • writeLongValue

      protected void writeLongValue(@NotNull @NotNull CharSequence value, @NotNull @NotNull Appendable out) throws IOException
      You can call the method from a child class
      Throws:
      IOException
    • getSizeLimit

      protected int getSizeLimit()
      Default lenhth is 32
    • format

      @NotNull public static <T> @NotNull String format(@Nullable @Nullable String messageTemplate, @Nullable @Nullable T... arguments)
      Format the message, see the next correct asserts:
        assertEquals("TEST"    , MsgFormatter.format("TE{}T", "S"));
        assertEquals("TE, S, T", MsgFormatter.format("TE", "S", "T"));
        assertEquals("TES{}"   , MsgFormatter.format("TE{}{}", "S"));
       
      Parameters:
      messageTemplate - Template where argument position is marked by the {} characters.
      arguments - Optional arguments
      Returns:
    • formatSql

      @NotNull public static <T> @NotNull String formatSql(@Nullable @Nullable String sqlTemplate, @Nullable @Nullable T... arguments)
      Format the SQL where makup character is '?'.
        assertEquals("TEST"    , MsgFormatter.format("TE?T", "S"));
        assertEquals("TE, S, T", MsgFormatter.format("TE", "S", "T"));
        assertEquals("TES{}"   , MsgFormatter.format("TE??", "S"));
       
      Parameters:
      sqlTemplate - SQL template where argument position is marked by the '?' characters.
      arguments - Optional arguments
      Returns: