Class ScannerImpl

  • All Implemented Interfaces:
    Scanner

    public final class ScannerImpl
    extends java.lang.Object
    implements Scanner
     Scanner produces tokens of the following types:
     STREAM-START
     STREAM-END
     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.
     
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Map<java.lang.Character,​java.lang.Integer> ESCAPE_CODES
      A mapping from a character to a number of bytes to read-ahead for that escape sequence.
      static java.util.Map<java.lang.Character,​java.lang.String> ESCAPE_REPLACEMENTS
      A mapping from an escaped character in the input stream to the character that they should be replaced with.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkToken​(Token.ID... choices)
      Check whether the next token is one of the given types.
      Token getToken()
      Return the next token, removing it from the queue.
      Token peekToken()
      Return the next token, but do not delete it from the queue.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ESCAPE_REPLACEMENTS

        public static final java.util.Map<java.lang.Character,​java.lang.String> ESCAPE_REPLACEMENTS
        A mapping from an escaped character in the input stream to the character that they should be replaced with. YAML defines several common and a few uncommon escape sequences.
        See Also:
        4.1.6. Escape Sequences
      • ESCAPE_CODES

        public static final java.util.Map<java.lang.Character,​java.lang.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
    • Constructor Detail

    • Method Detail

      • 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.
        Returns:
        true if the next token can be assigned to a variable of at least 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.getToken()
      • getToken

        public Token getToken()
        Return the next token, removing it from the queue.
        Specified by:
        getToken in interface Scanner
        Returns:
        the coming token