1 /** 2 * Copyright (c) 2008-2011, 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 */ 16 17 package org.yaml.snakeyaml.scanner; 18 19 import org.yaml.snakeyaml.tokens.Token; 20 21 /** 22 * This interface represents an input stream of {@link Token Tokens}. 23 * <p> 24 * The parser and the scanner form together the 'Parse' step in the loading 25 * process (see chapter 3.1 of the <a href="http://yaml.org/spec/1.1/">YAML 26 * Specification</a>). 27 * </p> 28 * 29 * @see org.yaml.snakeyaml.tokens.Token 30 */ 31 public interface Scanner { 32 33 /** 34 * Check if the next token is one of the given types. 35 * 36 * @param choices 37 * token IDs. 38 * @return <code>true</code> if the next token can be assigned to a variable 39 * of at least one of the given types. Returns <code>false</code> if 40 * no more tokens are available. 41 * @throws ScannerException 42 * Thrown in case of malformed input. 43 */ 44 boolean checkToken(Token.ID... choices); 45 46 /** 47 * Return the next token, but do not delete it from the stream. 48 * 49 * @return The token that will be returned on the next call to 50 * {@link #getToken} 51 * @throws ScannerException 52 * Thrown in case of malformed input. 53 */ 54 Token peekToken(); 55 56 /** 57 * Returns the next token. 58 * <p> 59 * The token will be removed from the stream. 60 * </p> 61 * 62 * @throws ScannerException 63 * Thrown in case of malformed input. 64 */ 65 Token getToken(); 66 }