Package org.pkl.core
Class ValueFormatter
java.lang.Object
org.pkl.core.ValueFormatter
-
Constructor Summary
ConstructorsConstructorDescriptionValueFormatter(boolean useMultilineStrings, boolean useCustomStringDelimiters) Constructs an instance of aValueFormatter. -
Method Summary
Modifier and TypeMethodDescriptionstatic ValueFormatterbasic()Equivalent tonew ValueFormatter(false, false).formatStringValue(String value, CharSequence lineIndent) Formatsvalueas a Pkl/Pcf string literal (including quotes).voidformatStringValue(String value, CharSequence lineIndent, Appendable appendable) Same asformatStringValue(String, CharSequence), except that output goes toappendable(which may causeIOException).voidformatStringValue(String value, CharSequence lineIndent, StringBuilder builder) Same asformatStringValue(String, CharSequence), except that output goes tobuilder.static ValueFormatterEquivalent tonew ValueFormatter(false, true).
-
Constructor Details
-
ValueFormatter
public ValueFormatter(boolean useMultilineStrings, boolean useCustomStringDelimiters) Constructs an instance of aValueFormatter.If
useMultilineStringsistrue, string values containing newline characters are formatted as multiline string literals.If
useCustomStringDelimitersistrue, custom string delimiters (such as#"..."#) are preferred over escaping quotes and backslashes.
-
-
Method Details
-
basic
Equivalent tonew ValueFormatter(false, false). -
withCustomStringDelimiters
Equivalent tonew ValueFormatter(false, true). -
formatStringValue
Formatsvalueas a Pkl/Pcf string literal (including quotes).If
valuecontains a\ncharacter, a multiline string literal is returned, and subsequent lines are indented bylineIndent. Otherwise, a single line string literal is returned. -
formatStringValue
Same asformatStringValue(String, CharSequence), except that output goes tobuilder. -
formatStringValue
public void formatStringValue(String value, CharSequence lineIndent, Appendable appendable) throws IOException Same asformatStringValue(String, CharSequence), except that output goes toappendable(which may causeIOException).- Throws:
IOException
-