1/**
2 * Copyright (c) 2008, http://www.snakeyaml.org
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.yaml.snakeyaml.scanner;
17
18import org.yaml.snakeyaml.tokens.Token;
19
20/**
21 * This interface represents an input stream of {@link Token Tokens}.
22 * <p>
23 * The parser and the scanner form together the 'Parse' step in the loading
24 * process (see chapter 3.1 of the <a href="http://yaml.org/spec/1.1/">YAML
25 * Specification</a>).
26 * </p>
27 *
28 * @see org.yaml.snakeyaml.tokens.Token
29 */
30public interface Scanner {
31
32    /**
33     * Check if the next token is one of the given types.
34     *
35     * @param choices
36     *            token IDs.
37     * @return <code>true</code> if the next token can be assigned to a variable
38     *         of at least one of the given types. Returns <code>false</code> if
39     *         no more tokens are available.
40     * @throws ScannerException
41     *             Thrown in case of malformed input.
42     */
43    boolean checkToken(Token.ID... choices);
44
45    /**
46     * Return the next token, but do not delete it from the stream.
47     *
48     * @return The token that will be returned on the next call to
49     *         {@link #getToken}
50     * @throws ScannerException
51     *             Thrown in case of malformed input.
52     */
53    Token peekToken();
54
55    /**
56     * Returns the next token.
57     * <p>
58     * The token will be removed from the stream.
59     * </p>
60     *
61     * @throws ScannerException
62     *             Thrown in case of malformed input.
63     */
64    Token getToken();
65}
66