Package org.yaml.snakeyaml.emitter
Class Emitter
- java.lang.Object
-
- org.yaml.snakeyaml.emitter.Emitter
-
- All Implemented Interfaces:
Emitable
public final class Emitter extends java.lang.Object implements Emitable
Emitter expects events obeying the following grammar: stream ::= STREAM-START document* STREAM-END document ::= DOCUMENT-START node DOCUMENT-END node ::= SCALAR | sequence | mapping sequence ::= SEQUENCE-START node* SEQUENCE-END mapping ::= MAPPING-START (node node)* MAPPING-END
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classEmitter.ExpectBlockMappingKeyprivate classEmitter.ExpectBlockMappingSimpleValueprivate classEmitter.ExpectBlockMappingValueprivate classEmitter.ExpectBlockSequenceItemprivate classEmitter.ExpectDocumentEndprivate classEmitter.ExpectDocumentRootprivate classEmitter.ExpectDocumentStartprivate classEmitter.ExpectFirstBlockMappingKeyprivate classEmitter.ExpectFirstBlockSequenceItemprivate classEmitter.ExpectFirstDocumentStartprivate classEmitter.ExpectFirstFlowMappingKeyprivate classEmitter.ExpectFirstFlowSequenceItemprivate classEmitter.ExpectFlowMappingKeyprivate classEmitter.ExpectFlowMappingSimpleValueprivate classEmitter.ExpectFlowMappingValueprivate classEmitter.ExpectFlowSequenceItemprivate classEmitter.ExpectNothingprivate classEmitter.ExpectStreamStart
-
Field Summary
Fields Modifier and Type Field Description private booleanallowUnicodeprivate ScalarAnalysisanalysisprivate intbestIndentprivate char[]bestLineBreakprivate intbestWidthprivate CommentEventsCollectorblockCommentsCollectorprivate java.lang.Booleancanonicalprivate intcolumnprivate static java.util.Map<java.lang.String,java.lang.String>DEFAULT_TAG_PREFIXESprivate booleanemitCommentsprivate static java.util.Map<java.lang.Character,java.lang.String>ESCAPE_REPLACEMENTSprivate Eventeventprivate java.util.Queue<Event>eventsprivate intflowLevelprivate static java.util.regex.PatternHANDLE_FORMATprivate java.lang.Integerindentprivate booleanindentionprivate ArrayStack<java.lang.Integer>indentsprivate booleanindentWithIndicatorprivate intindicatorIndentprivate CommentEventsCollectorinlineCommentsCollectorprivate static java.util.Set<java.lang.Character>INVALID_ANCHORprivate static java.util.regex.PatternLEADING_ZERO_PATTERNprivate booleanmappingContextstatic intMAX_INDENTindent should not be more than 10 spacesprivate intmaxSimpleKeyLengthstatic intMIN_INDENTindent cannot be zero spacesprivate booleanopenEndedprivate java.lang.StringpreparedAnchorprivate java.lang.StringpreparedTagprivate java.lang.BooleanprettyFlowprivate booleanrootContextprivate booleansimpleKeyContextprivate static char[]SPACEprivate static java.util.regex.PatternSPACES_PATTERNprivate booleansplitLinesprivate EmitterStatestateprivate ArrayStack<EmitterState>statesprivate java.io.Writerstreamprivate DumperOptions.ScalarStylestyleprivate java.util.Map<java.lang.String,java.lang.String>tagPrefixesprivate booleanwhitespace
-
Constructor Summary
Constructors Constructor Description Emitter(java.io.Writer stream, DumperOptions opts)Create
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private ScalarAnalysisanalyzeScalar(java.lang.String scalar)private booleancheckEmptyDocument()private booleancheckEmptyMapping()private booleancheckEmptySequence()private booleancheckSimpleKey()private DumperOptions.ScalarStylechooseScalarStyle()private java.lang.StringdetermineBlockHints(java.lang.String text)voidemit(Event event)Push event to bytesprivate voidexpectAlias()private voidexpectBlockMapping()private voidexpectBlockSequence()private voidexpectFlowMapping()private voidexpectFlowSequence()private voidexpectNode(boolean root, boolean mapping, boolean simpleKey)private voidexpectScalar()(package private) voidflushStream()private voidincreaseIndent(boolean flow, boolean indentless)private booleanisFoldedOrLiteral(Event event)private booleanneedEvents(java.util.Iterator<Event> iter, int count)private booleanneedMoreEvents()(package private) static java.lang.StringprepareAnchor(java.lang.String anchor)private java.lang.StringprepareTag(java.lang.String tag)private java.lang.StringprepareTagHandle(java.lang.String handle)private java.lang.StringprepareTagPrefix(java.lang.String prefix)private java.lang.StringprepareVersion(DumperOptions.Version version)private voidprocessAnchor(java.lang.String indicator)private voidprocessScalar()private voidprocessTag()private voidwriteBlockComment()private booleanwriteCommentLines(java.util.List<CommentLine> commentLines)private voidwriteDoubleQuoted(java.lang.String text, boolean split)(package private) voidwriteFolded(java.lang.String text, boolean split)(package private) voidwriteIndent()(package private) voidwriteIndicator(java.lang.String indicator, boolean needWhitespace, boolean whitespace, boolean indentation)private booleanwriteInlineComments()private voidwriteLineBreak(java.lang.String data)(package private) voidwriteLiteral(java.lang.String text)(package private) voidwritePlain(java.lang.String text, boolean split)private voidwriteSingleQuoted(java.lang.String text, boolean split)(package private) voidwriteStreamEnd()(package private) voidwriteStreamStart()(package private) voidwriteTagDirective(java.lang.String handleText, java.lang.String prefixText)(package private) voidwriteVersionDirective(java.lang.String versionText)private voidwriteWhitespace(int length)
-
-
-
Field Detail
-
MIN_INDENT
public static final int MIN_INDENT
indent cannot be zero spaces- See Also:
- Constant Field Values
-
MAX_INDENT
public static final int MAX_INDENT
indent should not be more than 10 spaces- See Also:
- Constant Field Values
-
SPACE
private static final char[] SPACE
-
SPACES_PATTERN
private static final java.util.regex.Pattern SPACES_PATTERN
-
INVALID_ANCHOR
private static final java.util.Set<java.lang.Character> INVALID_ANCHOR
-
ESCAPE_REPLACEMENTS
private static final java.util.Map<java.lang.Character,java.lang.String> ESCAPE_REPLACEMENTS
-
DEFAULT_TAG_PREFIXES
private static final java.util.Map<java.lang.String,java.lang.String> DEFAULT_TAG_PREFIXES
-
stream
private final java.io.Writer stream
-
states
private final ArrayStack<EmitterState> states
-
state
private EmitterState state
-
events
private final java.util.Queue<Event> events
-
event
private Event event
-
indents
private final ArrayStack<java.lang.Integer> indents
-
indent
private java.lang.Integer indent
-
flowLevel
private int flowLevel
-
rootContext
private boolean rootContext
-
mappingContext
private boolean mappingContext
-
simpleKeyContext
private boolean simpleKeyContext
-
column
private int column
-
whitespace
private boolean whitespace
-
indention
private boolean indention
-
openEnded
private boolean openEnded
-
canonical
private final java.lang.Boolean canonical
-
prettyFlow
private final java.lang.Boolean prettyFlow
-
allowUnicode
private final boolean allowUnicode
-
bestIndent
private int bestIndent
-
indicatorIndent
private final int indicatorIndent
-
indentWithIndicator
private final boolean indentWithIndicator
-
bestWidth
private int bestWidth
-
bestLineBreak
private final char[] bestLineBreak
-
splitLines
private final boolean splitLines
-
maxSimpleKeyLength
private final int maxSimpleKeyLength
-
emitComments
private final boolean emitComments
-
tagPrefixes
private java.util.Map<java.lang.String,java.lang.String> tagPrefixes
-
preparedAnchor
private java.lang.String preparedAnchor
-
preparedTag
private java.lang.String preparedTag
-
analysis
private ScalarAnalysis analysis
-
style
private DumperOptions.ScalarStyle style
-
blockCommentsCollector
private final CommentEventsCollector blockCommentsCollector
-
inlineCommentsCollector
private final CommentEventsCollector inlineCommentsCollector
-
HANDLE_FORMAT
private static final java.util.regex.Pattern HANDLE_FORMAT
-
LEADING_ZERO_PATTERN
private static final java.util.regex.Pattern LEADING_ZERO_PATTERN
-
-
Constructor Detail
-
Emitter
public Emitter(java.io.Writer stream, DumperOptions opts)Create- Parameters:
stream- - output to write toopts- - options
-
-
Method Detail
-
emit
public void emit(Event event) throws java.io.IOException
Description copied from interface:EmitablePush event to bytes
-
needMoreEvents
private boolean needMoreEvents()
-
needEvents
private boolean needEvents(java.util.Iterator<Event> iter, int count)
-
increaseIndent
private void increaseIndent(boolean flow, boolean indentless)
-
expectNode
private void expectNode(boolean root, boolean mapping, boolean simpleKey) throws java.io.IOException- Throws:
java.io.IOException
-
expectAlias
private void expectAlias() throws java.io.IOException- Throws:
java.io.IOException
-
expectScalar
private void expectScalar() throws java.io.IOException- Throws:
java.io.IOException
-
expectFlowSequence
private void expectFlowSequence() throws java.io.IOException- Throws:
java.io.IOException
-
expectFlowMapping
private void expectFlowMapping() throws java.io.IOException- Throws:
java.io.IOException
-
expectBlockSequence
private void expectBlockSequence() throws java.io.IOException- Throws:
java.io.IOException
-
expectBlockMapping
private void expectBlockMapping() throws java.io.IOException- Throws:
java.io.IOException
-
isFoldedOrLiteral
private boolean isFoldedOrLiteral(Event event)
-
checkEmptySequence
private boolean checkEmptySequence()
-
checkEmptyMapping
private boolean checkEmptyMapping()
-
checkEmptyDocument
private boolean checkEmptyDocument()
-
checkSimpleKey
private boolean checkSimpleKey()
-
processAnchor
private void processAnchor(java.lang.String indicator) throws java.io.IOException- Throws:
java.io.IOException
-
processTag
private void processTag() throws java.io.IOException- Throws:
java.io.IOException
-
chooseScalarStyle
private DumperOptions.ScalarStyle chooseScalarStyle()
-
processScalar
private void processScalar() throws java.io.IOException- Throws:
java.io.IOException
-
prepareVersion
private java.lang.String prepareVersion(DumperOptions.Version version)
-
prepareTagHandle
private java.lang.String prepareTagHandle(java.lang.String handle)
-
prepareTagPrefix
private java.lang.String prepareTagPrefix(java.lang.String prefix)
-
prepareTag
private java.lang.String prepareTag(java.lang.String tag)
-
prepareAnchor
static java.lang.String prepareAnchor(java.lang.String anchor)
-
analyzeScalar
private ScalarAnalysis analyzeScalar(java.lang.String scalar)
-
flushStream
void flushStream() throws java.io.IOException- Throws:
java.io.IOException
-
writeStreamStart
void writeStreamStart()
-
writeStreamEnd
void writeStreamEnd() throws java.io.IOException- Throws:
java.io.IOException
-
writeIndicator
void writeIndicator(java.lang.String indicator, boolean needWhitespace, boolean whitespace, boolean indentation) throws java.io.IOException- Throws:
java.io.IOException
-
writeIndent
void writeIndent() throws java.io.IOException- Throws:
java.io.IOException
-
writeWhitespace
private void writeWhitespace(int length) throws java.io.IOException- Throws:
java.io.IOException
-
writeLineBreak
private void writeLineBreak(java.lang.String data) throws java.io.IOException- Throws:
java.io.IOException
-
writeVersionDirective
void writeVersionDirective(java.lang.String versionText) throws java.io.IOException- Throws:
java.io.IOException
-
writeTagDirective
void writeTagDirective(java.lang.String handleText, java.lang.String prefixText) throws java.io.IOException- Throws:
java.io.IOException
-
writeSingleQuoted
private void writeSingleQuoted(java.lang.String text, boolean split) throws java.io.IOException- Throws:
java.io.IOException
-
writeDoubleQuoted
private void writeDoubleQuoted(java.lang.String text, boolean split) throws java.io.IOException- Throws:
java.io.IOException
-
writeCommentLines
private boolean writeCommentLines(java.util.List<CommentLine> commentLines) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBlockComment
private void writeBlockComment() throws java.io.IOException- Throws:
java.io.IOException
-
writeInlineComments
private boolean writeInlineComments() throws java.io.IOException- Throws:
java.io.IOException
-
determineBlockHints
private java.lang.String determineBlockHints(java.lang.String text)
-
writeFolded
void writeFolded(java.lang.String text, boolean split) throws java.io.IOException- Throws:
java.io.IOException
-
writeLiteral
void writeLiteral(java.lang.String text) throws java.io.IOException- Throws:
java.io.IOException
-
writePlain
void writePlain(java.lang.String text, boolean split) throws java.io.IOException- Throws:
java.io.IOException
-
-