Package io.github.qishr.cascara.lang.yaml.processor
Class YamlEmitter
java.lang.Object
io.github.qishr.cascara.lang.yaml.processor.AbstractYamlProcessor<io.github.qishr.cascara.lang.yaml.processor.YamlEmitter>
io.github.qishr.cascara.lang.yaml.processor.YamlEmitter
All Implemented Interfaces:
Emitter
public class YamlEmitter
extends AbstractYamlProcessor<YamlEmitter>
Responsible for converting a YamlNode AST back into a valid YAML string.This emitter is high-fidelity: it prioritizes preserving the original NodeStyle and QuoteStyle of nodes while ensuring that comments are placed correctly relative to their owner nodes.
Indentation Logic
The emitter maintains a virtual column through the indent parameters passed
during recursive calls. It handles special cases like "compact" sequences where
the mapping starts on the same line as the sequence dash (- key: value).
Constructor Summary
| Constructor | Description |
|---|---|
| YamlEmitter() |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| protected YamlEmitter | self() | |
| public void | emitScalar(String value) | |
| public void | emitMapStart() | |
| public void | emitMapEnd() | |
| public void | emitSequenceStart() | |
| public void | emitSequenceEnd() | |
| public void | emitPropertySeparator() | |
| public void | emitItemSeparator() | |
| public void | emitNewLine() | |
| public void | indent() | |
| public void | dedent() | |
| public String | getOutput() | |
| public String | emit(YamlNode root) | Primary entry point for emitting a full document or a multi-document stream. |
Methods inherited from AbstractYamlProcessor
setReporter, getOptions, getContentType, getServiceProperties, getVersion, getReporter, setOptions
Method Details
self
protected YamlEmitter self()
Overrides:
emitScalar
public void emitScalar(String value)
Specified By:
emitMapStart
public void emitMapStart()
Specified By:
emitMapEnd
public void emitMapEnd()
Specified By:
emitSequenceStart
public void emitSequenceStart()
Specified By:
emitSequenceEnd
public void emitSequenceEnd()
Specified By:
emitPropertySeparator
public void emitPropertySeparator()
Specified By:
emitItemSeparator
public void emitItemSeparator()
Specified By:
emitNewLine
public void emitNewLine()
Specified By:
indent
public void indent()
Specified By:
dedent
public void dedent()
Specified By:
getOutput
public String getOutput()
Specified By:
emit
public String emit(YamlNode root)
Primary entry point for emitting a full document or a multi-document stream.
Parameters:
root - AST root (can be a YamlStreamNode, YamlMap, YamlSequenceNode, or YamlScalarNode).
Returns:
A formatted YAML string.