1 /* 2 * TokenizerSource.java: Data source for the Tokenizer. 3 * 4 * Copyright (C) 2001 Heiko Blau 5 * 6 * This file belongs to the JTopas Library. 7 * JTopas is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU Lesser General Public License as published by the 9 * Free Software Foundation; either version 2.1 of the License, or (at your 10 * option) any later version. 11 * 12 * This software is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. 15 * See the GNU Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License along 18 * with JTopas. If not, write to the 19 * 20 * Free Software Foundation, Inc. 21 * 59 Temple Place, Suite 330, 22 * Boston, MA 02111-1307 23 * USA 24 * 25 * or check the Internet: http://www.fsf.org 26 * 27 * Contact: 28 * email: heiko@susebox.de 29 */ 30 31 package de.susebox.jtopas; 32 33 34 //----------------------------------------------------------------------------- 35 // Interface TokenizerSource 36 // 37 38 /**<p> 39 * This interface describes the data source for a {@link Tokenizer}. It is a 40 * simplification of the {@link java.io.Reader} class (<code>java.io.Reader</code>). 41 *</p> 42 * 43 * @see Tokenizer 44 * @author Heiko Blau 45 */ 46 public interface TokenizerSource { 47 48 /** 49 * A basic method to supply character data for a {@link Tokenizer}. Note that 50 * the more complicated operations of buffering, skipping etc. are done by 51 * the <code>Tokenizer</code> implementation using this data source. An implementation 52 * of this interface should therefore avoid caching data itself. Otherwise, 53 * storing data is done twice wasting memory. 54 *<br> 55 * In correspondence to the methods in {@link java.io.Reader} this method 56 * returns -1 on end-of-file (EOF). 57 * 58 * @param cbuf buffer to receive data 59 * @param offset position from where the data should be inserted in <code>cbuf</code> 60 * @param maxChars maximum number of characters to be read into <code>cbuf</code> 61 * @return actually read characters or -1 on an end-of-file condition 62 * @throws Exception anything that could happen during read, most likely {@link java.io.IOException} 63 */ 64 int read(char[] cbuf, int offset, int maxChars) throws Exception; 65 } 66