Top Description Inners Fields Constructors Methods
org.yaml.snakeyaml.scanner

public final Class ScannerImpl

extends Object
implements Scanner
Class Inheritance
All Implemented Interfaces
org.yaml.snakeyaml.scanner.Scanner
Imports
java.nio.ByteBuffer, java.nio.charset.CharacterCodingException, java.util.ArrayList, .HashMap, .Iterator, .LinkedHashMap, .List, .Map, java.util.regex.Pattern, org.yaml.snakeyaml.DumperOptions, .LoaderOptions, org.yaml.snakeyaml.comments.CommentType, org.yaml.snakeyaml.error.Mark, .YAMLException, org.yaml.snakeyaml.reader.StreamReader, org.yaml.snakeyaml.tokens.AliasToken, .AnchorToken, .BlockEndToken, .BlockEntryToken, .BlockMappingStartToken, .BlockSequenceStartToken, .CommentToken, .DirectiveToken, .DocumentEndToken, .DocumentStartToken, .FlowEntryToken, .FlowMappingEndToken, .FlowMappingStartToken, .FlowSequenceEndToken, .FlowSequenceStartToken, .KeyToken, .ScalarToken, .StreamEndToken, .StreamStartToken, .TagToken, .TagTuple, .Token, .ValueToken, org.yaml.snakeyaml.util.ArrayStack, .UriEncoder

Scanner produces tokens of the following types:
STREAM-START
STREAM-END
COMMENT
DIRECTIVE(name, value)
DOCUMENT-START
DOCUMENT-END
BLOCK-SEQUENCE-START
BLOCK-MAPPING-START
BLOCK-END
FLOW-SEQUENCE-START
FLOW-MAPPING-START
FLOW-SEQUENCE-END
FLOW-MAPPING-END
BLOCK-ENTRY
FLOW-ENTRY
KEY
VALUE
ALIAS(value)
ANCHOR(value)
TAG(value)
SCALAR(value, plain, style)
Read comments in the Scanner code for more details.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ScannerImpl.Chomping

Chomping the tail may have 3 values - yes, no, not defined.

Field Summary

Modifier and TypeField and Description
private boolean
allowSimpleKey

A simple key is a key that is not denoted by the '?' indicator.
private boolean
public static final Map<Character, Integer>
ESCAPE_CODES

A mapping from a character to a number of bytes to read-ahead for that escape sequence.

public static final Map<Character, String>
ESCAPE_REPLACEMENTS

A mapping from an escaped character in the input stream to the string representation that they should be replaced with.

private int
private int
private final ArrayStack<Integer>
private Token
private final LoaderOptions
private static final Pattern
NOT_HEXA

A regular expression matching characters which are not in the hexadecimal set (0-9, A-F, a-f).

private final boolean
private final Map<Integer, SimpleKey>
private final StreamReader
private final List<Token>
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
private boolean
addIndent(int column)

Check if we need to increase indentation.

private void
addToken(Token token)

private void
addToken(int index, Token token)

private boolean
private boolean
checkBlockEntry()

Returns true if the next thing on the reader is a block token.

private boolean
checkDirective()

Returns true if the next thing on the reader is a directive, given that the leading '%' has already been checked.

private boolean
checkDocumentEnd()

Returns true if the next thing on the reader is a document-end ("...").

private boolean
checkDocumentStart()

Returns true if the next thing on the reader is a document-start ("---").

private boolean
checkKey()

Returns true if the next thing on the reader is a key token.

private boolean
checkPlain()

Returns true if the next thing on the reader is a plain token.

public boolean
checkToken(Token.ID...
token IDs to match with
choices
)

Implements org.yaml.snakeyaml.scanner.Scanner.checkToken.

Check whether the next token is one of the given types.
private boolean
checkValue()

Returns true if the next thing on the reader is a value token.

private String
escapeChar(String chRepresentation)

This is implemented in CharConstants in SnakeYAML Engine

private void
fetchAlias()

Fetch an alias, which is a reference to an anchor.

private void
fetchAnchor()

Fetch an anchor.

private void
fetchBlockEntry()

Fetch an entry in the block style.

private void
fetchBlockScalar(char style)

Fetch a block scalar (literal or folded).

private void
fetchDirective()

Fetch a YAML directive.

private void
fetchDocumentEnd()

Fetch a document-end token ("...").

private void
fetchDocumentIndicator(boolean isDocumentStart)

Fetch a document indicator, either "---" for "document-start", or else "..." for "document-end.

private void
fetchDocumentStart()

Fetch a document-start token ("---").

private void
fetchDouble()

Fetch a double-quoted (") scalar.

private void
fetchFlowCollectionEnd(boolean isMappingEnd)

Fetch a flow-style collection end, which is either a sequence or a mapping.

private void
fetchFlowCollectionStart(boolean isMappingStart)

Fetch a flow-style collection start, which is either a sequence or a mapping.

private void
fetchFlowEntry()

Fetch an entry in the flow style.

private void
private void
private void
fetchFlowScalar(char style)

Fetch a flow scalar (single- or double-quoted).

private void
private void
private void
fetchFolded()

Fetch a folded scalar, denoted with a greater-than sign.

private void
fetchKey()

Fetch a key in a block-style mapping.

private void
fetchLiteral()

Fetch a literal scalar, denoted with a vertical-bar.

private void
fetchMoreTokens()

Fetch one or more tokens from the StreamReader.

private void
fetchPlain()

Fetch a plain scalar.

private void
fetchSingle()

Fetch a single-quoted (') scalar.

private void
private void
fetchStreamStart()

We always add STREAM-START as the first token and STREAM-END as the last token.

private void
fetchTag()

Fetch a tag.

private void
fetchValue()

Fetch a value in a block-style mapping.

public Token
getToken()

Implements org.yaml.snakeyaml.scanner.Scanner.getToken.

Return the next token, removing it from the queue.
private List<Token>
makeTokenList(Token... tokens)

private boolean
needMoreTokens()

Returns true if more tokens should be scanned.

private int
nextPossibleSimpleKey()

Return the number of the nearest possible simple key.

public Token
peekToken()

Implements org.yaml.snakeyaml.scanner.Scanner.peekToken.

Return the next token, but do not delete it from the queue.
private void
removePossibleSimpleKey()

Remove the saved possible key position at the current flow level.

public void
private void
savePossibleSimpleKey()

The next token may start a simple key.

private Token
scanAnchor(boolean isAnchor)

The YAML 1.1 specification does not restrict characters for anchors and
aliases.
private List<Token>
scanBlockScalar(char style)

private Object[]
private CommentToken
scanBlockScalarIgnoredLine(Mark startMark)

Scan to the end of the line after a block scalar has been scanned; the only things that are permitted at this time are comments and spaces.

private Object[]
scanBlockScalarIndentation()

Scans for the indentation of a block scalar implicitly.

private ScannerImpl.Chomping
scanBlockScalarIndicators(Mark startMark)

Scan a block scalar indicator.

private CommentToken
private List<Token>
private CommentToken
private String
scanDirectiveName(Mark startMark)

Scan a directive name.

private Token
scanFlowScalar(char style)

Scan a flow-style scalar.

private String
private String
scanFlowScalarNonSpaces(boolean doubleQuoted, Mark startMark)

Scan some number of flow-scalar non-space characters.

private String
private String
scanLineBreak()

Scan a line break, transforming:

'\r\n' : '\n'
'\r' : '\n'
'\n' : '\n'
'\x85' : '\n'
default : ''
private Token
scanPlain()

Scan a plain scalar.

private String
scanPlainSpaces()

See the specification for details.

private Token
scanTag()

Scan a Tag property.

private String

Returns:

scanned handle
scanTagDirectiveHandle
(Mark
- beginning of the handle
startMark
)

Scan a %TAG directive's handle.

private String
scanTagDirectivePrefix(Mark startMark)

Scan a %TAG directive's prefix.

private List<String>
scanTagDirectiveValue(Mark startMark)

Read a %TAG directive value:

s-ignored-space+ c-tag-handle s-ignored-space+ ns-tag-prefix s-l-comments
private String
scanTagHandle(String name, Mark startMark)

Scan a Tag handle.

private String
scanTagUri(String name, Mark startMark)

Scan a Tag URI.

private void
scanToNextToken()

We ignore spaces, line breaks and comments.
private String
scanUriEscapes(String name, Mark startMark)

Scan a sequence of %-escaped URI escape codes and convert them into a String representing the unescaped values.

private Integer
scanYamlDirectiveNumber(Mark startMark)

Read a %YAML directive number: this is either the major or the minor part.

private List<Integer>
private void
stalePossibleSimpleKeys()

Remove entries that are no longer possible simple keys.
private void
unwindIndent(int col)

* Handle implicitly ending multiple levels of block nodes by decreased indentation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowSimpleKeyback to summary
private boolean allowSimpleKey
A simple key is a key that is not denoted by the '?' indicator.
Example of simple keys:
  ---
  block simple key: value
  ? not a simple key:
  : { flow simple key: value }
We emit the KEY token before all keys, so when we find a potential
simple key, we try to locate the corresponding ':' indicator.
Simple keys should be limited to a single line and 1024 characters.

Can a simple key start at the current position? A simple key may
start:
- at the beginning of the line, not counting indentation spaces
      (in block context),
- after '{', '[', ',' (in the flow context),
- after '?', ':', '-' (in the block context).
In the block context, this flag also signifies if a block collection
may start at the current position.
doneback to summary
private boolean done
ESCAPE_CODESback to summary
public static final Map<Character, Integer> ESCAPE_CODES

A mapping from a character to a number of bytes to read-ahead for that escape sequence. These escape sequences are used to handle unicode escaping in the following formats, where H is a hexadecimal character:

\xHH         : escaped 8-bit Unicode character
\uHHHH       : escaped 16-bit Unicode character
\UHHHHHHHH   : escaped 32-bit Unicode character
See Also
5.6. Escape Sequences
ESCAPE_REPLACEMENTSback to summary
public static final Map<Character, String> ESCAPE_REPLACEMENTS

A mapping from an escaped character in the input stream to the string representation that they should be replaced with. YAML defines several common and a few uncommon escape sequences.

See Also
4.1.6. Escape Sequences
flowLevelback to summary
private int flowLevel
indentback to summary
private int indent
indentsback to summary
private final ArrayStack<Integer> indents
lastTokenback to summary
private Token lastToken
loaderOptionsback to summary
private final LoaderOptions loaderOptions
NOT_HEXAback to summary
private static final Pattern NOT_HEXA

A regular expression matching characters which are not in the hexadecimal set (0-9, A-F, a-f).

parseCommentsback to summary
private final boolean parseComments
possibleSimpleKeysback to summary
private final Map<Integer, SimpleKey> possibleSimpleKeys
readerback to summary
private final StreamReader reader
tokensback to summary
private final List<Token> tokens
tokensTakenback to summary
private int tokensTaken

Constructor Detail

ScannerImplback to summary
public ScannerImpl(StreamReader reader, LoaderOptions options)

Method Detail

addAllTokensback to summary
private void addAllTokens(List<Token> tokens)
addIndentback to summary
private boolean addIndent(int column)

Check if we need to increase indentation.

addTokenback to summary
private void addToken(Token token)
addTokenback to summary
private void addToken(int index, Token token)
atEndOfPlainback to summary
private boolean atEndOfPlain()
checkBlockEntryback to summary
private boolean checkBlockEntry()

Returns true if the next thing on the reader is a block token.

checkDirectiveback to summary
private boolean checkDirective()

Returns true if the next thing on the reader is a directive, given that the leading '%' has already been checked.

See Also
3.2.3.4. Directives
checkDocumentEndback to summary
private boolean checkDocumentEnd()

Returns true if the next thing on the reader is a document-end ("..."). A document-end is always followed immediately by a new line.

checkDocumentStartback to summary
private boolean checkDocumentStart()

Returns true if the next thing on the reader is a document-start ("---"). A document-start is always followed immediately by a new line.

checkKeyback to summary
private boolean checkKey()

Returns true if the next thing on the reader is a key token.

checkPlainback to summary
private boolean checkPlain()

Returns true if the next thing on the reader is a plain token.

checkTokenback to summary
public boolean checkToken(Token.ID... choices)

Implements org.yaml.snakeyaml.scanner.Scanner.checkToken.

Check whether the next token is one of the given types.

Parameters
choices:Token.ID[]

Doc from org.yaml.snakeyaml.scanner.Scanner.checkToken.

token IDs to match with

Returns:boolean

Doc from org.yaml.snakeyaml.scanner.Scanner.checkToken.

true if the next token is one of the given types. Returns false if no more tokens are available.

checkValueback to summary
private boolean checkValue()

Returns true if the next thing on the reader is a value token.

escapeCharback to summary
private String escapeChar(String chRepresentation)

This is implemented in CharConstants in SnakeYAML Engine

fetchAliasback to summary
private void fetchAlias()

Fetch an alias, which is a reference to an anchor. Aliases take the format:

*(anchor name)
See Also
3.2.2.2. Anchors and Aliases
fetchAnchorback to summary
private void fetchAnchor()

Fetch an anchor. Anchors take the form:

&(anchor name)
See Also
3.2.2.2. Anchors and Aliases
fetchBlockEntryback to summary
private void fetchBlockEntry()

Fetch an entry in the block style.

See Also
3.2.3.1. Node Styles
fetchBlockScalarback to summary
private void fetchBlockScalar(char style)

Fetch a block scalar (literal or folded).

See Also
3.2.3.1. Node Styles
fetchDirectiveback to summary
private void fetchDirective()

Fetch a YAML directive. Directives are presentation details that are interpreted as instructions to the processor. YAML defines two kinds of directives, YAML and TAG; all other types are reserved for future use.

See Also
3.2.3.4. Directives
fetchDocumentEndback to summary
private void fetchDocumentEnd()

Fetch a document-end token ("...").

fetchDocumentIndicatorback to summary
private void fetchDocumentIndicator(boolean isDocumentStart)

Fetch a document indicator, either "---" for "document-start", or else "..." for "document-end. The type is chosen by the given boolean.

fetchDocumentStartback to summary
private void fetchDocumentStart()

Fetch a document-start token ("---").

fetchDoubleback to summary
private void fetchDouble()

Fetch a double-quoted (") scalar.

fetchFlowCollectionEndback to summary
private void fetchFlowCollectionEnd(boolean isMappingEnd)

Fetch a flow-style collection end, which is either a sequence or a mapping. The type is determined by the given boolean. A flow-style collection is in a format similar to JSON. Sequences are started by '[' and ended by ']'; mappings are started by '{' and ended by '}'.

See Also
3.2.3.1. Node Styles
fetchFlowCollectionStartback to summary
private void fetchFlowCollectionStart(boolean isMappingStart)

Fetch a flow-style collection start, which is either a sequence or a mapping. The type is determined by the given boolean. A flow-style collection is in a format similar to JSON. Sequences are started by '[' and ended by ']'; mappings are started by '{' and ended by '}'.

See Also
3.2.3.1. Node Styles
fetchFlowEntryback to summary
private void fetchFlowEntry()

Fetch an entry in the flow style. Flow-style entries occur either immediately after the start of a collection, or else after a comma.

See Also
3.2.3.1. Node Styles
fetchFlowMappingEndback to summary
private void fetchFlowMappingEnd()
fetchFlowMappingStartback to summary
private void fetchFlowMappingStart()
fetchFlowScalarback to summary
private void fetchFlowScalar(char style)

Fetch a flow scalar (single- or double-quoted).

See Also
3.2.3.1. Node Styles
fetchFlowSequenceEndback to summary
private void fetchFlowSequenceEnd()
fetchFlowSequenceStartback to summary
private void fetchFlowSequenceStart()
fetchFoldedback to summary
private void fetchFolded()

Fetch a folded scalar, denoted with a greater-than sign. This is the type best used for long content, such as the text of a chapter or description.

See Also
3.2.3.1. Node Styles
fetchKeyback to summary
private void fetchKey()

Fetch a key in a block-style mapping.

See Also
3.2.3.1. Node Styles
fetchLiteralback to summary
private void fetchLiteral()

Fetch a literal scalar, denoted with a vertical-bar. This is the type best used for source code and other content, such as binary data, which must be included verbatim.

See Also
3.2.3.1. Node Styles
fetchMoreTokensback to summary
private void fetchMoreTokens()

Fetch one or more tokens from the StreamReader.

fetchPlainback to summary
private void fetchPlain()

Fetch a plain scalar.

fetchSingleback to summary
private void fetchSingle()

Fetch a single-quoted (') scalar.

fetchStreamEndback to summary
private void fetchStreamEnd()
fetchStreamStartback to summary
private void fetchStreamStart()

We always add STREAM-START as the first token and STREAM-END as the last token.

fetchTagback to summary
private void fetchTag()

Fetch a tag. Tags take a complex form.

See Also
3.2.1.2. Tags
fetchValueback to summary
private void fetchValue()

Fetch a value in a block-style mapping.

See Also
3.2.3.1. Node Styles
getTokenback to summary
public Token getToken()

Implements org.yaml.snakeyaml.scanner.Scanner.getToken.

Return the next token, removing it from the queue.

Returns:Token

Doc from org.yaml.snakeyaml.scanner.Scanner.getToken.

the coming token

makeTokenListback to summary
private List<Token> makeTokenList(Token... tokens)
needMoreTokensback to summary
private boolean needMoreTokens()

Returns true if more tokens should be scanned.

nextPossibleSimpleKeyback to summary
private int nextPossibleSimpleKey()

Return the number of the nearest possible simple key. Actually we don't need to loop through the whole dictionary.

peekTokenback to summary
public Token peekToken()

Implements org.yaml.snakeyaml.scanner.Scanner.peekToken.

Return the next token, but do not delete it from the queue.

Returns:Token

Doc from org.yaml.snakeyaml.scanner.Scanner.peekToken.

The token that will be returned on the next call to getToken

removePossibleSimpleKeyback to summary
private void removePossibleSimpleKey()

Remove the saved possible key position at the current flow level.

resetDocumentIndexback to summary
public void resetDocumentIndex()

Implements org.yaml.snakeyaml.scanner.Scanner.resetDocumentIndex.

Annotations
@Override
savePossibleSimpleKeyback to summary
private void savePossibleSimpleKey()

The next token may start a simple key. We check if it's possible and save its position. This function is called for ALIAS, ANCHOR, TAG, SCALAR(flow), '[', and '{'.

scanAnchorback to summary
private Token scanAnchor(boolean isAnchor)
The YAML 1.1 specification does not restrict characters for anchors and
aliases. This may lead to problems.
see https://bitbucket.org/snakeyaml/snakeyaml/issues/485/alias-names-are-too-permissive-compared-to
This implementation tries to follow https://github.com/yaml/yaml-spec/blob/master/rfc/RFC-0003.md
scanBlockScalarback to summary
private List<Token> scanBlockScalar(char style)
scanBlockScalarBreaksback to summary
private Object[] scanBlockScalarBreaks(int indent)
scanBlockScalarIgnoredLineback to summary
private CommentToken scanBlockScalarIgnoredLine(Mark startMark)

Scan to the end of the line after a block scalar has been scanned; the only things that are permitted at this time are comments and spaces.

scanBlockScalarIndentationback to summary
private Object[] scanBlockScalarIndentation()

Scans for the indentation of a block scalar implicitly. This mechanism is used only if the block did not explicitly state an indentation to be used.

See Also
9.2.2. Block Indentation Indicator
scanBlockScalarIndicatorsback to summary
private ScannerImpl.Chomping scanBlockScalarIndicators(Mark startMark)

Scan a block scalar indicator. The block scalar indicator includes two optional components, which may appear in either order. A block indentation indicator is a non-zero digit describing the indentation level of the block scalar to follow. This indentation is an additional number of spaces relative to the current indentation level. A block chomping indicator is a + or -, selecting the chomping mode away from the default (clip) to either -(strip) or +(keep).

See Also
5.3. Indicator Characters, 9.2.2. Block Indentation Indicator, 9.2.3. Block Chomping Indicator
scanCommentback to summary
private CommentToken scanComment(CommentType type)
scanDirectiveback to summary
private List<Token> scanDirective()
Annotations
@SuppressWarnings:unchecked, rawtypes
scanDirectiveIgnoredLineback to summary
private CommentToken scanDirectiveIgnoredLine(Mark startMark)
scanDirectiveNameback to summary
private String scanDirectiveName(Mark startMark)

Scan a directive name. Directive names are a series of non-space characters.

See Also
7.1. Directives
scanFlowScalarback to summary
private Token scanFlowScalar(char style)

Scan a flow-style scalar. Flow scalars are presented in one of two forms; first, a flow scalar may be a double-quoted string; second, a flow scalar may be a single-quoted string. style/syntax

See the specification for details.
Note that we loose indentation rules for quoted scalars. Quoted
scalars don't need to adhere indentation because " and ' clearly
mark the beginning and the end of them. Therefore we are less
restrictive then the specification requires. We only need to check
that document separators are not included in scalars.
     
See Also
9.1. Flow Scalar Styles
scanFlowScalarBreaksback to summary
private String scanFlowScalarBreaks(Mark startMark)
scanFlowScalarNonSpacesback to summary
private String scanFlowScalarNonSpaces(boolean doubleQuoted, Mark startMark)

Scan some number of flow-scalar non-space characters.

scanFlowScalarSpacesback to summary
private String scanFlowScalarSpaces(Mark startMark)
scanLineBreakback to summary
private String scanLineBreak()

Scan a line break, transforming:

'\r\n' : '\n'
'\r' : '\n'
'\n' : '\n'
'\x85' : '\n'
default : ''
scanPlainback to summary
private Token scanPlain()

Scan a plain scalar.

See the specification for details.
We add an additional restriction for the flow context:
  plain scalars in the flow context cannot contain ',', ':' and '?'.
We also keep track of the `allow_simple_key` flag here.
Indentation rules are loosed for the flow context.
scanPlainSpacesback to summary
private String scanPlainSpaces()

See the specification for details. SnakeYAML and libyaml allow tabs inside plain scalar

scanTagback to summary
private Token scanTag()

Scan a Tag property. A Tag property may be specified in one of three ways: c-verbatim-tag, c-ns-shorthand-tag, or c-ns-non-specific-tag

c-verbatim-tag takes the form !<ns-uri-char+> and must be delivered verbatim (as-is) to the application. In particular, verbatim tags are not subject to tag resolution.

c-ns-shorthand-tag is a valid tag handle followed by a non-empty suffix. If the tag handle is a c-primary-tag-handle ('!') then the suffix must have all exclamation marks properly URI-escaped (%21); otherwise, the string will look like a named tag handle: !foo!bar would be interpreted as (handle="!foo!", suffix="bar").

c-ns-non-specific-tag is always a lone '!'; this is only useful for plain scalars, where its specification means that the scalar MUST be resolved to have type tag:yaml.org,2002:str.

TODO SnakeYAML incorrectly ignores c-ns-non-specific-tag right now.
See Also
8.2. Node Tags TODO Note that this method does not enforce rules about local versus global tags!
scanTagDirectiveHandleback to summary
private String scanTagDirectiveHandle(Mark startMark)

Scan a %TAG directive's handle. This is YAML's c-tag-handle.

Parameters
startMark:Mark

- beginning of the handle

Returns:String

scanned handle

See Also
7.1.2.2. Tag Handles
scanTagDirectivePrefixback to summary
private String scanTagDirectivePrefix(Mark startMark)

Scan a %TAG directive's prefix. This is YAML's ns-tag-prefix.

See Also
scanTagDirectiveValueback to summary
private List<String> scanTagDirectiveValue(Mark startMark)

Read a %TAG directive value:

s-ignored-space+ c-tag-handle s-ignored-space+ ns-tag-prefix s-l-comments

See Also
7.1.2. “TAG” Directive
scanTagHandleback to summary
private String scanTagHandle(String name, Mark startMark)

Scan a Tag handle. A Tag handle takes one of three forms:

"!" (c-primary-tag-handle)
"!!" (ns-secondary-tag-handle)
"!(name)!" (c-named-tag-handle)
Where (name) must be formatted as an ns-word-char.

See the specification for details.
For some strange reasons, the specification does not allow '_' in
tag handles. I have allowed it anyway.
     
See Also
,
scanTagUriback to summary
private String scanTagUri(String name, Mark startMark)

Scan a Tag URI. This scanning is valid for both local and global tag directives, because both appear to be valid URIs as far as scanning is concerned. The difference may be distinguished later, in parsing. This method will scan for ns-uri-char*, which covers both cases.

This method performs no verification that the scanned URI conforms to any particular kind of URI specification.

See Also
scanToNextTokenback to summary
private void scanToNextToken()
We ignore spaces, line breaks and comments.
If we find a line break in the block context, we set the flag
`allow_simple_key` on.
The byte order mark is stripped if it's the first character in the
stream. We do not yet support BOM inside the stream as the
specification requires. Any such mark will be considered as a part
of the document.
TODO: We need to make tab handling rules more sane. A good rule is
  Tabs cannot precede tokens
  BLOCK-SEQUENCE-START, BLOCK-MAPPING-START, BLOCK-END,
  KEY(block), VALUE(block), BLOCK-ENTRY
So the checking code is
  if <TAB>:
      self.allow_simple_keys = False
We also need to add the check for `allow_simple_keys == True` to
`unwind_indent` before issuing BLOCK-END.
Scanners for block, flow, and plain scalars need to be modified.
scanUriEscapesback to summary
private String scanUriEscapes(String name, Mark startMark)

Scan a sequence of %-escaped URI escape codes and convert them into a String representing the unescaped values.

FIXME This method fails for more than 256 bytes' worth of URI-encoded characters in a row. Is this possible? Is this a use-case?
See Also
section 2.4, Escaped Encoding
scanYamlDirectiveNumberback to summary
private Integer scanYamlDirectiveNumber(Mark startMark)

Read a %YAML directive number: this is either the major or the minor part. Stop reading at a non-digit character (usually either '.' or '\n').

See Also
7.1.1. “YAML” Directive,
scanYamlDirectiveValueback to summary
private List<Integer> scanYamlDirectiveValue(Mark startMark)
stalePossibleSimpleKeysback to summary
private void stalePossibleSimpleKeys()
Remove entries that are no longer possible simple keys. According to
the YAML specification, simple keys
- should be limited to a single line,
- should be no longer than 1024 characters.
Disabling this procedure will allow simple keys of any length and
height (may cause problems if indentation is broken though).
unwindIndentback to summary
private void unwindIndent(int col)

* Handle implicitly ending multiple levels of block nodes by decreased indentation. This function becomes important on lines 4 and 7 of this example:

1) book one:
2)   part one:
3)     chapter one
4)   part two:
5)     chapter one
6)     chapter two
7) book two:
In flow context, tokens should respect indentation. Actually the condition should be `self.indent >= column` according to the spec. But this condition will prohibit intuitively correct constructions such as key : { }
org.yaml.snakeyaml.scanner back to summary

private Class ScannerImpl.Chomping

extends Object
Class Inheritance

Chomping the tail may have 3 values - yes, no, not defined.

Field Summary

Modifier and TypeField and Description
private final int
private final Boolean

Constructor Summary

AccessConstructor and Description
public
Chomping(Boolean value, int increment)

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
public int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

incrementback to summary
private final int increment
valueback to summary
private final Boolean value

Constructor Detail

Chompingback to summary
public Chomping(Boolean value, int increment)

Method Detail

chompTailIsNotFalseback to summary
public boolean chompTailIsNotFalse()
chompTailIsTrueback to summary
public boolean chompTailIsTrue()
getIncrementback to summary
public int getIncrement()