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.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | allowSimpleKey
A simple key is a key that is not denoted by the '?' indicator. |
| private static final String | |
| private boolean | |
| private static final String | |
| private int | |
| private int | |
| private final ArrayStack | |
| private Token | |
| 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 Map | |
| private final StreamReader | |
| private static final String | |
| private static final String | |
| private final LoadSettings | |
| private final List | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | ScannerImpl(StreamReader
- the input reader, LoadSettings - configurable options settings)
Deprecated
use the other constructor with LoadSettings first
|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private boolean | |
| private void | |
| private void | |
| private boolean | |
| private boolean | |
| 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 | |
| private boolean | |
| private boolean | |
| private boolean | |
| public boolean | checkToken(Token.
Overrides default org. Check whether the next token is the given type. |
| public boolean | checkToken(Token.
Implements org. Check whether the next token is one of the given types. |
| private boolean | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | fetchDocumentIndicator(boolean isDocumentStart)
Fetch a document indicator, either "---" for "document-start", or else "..." for "document-end. |
| private void | |
| private void | |
| private void | fetchFlowCollectionEnd(boolean isMappingEnd)
Fetch a flow-style collection end, which is either a sequence or a mapping. |
| private void | fetchFlowCollectionStart(boolean
- true for mapping, false for sequence isMappingStart)Fetch a flow-style collection start, which is either a sequence or a mapping. |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| public boolean | |
| private boolean | |
| private boolean | |
| private List | Returns: tokens to be used- token types tokens)Ignore Comment token if they are null, or Comments should not be parsed |
| private boolean | |
| public Token | next()
Implements org. Return the next token, removing it from the queue. |
| private int | |
| public Token | peekToken()
Implements org. Return the next token, but do not delete it from the queue. |
| private void | |
| public void | resetDocumentIndex()
Implements org. Set the document index to 0 after a document end |
| private void | |
| private Token | scanAnchor(boolean isAnchor)
The YAML 1.2 specification does not restrict characters for anchors and aliases. |
| private List | |
| private ScannerImpl. | |
| private CommentToken | scanBlockScalarIgnoredLine(Optional<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 ScannerImpl. | |
| private ScannerImpl. | |
| private CommentToken | |
| private List | |
| private CommentToken | |
| private String | |
| private Token | |
| private String | |
| private void | scanFlowScalarNonSpaces(boolean doubleQuoted, Optional<Mark> startMark, StringBuilder chunks)
Scan some number of flow-scalar non-space characters. |
| private void | |
| private Optional | Returns: transformed character or empty string if no line break detectedScan a line break, transforming: '\r\n' : '\n' '\r' : '\n' '\n' : '\n' '\x85' : '\n' default : '' |
| private Token | |
| private String | |
| private Token | |
| private String | Returns: the directive value- start startMark)Scan a %TAG directive's handle. |
| private String | |
| private List | scanTagDirectiveValue(Optional<Mark> startMark)
Read a %TAG directive value:
s-ignored-space+ c-tag-handle s-ignored-space+ ns-tag-prefix s-l-comments |
| private String | |
| private String | |
| private void | |
| private String | scanUriEscapes(String name, Optional<Mark> startMark)
Scan a sequence of %-escaped URI escape codes and convert them into a String representing the unescaped values. |
| private Integer | scanYamlDirectiveNumber(Optional<Mark> startMark)
Read a %YAML directive number: this is either the major or the minor part. |
| private List | |
| private void | |
| private void | unwindIndent(int col)
* Handle implicitly ending multiple levels of block nodes by decreased indentation. |
| allowSimpleKey | back 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.
| |
| DIRECTIVE_PREFIX | back to summary |
|---|---|
| private static final String DIRECTIVE_PREFIX | |
| done | back to summary |
|---|---|
| private boolean done | |
| EXPECTED_ALPHA_ERROR_PREFIX | back to summary |
|---|---|
| private static final String EXPECTED_ALPHA_ERROR_PREFIX | |
| flowLevel | back to summary |
|---|---|
| private int flowLevel | |
| indent | back to summary |
|---|---|
| private int indent | |
| indents | back to summary |
|---|---|
| private final ArrayStack<Integer> indents | |
| lastToken | back to summary |
|---|---|
| private Token lastToken | |
| NOT_HEXA | back 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). | |
| possibleSimpleKeys | back to summary |
|---|---|
| private final Map<Integer, SimpleKey> possibleSimpleKeys | |
| reader | back to summary |
|---|---|
| private final StreamReader reader | |
| SCANNING_PREFIX | back to summary |
|---|---|
| private static final String SCANNING_PREFIX | |
| SCANNING_SCALAR | back to summary |
|---|---|
| private static final String SCANNING_SCALAR | |
| settings | back to summary |
|---|---|
| private final LoadSettings settings | |
| tokens | back to summary |
|---|---|
| private final List<Token> tokens | |
| tokensTaken | back to summary |
|---|---|
| private int tokensTaken | |
| ScannerImpl | back to summary |
|---|---|
| public ScannerImpl(StreamReader reader, LoadSettings settings)
Deprecated use the other constructor with LoadSettings first
| |
| ScannerImpl | back to summary |
|---|---|
| public ScannerImpl(LoadSettings settings, StreamReader reader) Create
| |
| ScannerImpl | back to summary |
|---|---|
| public ScannerImpl(StreamReader reader)
Deprecated it should be used with LoadSettings
| |
| addAllTokens | back to summary |
|---|---|
| private void addAllTokens(List<Token> tokens) | |
| addIndent | back to summary |
|---|---|
| private boolean addIndent(int column) Check if we need to increase indentation. | |
| addToken | back to summary |
|---|---|
| private void addToken(Token token) | |
| addToken | back to summary |
|---|---|
| private void addToken(int index, Token token) | |
| atEndOfPlain | back to summary |
|---|---|
| private boolean atEndOfPlain() | |
| checkBlockEntry | back to summary |
|---|---|
| private boolean checkBlockEntry() Returns true if the next thing on the reader is a block token. | |
| checkDirective | back 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. | |
| checkDocumentEnd | back 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. | |
| checkDocumentStart | back 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. | |
| checkKey | back to summary |
|---|---|
| private boolean checkKey() Returns true if the next thing on the reader is a key token. This is different in SnakeYAML -> '?' may start a token in the flow context | |
| checkPlain | back to summary |
|---|---|
| private boolean checkPlain() Returns true if the next thing on the reader is a plain token. | |
| checkToken | back to summary |
|---|---|
| public boolean checkToken(Token. Overrides default org. Check whether the next token is the given type.
| |
| checkToken | back to summary |
|---|---|
| public boolean checkToken(Token. Implements org. Check whether the next token is one of the given types.
| |
| checkValue | back to summary |
|---|---|
| private boolean checkValue() Returns true if the next thing on the reader is a value token. | |
| fetchAlias | back to summary |
|---|---|
| private void fetchAlias() Fetch an alias, which is a reference to an anchor. Aliases take the format: *(anchor name) | |
| fetchAnchor | back to summary |
|---|---|
| private void fetchAnchor() Fetch an anchor. Anchors take the form: &(anchor name) | |
| fetchBlockEntry | back to summary |
|---|---|
| private void fetchBlockEntry() Fetch an entry in the block style. | |
| fetchBlockScalar | back to summary |
|---|---|
| private void fetchBlockScalar(ScalarStyle style) | |
| fetchDirective | back 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. | |
| fetchDocumentEnd | back to summary |
|---|---|
| private void fetchDocumentEnd() Fetch a document-end token ("..."). | |
| fetchDocumentIndicator | back 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. | |
| fetchDocumentStart | back to summary |
|---|---|
| private void fetchDocumentStart() Fetch a document-start token ("---"). | |
| fetchDouble | back to summary |
|---|---|
| private void fetchDouble() Fetch a double-quoted (") scalar. | |
| fetchFlowCollectionEnd | back 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 '}'. | |
| fetchFlowCollectionStart | back 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 '}'.
| |
| fetchFlowEntry | back 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. | |
| fetchFlowMappingEnd | back to summary |
|---|---|
| private void fetchFlowMappingEnd() | |
| fetchFlowMappingStart | back to summary |
|---|---|
| private void fetchFlowMappingStart() | |
| fetchFlowScalar | back to summary |
|---|---|
| private void fetchFlowScalar(ScalarStyle style) | |
| fetchFlowSequenceEnd | back to summary |
|---|---|
| private void fetchFlowSequenceEnd() | |
| fetchFlowSequenceStart | back to summary |
|---|---|
| private void fetchFlowSequenceStart() | |
| fetchFolded | back 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. | |
| fetchKey | back to summary |
|---|---|
| private void fetchKey() Fetch a key in a block-style mapping. | |
| fetchLiteral | back 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. | |
| fetchMoreTokens | back to summary |
|---|---|
| private void fetchMoreTokens() Fetch one or more tokens from the StreamReader. | |
| fetchPlain | back to summary |
|---|---|
| private void fetchPlain() Fetch a plain scalar. | |
| fetchSingle | back to summary |
|---|---|
| private void fetchSingle() Fetch a single-quoted (') scalar. | |
| fetchStreamEnd | back to summary |
|---|---|
| private void fetchStreamEnd() | |
| fetchStreamStart | back to summary |
|---|---|
| private void fetchStreamStart() We always add STREAM-START as the first token and STREAM-END as the last token. | |
| fetchTag | back to summary |
|---|---|
| private void fetchTag() Fetch a tag. Tags take a complex form. | |
| fetchValue | back to summary |
|---|---|
| private void fetchValue() Fetch a value in a block-style mapping. | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| isBlockContext | back to summary |
|---|---|
| private boolean isBlockContext() | |
| isFlowContext | back to summary |
|---|---|
| private boolean isFlowContext() | |
| makeTokenList | back to summary |
|---|---|
| private List Ignore Comment token if they are null, or Comments should not be parsed | |
| needMoreTokens | back to summary |
|---|---|
| private boolean needMoreTokens() Returns true if more tokens should be scanned. | |
| next | back to summary |
|---|---|
| public Token next() Implements org. Return the next token, removing it from the queue. | |
| nextPossibleSimpleKey | back 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. | |
| peekToken | back to summary |
|---|---|
| public Token peekToken() Implements org. Return the next token, but do not delete it from the queue. | |
| removePossibleSimpleKey | back to summary |
|---|---|
| private void removePossibleSimpleKey() Remove the saved possible key position at the current flow level. | |
| resetDocumentIndex | back to summary |
|---|---|
| public void resetDocumentIndex() Implements org. Doc from org. Set the document index to 0 after a document end
| |
| savePossibleSimpleKey | back 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 '{'. | |
| scanAnchor | back to summary |
|---|---|
private Token scanAnchor(boolean isAnchor)The YAML 1.2 specification does not restrict characters for anchors and aliases. This may lead to problems. See alias naming See also issue 485 | |
| scanBlockScalar | back to summary |
|---|---|
| private List | |
| scanBlockScalarBreaks | back to summary |
|---|---|
| private ScannerImpl. | |
| scanBlockScalarIgnoredLine | back to summary |
|---|---|
| private CommentToken scanBlockScalarIgnoredLine(Optional<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. | |
| scanBlockScalarIndentation | back to summary |
|---|---|
| private ScannerImpl. 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. | |
| scanBlockScalarIndicators | back to summary |
|---|---|
| private ScannerImpl. 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). | |
| scanComment | back to summary |
|---|---|
| private CommentToken scanComment(CommentType type) | |
| scanDirective | back to summary |
|---|---|
private List
| |
| scanDirectiveIgnoredLine | back to summary |
|---|---|
| private CommentToken scanDirectiveIgnoredLine(Optional<Mark> startMark) | |
| scanDirectiveName | back to summary |
|---|---|
| private String scanDirectiveName(Optional<Mark> startMark) Scan a directive name. Directive names are a series of non-space characters. | |
| scanFlowScalar | back to summary |
|---|---|
| private Token scanFlowScalar(final ScalarStyle 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. 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. | |
| scanFlowScalarBreaks | back to summary |
|---|---|
| private String scanFlowScalarBreaks(Optional<Mark> startMark) | |
| scanFlowScalarNonSpaces | back to summary |
|---|---|
| private void scanFlowScalarNonSpaces(boolean doubleQuoted, Optional<Mark> startMark, StringBuilder chunks) Scan some number of flow-scalar non-space characters. | |
| scanFlowScalarSpaces | back to summary |
|---|---|
| private void scanFlowScalarSpaces(Optional<Mark> startMark, StringBuilder chunks) | |
| scanLineBreak | back to summary |
|---|---|
| private Optional Scan a line break, transforming: '\r\n' : '\n' '\r' : '\n' '\n' : '\n' '\x85' : '\n' default : '' | |
| scanPlain | back 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. | |
| scanPlainSpaces | back to summary |
|---|---|
| private String scanPlainSpaces() See the specification for details. SnakeYAML and libyaml allow tabs inside plain scalar | |
| scanTag | back 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 !
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 Note that this method does not enforce rules about local versus global tags!
| |
| scanTagDirectiveHandle | back to summary |
|---|---|
| private String scanTagDirectiveHandle(Optional<Mark> startMark) Scan a %TAG directive's handle. This is YAML's c-tag-handle. | |
| scanTagDirectivePrefix | back to summary |
|---|---|
| private String scanTagDirectivePrefix(Optional<Mark> startMark) Scan a %TAG directive's prefix. This is YAML's ns-tag-prefix. | |
| scanTagDirectiveValue | back to summary |
|---|---|
| private List Read a %TAG directive value:
s-ignored-space+ c-tag-handle s-ignored-space+ ns-tag-prefix s-l-comments
| |
| scanTagHandle | back to summary |
|---|---|
| private String scanTagHandle(String name, Optional<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. | |
| scanTagUri | back to summary |
|---|---|
| private String scanTagUri(String name, CharConstants range, Optional<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. | |
| scanToNextToken | back 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. | |
| scanUriEscapes | back to summary |
|---|---|
| private String scanUriEscapes(String name, Optional<Mark> startMark) Scan a sequence of %-escaped URI escape codes and convert them into a String representing the unescaped values. This method fails for more than 256 bytes' worth of URI-encoded characters in a row. Is this possible? Is this a use-case? | |
| scanYamlDirectiveNumber | back to summary |
|---|---|
| private Integer scanYamlDirectiveNumber(Optional<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'). | |
| scanYamlDirectiveValue | back to summary |
|---|---|
| private List | |
| stalePossibleSimpleKeys | back 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). | |
| unwindIndent | back 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 : { }' | |
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final Optional | |
| private final int |
| Access | Constructor and Description |
|---|---|
| public |
| breaks | back to summary |
|---|---|
| private final String breaks | |
| endMark | back to summary |
|---|---|
| private final Optional<Mark> endMark | |
| maxIndent | back to summary |
|---|---|
| private final int maxIndent | |
| BreakIntentHolder | back to summary |
|---|---|
| public BreakIntentHolder(String breaks, int maxIndent, Optional<Mark> endMark) | |
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static enum |
| Modifier and Type | Field and Description |
|---|---|
| private final Optional | |
| private final ScannerImpl. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static ScannerImpl. |
| increment | back to summary |
|---|---|
| private final Optional<Integer> increment | |
| value | back to summary |
|---|---|
| private final ScannerImpl. | |
| Chomping | back to summary |
|---|---|
| public Chomping(ScannerImpl. | |
| Chomping | back to summary |
|---|---|
| public Chomping(int indicatorCodePoint, Optional<Integer> increment) | |
| parse | back to summary |
|---|---|
| private static ScannerImpl. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final ScannerImpl. | |
| public static final ScannerImpl. | |
| public static final ScannerImpl. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static ScannerImpl. | |
| public static ScannerImpl. |
| CLIP | back to summary |
|---|---|
| public static final ScannerImpl. | |
| KEEP | back to summary |
|---|---|
| public static final ScannerImpl. | |
| STRIP | back to summary |
|---|---|
| public static final ScannerImpl. | |
| Indicator | back to summary |
|---|---|
| private Indicator() | |
| valueOf | back to summary |
|---|---|
| public static ScannerImpl. | |
| values | back to summary |
|---|---|
| public static ScannerImpl. | |