Package org.apache.juneau.marshall.hocon
Class HoconWriter
java.lang.Object
java.io.Writer
org.apache.juneau.marshall.serializer.SerializerWriter<HoconWriter>
org.apache.juneau.marshall.hocon.HoconWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
Specialized writer for serializing HOCON format.
Extends SerializerWriter with HOCON-specific methods for unquoted strings,
triple-quoted strings ("""), equals sign separator, and formatting options.
See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanOmit root braces.protected final booleanUse = (not :) for key-value separator.protected final booleanUse triple-quoted """ for strings with newlines.protected final booleanUse newlines instead of commas between members.protected final booleanUse unquoted keys when safe.protected final booleanUse unquoted strings for simple values.Fields inherited from class org.apache.juneau.marshall.serializer.SerializerWriter
maxIndent, out, quoteChar, trimStrings, uriResolver, useWhitespace -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHoconWriter(Writer out, boolean useWhitespace, int maxIndent, boolean trimStrings, boolean useNewlineSeparators, boolean useUnquotedStrings, boolean useUnquotedKeys, boolean omitRootBraces, boolean useMultilineStrings, boolean useEqualsSign, UriResolver uriResolver) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionarrayEnd()Writes array end.Writes array start.Writes the key-value separator (= or :).booleanisSimpleValue(String value) Returns whether the value can be written as unquoted.Writes the key (unquoted or quoted).booleanneedsQuoting(String key) Returns whether the key needs quoting.objectEnd(int depth) Writes object end.objectStart(int depth) Writes object start.quotedString(String value) Writes a quoted string with JSON escaping.separator(int depth) Writes member separator (newline or comma).tripleQuotedString(String value) Writes a triple-quoted string using """ syntax.unquotedString(String value) Writes an unquoted string value.
-
Field Details
-
useNewlineSeparators
Use newlines instead of commas between members. -
useUnquotedStrings
Use unquoted strings for simple values. -
useUnquotedKeys
Use unquoted keys when safe. -
omitRootBraces
Omit root braces. -
useMultilineStrings
Use triple-quoted """ for strings with newlines. -
useEqualsSign
Use = (not :) for key-value separator.
-
-
Constructor Details
-
HoconWriter
protected HoconWriter(Writer out, boolean useWhitespace, int maxIndent, boolean trimStrings, boolean useNewlineSeparators, boolean useUnquotedStrings, boolean useUnquotedKeys, boolean omitRootBraces, boolean useMultilineStrings, boolean useEqualsSign, UriResolver uriResolver) Constructor.- Parameters:
out- The writer being wrapped.useWhitespace- Iftrue , use indentation and newlines.maxIndent- The maximum indentation level.trimStrings- Iftrue , trim strings before serialization.useNewlineSeparators- Use newlines instead of commas.useUnquotedStrings- Use unquoted strings for simple values.useUnquotedKeys- Use unquoted keys when safe.omitRootBraces- Omit root object braces.useMultilineStrings- Use """ for multiline strings.useEqualsSign- Use = for key-value separator.uriResolver- The URI resolver.
-
-
Method Details
-
key
Writes the key (unquoted or quoted).- Parameters:
key- The key to write.
Can benull (treated as an empty string).- Returns:
- This object.
-
equalsSign
Writes the key-value separator (= or :).- Returns:
- This object.
-
objectStart
Writes object start.- Parameters:
depth- The current indentation depth.- Returns:
- This object.
-
objectEnd
Writes object end.- Parameters:
depth- The current indentation depth.- Returns:
- This object.
-
arrayStart
Writes array start.- Returns:
- This object.
-
arrayEnd
Writes array end.- Returns:
- This object.
-
separator
Writes member separator (newline or comma).- Parameters:
depth- The current indentation depth.- Returns:
- This object.
-
needsQuoting
Returns whether the key needs quoting.- Parameters:
key- The key to check.
Can benull (returnstrue ).- Returns:
true if the key must be quoted.
-
isSimpleValue
Returns whether the value can be written as unquoted.- Parameters:
value- The value to check.
Can benull (returnsfalse ).- Returns:
true if the value can be unquoted.
-
unquotedString
Writes an unquoted string value.- Parameters:
value- The value to write.
Can benull (nothing is written).- Returns:
- This object.
-
quotedString
Writes a quoted string with JSON escaping.- Parameters:
value- The value to write.
Can benull (emitted as the literal"null" ).- Returns:
- This object.
-
tripleQuotedString
Writes a triple-quoted string using """ syntax.- Parameters:
value- The value to write.
Can benull (emitted as the literal"null" ).- Returns:
- This object.
-