Class ScannerImpl

java.lang.Object
org.snakeyaml.engine.v2.scanner.ScannerImpl
All Implemented Interfaces:
Iterator<Token>, Scanner

public final class ScannerImpl extends Object implements Scanner
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.
  • Constructor Details

    • ScannerImpl

      @Deprecated public ScannerImpl(StreamReader reader, LoadSettings settings)
      Deprecated.
      use the other constructor with LoadSettings first
      Parameters:
      reader - - the input
      settings - - configurable options
    • ScannerImpl

      public ScannerImpl(LoadSettings settings, StreamReader reader)
      Create
      Parameters:
      settings - - configurable options
      reader - - the input
    • ScannerImpl

      @Deprecated public ScannerImpl(StreamReader reader)
      Deprecated.
      it should be used with LoadSettings
      Parameters:
      reader - - the input
  • Method Details

    • checkToken

      public boolean checkToken(Token.ID... choices)
      Check whether the next token is one of the given types.
      Specified by:
      checkToken in interface Scanner
      Parameters:
      choices - token IDs to match with
      Returns:
      true if the next token is one of the given types. Returns false if no more tokens are available.
    • peekToken

      public Token peekToken()
      Return the next token, but do not delete it from the queue.
      Specified by:
      peekToken in interface Scanner
      Returns:
      The token that will be returned on the next call to Scanner.next()
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Token>
    • next

      public Token next()
      Return the next token, removing it from the queue.
      Specified by:
      next in interface Iterator<Token>
      Specified by:
      next in interface Scanner
      Returns:
      the coming token
    • resetDocumentIndex

      public void resetDocumentIndex()
      Description copied from interface: Scanner
      Set the document index to 0 after a document end
      Specified by:
      resetDocumentIndex in interface Scanner