Package org.apache.juneau.marshall.yaml
Class YamlWriter
java.lang.Object
java.io.Writer
org.apache.juneau.marshall.serializer.SerializerWriter<YamlWriter>
org.apache.juneau.marshall.yaml.YamlWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
Specialized writer for serializing YAML.
Notes:
- This class is not intended for external use.
See Also:
-
Field Summary
Fields inherited from class org.apache.juneau.marshall.serializer.SerializerWriter
maxIndent, out, quoteChar, trimStrings, uriResolver, useWhitespace -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedYamlWriter(Writer out, boolean useWhitespace, int maxIndent, boolean trimStrings, UriResolver uriResolver) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionWrites a YAML mapping key.Writes just the key name portion (with quoting if necessary) but without any separator.listEntry(int depth) Writes a YAML list entry prefix.Writes a YAML scalar text value.Appends a URI value to the output.yamlIndent(int depth) Writes YAML block indentation.
-
Constructor Details
-
YamlWriter
protected YamlWriter(Writer out, boolean useWhitespace, int maxIndent, boolean trimStrings, UriResolver uriResolver) Constructor.- Parameters:
out- The writer being wrapped.useWhitespace- Iftrue , tabs and spaces will be used in output.maxIndent- The maximum indentation level.trimStrings- Iftrue , strings will be trimmed before being serialized.uriResolver- The URI resolver for resolving URIs to absolute or root-relative form.
-
-
Method Details
-
key
Writes a YAML mapping key.If the key needs quoting (contains special YAML characters, starts/ends with whitespace, is empty, or is a YAML reserved word), it will be double-quoted with proper escaping. A colon-space separator is always appended after the key.
- Parameters:
s- The key name.
Can benull (written as the literalnull ).- Returns:
- This object.
-
keyName
Writes just the key name portion (with quoting if necessary) but without any separator.- Parameters:
s- The key name.
Can benull (written as the literalnull ).- Returns:
- This object.
-
textValue
Writes a YAML scalar text value.If null, writes the literal
null . If the string needs quoting (is empty, looks like a boolean/null/number, contains special characters, starts/ends with whitespace, or contains newlines), it will be double-quoted with proper YAML escaping.- Parameters:
s- The string value.
Can benull (written as the literalnull ).- Returns:
- This object.
-
uriValue
Appends a URI value to the output.Resolves the URI and writes it as a double-quoted YAML string.
- Parameters:
uri- The URI to append to the output.
Can benull . The effect is implementation-dependent — seeUriResolver.resolve(Object).- Returns:
- This object.
-
yamlIndent
Writes YAML block indentation.Writes a newline followed by
depth * 2spaces of indentation.- Parameters:
depth- The indentation depth.- Returns:
- This object.
-
listEntry
Writes a YAML list entry prefix.Writes a newline followed by
depth * 2spaces and a dash-space ("- " ) prefix.- Parameters:
depth- The indentation depth.- Returns:
- This object.
-