11adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov/**
211a89b445f3bde56bf07e6a0d04f0b0256dcb215Andrey Somov * Copyright (c) 2008, http://www.snakeyaml.org
31adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *
41adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * Licensed under the Apache License, Version 2.0 (the "License");
51adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * you may not use this file except in compliance with the License.
61adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * You may obtain a copy of the License at
71adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *
81adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *     http://www.apache.org/licenses/LICENSE-2.0
91adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov *
101adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * Unless required by applicable law or agreed to in writing, software
111adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * distributed under the License is distributed on an "AS IS" BASIS,
121adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * See the License for the specific language governing permissions and
141adf3a94fce500e0bda933e4b495a004d5789bd7Andrey Somov * limitations under the License.
159629be70863521bead138c295351f3dec926ab1Andrey Somov */
169629be70863521bead138c295351f3dec926ab1Andrey Somovpackage org.yaml.snakeyaml.scanner;
179629be70863521bead138c295351f3dec926ab1Andrey Somov
189629be70863521bead138c295351f3dec926ab1Andrey Somovimport org.yaml.snakeyaml.tokens.Token;
199629be70863521bead138c295351f3dec926ab1Andrey Somov
209629be70863521bead138c295351f3dec926ab1Andrey Somov/**
215276a6f69a288c609ad58a2d17423a862d44c9a5scm * This interface represents an input stream of {@link Token Tokens}.
225276a6f69a288c609ad58a2d17423a862d44c9a5scm * <p>
2337f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov * The parser and the scanner form together the 'Parse' step in the loading
2437f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov * process (see chapter 3.1 of the <a href="http://yaml.org/spec/1.1/">YAML
2537f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov * Specification</a>).
265276a6f69a288c609ad58a2d17423a862d44c9a5scm * </p>
2737f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov *
285276a6f69a288c609ad58a2d17423a862d44c9a5scm * @see org.yaml.snakeyaml.tokens.Token
299629be70863521bead138c295351f3dec926ab1Andrey Somov */
309629be70863521bead138c295351f3dec926ab1Andrey Somovpublic interface Scanner {
3137f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov
329629be70863521bead138c295351f3dec926ab1Andrey Somov    /**
339629be70863521bead138c295351f3dec926ab1Andrey Somov     * Check if the next token is one of the given types.
3437f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *
3537f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * @param choices
36b93bc9c91d27637fcc2125182de31c9dc9b772a7Andrey Somov     *            token IDs.
3737f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * @return <code>true</code> if the next token can be assigned to a variable
3837f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *         of at least one of the given types. Returns <code>false</code> if
3937f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *         no more tokens are available.
4037f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * @throws ScannerException
4137f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *             Thrown in case of malformed input.
429629be70863521bead138c295351f3dec926ab1Andrey Somov     */
433eef5308a918635c1ee1b576696eb4dd47b9448bAndrey Somov    boolean checkToken(Token.ID... choices);
449629be70863521bead138c295351f3dec926ab1Andrey Somov
459629be70863521bead138c295351f3dec926ab1Andrey Somov    /**
465276a6f69a288c609ad58a2d17423a862d44c9a5scm     * Return the next token, but do not delete it from the stream.
4737f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *
4837f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * @return The token that will be returned on the next call to
4937f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *         {@link #getToken}
5037f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * @throws ScannerException
5137f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *             Thrown in case of malformed input.
529629be70863521bead138c295351f3dec926ab1Andrey Somov     */
539629be70863521bead138c295351f3dec926ab1Andrey Somov    Token peekToken();
549629be70863521bead138c295351f3dec926ab1Andrey Somov
559629be70863521bead138c295351f3dec926ab1Andrey Somov    /**
565276a6f69a288c609ad58a2d17423a862d44c9a5scm     * Returns the next token.
5737f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * <p>
5837f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * The token will be removed from the stream.
5937f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * </p>
6037f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *
6137f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     * @throws ScannerException
6237f2f1c81f4a5be14db404db4e73f3dca6aa82f2Andrey Somov     *             Thrown in case of malformed input.
639629be70863521bead138c295351f3dec926ab1Andrey Somov     */
649629be70863521bead138c295351f3dec926ab1Andrey Somov    Token getToken();
659629be70863521bead138c295351f3dec926ab1Andrey Somov}
66