Package org.ujorm.tools.msg
Class ValueFormatter
java.lang.Object
org.ujorm.tools.msg.MsgFormatter
org.ujorm.tools.msg.ValueFormatter
- Direct Known Subclasses:
ValuePrinter
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 Summary
FieldsFields inherited from class org.ujorm.tools.msg.MsgFormatter
DEFAULT_MARK, SEPARATOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStatic methods are available onlyprotectedValueFormatter(@NotNull String mark, @NotNull String textBorder) Static methods are available only -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull StringFormat the message, see the next correct asserts:static <T> @NotNull StringFormat the SQL where makup character is'?'.protected intDefault lenhth is 32protected voidwriteByteArray(@org.jetbrains.annotations.NotNull byte[] bytes, @NotNull Appendable out) Write bytes as hexaprotected voidwriteLongValue(@NotNull CharSequence value, @NotNull Appendable out) You can call the method from a child classprotected voidwriteValue(@Nullable Object value, @NotNull Appendable out, boolean marked) Print argument to the Writter with an optional format.Methods inherited from class org.ujorm.tools.msg.MsgFormatter
format, format, formatMsg, formatMsg
-
Field Details
-
valueBorder
Border of the byte array
-
-
Constructor Details
-
ValueFormatter
protected ValueFormatter()Static methods are available only -
ValueFormatter
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:
writeValuein classMsgFormatter- Parameters:
out- Appendablevalue- A one value where theSupplierinterface 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:
-