1 /* 2 * Copyright 2006 Simon Raess 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 package net.sf.beep4j.internal; 17 18 import java.nio.ByteBuffer; 19 20 /** 21 * A state in the process of parsing an incoming stream of ByteBuffers. 22 * 23 * @author Simon Raess 24 */ 25 interface ParseState { 26 27 /** 28 * Processes the passed in ByteBuffer. The context object is used 29 * to report important events back to the context. If the buffer 30 * is not processed fully, the method returns true. Otherwise, 31 * the method returns false. 32 * 33 * @param buffer the ByteBuffer to process 34 * @param context the context of the state 35 * @return true iff there are more bytes to be processed in the buffer 36 */ 37 boolean process(ByteBuffer buffer, ParseStateContext context); 38 39 }