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.parser; 18 19 import org.yaml.snakeyaml.events.Event; 20 21 /** 22 * This interface represents an input stream of {@link Event Events}. 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.events.Event 30 */ 31 public interface Parser { 32 33 /** 34 * Check if the next event is one of the given type. 35 * 36 * @param choice 37 * Event ID. 38 * @return <code>true</code> if the next event can be assigned to a variable 39 * of the given type. Returns <code>false</code> if no more events 40 * are available. 41 * @throws ParserException 42 * Thrown in case of malformed input. 43 */ 44 public boolean checkEvent(Event.ID choice); 45 46 /** 47 * Return the next event, but do not delete it from the stream. 48 * 49 * @return The event that will be returned on the next call to 50 * {@link #getEvent} 51 * @throws ParserException 52 * Thrown in case of malformed input. 53 */ 54 public Event peekEvent(); 55 56 /** 57 * Returns the next event. 58 * <p> 59 * The event will be removed from the stream. 60 * </p> 61 * 62 * @throws ParserException 63 * Thrown in case of malformed input. 64 */ 65 public Event getEvent(); 66 }