01: /*
02: * TokenizerSource.java: Data source for the Tokenizer.
03: *
04: * Copyright (C) 2001 Heiko Blau
05: *
06: * This file belongs to the JTopas Library.
07: * JTopas is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as published by the
09: * 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: // Interface TokenizerSource
35: //
36:
37: /**<p>
38: * This interface describes the data source for a {@link Tokenizer}. It is a
39: * simplification of the {@link java.io.Reader} class (<code>java.io.Reader</code>).
40: *</p>
41: *
42: * @see Tokenizer
43: * @author Heiko Blau
44: */
45: public interface TokenizerSource {
46:
47: /**
48: * A basic method to supply character data for a {@link Tokenizer}. Note that
49: * the more complicated operations of buffering, skipping etc. are done by
50: * the <code>Tokenizer</code> implementation using this data source. An implementation
51: * of this interface should therefore avoid caching data itself. Otherwise,
52: * storing data is done twice wasting memory.
53: *<br>
54: * In correspondence to the methods in {@link java.io.Reader} this method
55: * returns -1 on end-of-file (EOF).
56: *
57: * @param cbuf buffer to receive data
58: * @param offset position from where the data should be inserted in <code>cbuf</code>
59: * @param maxChars maximum number of characters to be read into <code>cbuf</code>
60: * @return actually read characters or -1 on an end-of-file condition
61: * @throws Exception anything that could happen during read, most likely {@link java.io.IOException}
62: */
63: int read(char[] cbuf, int offset, int maxChars) throws Exception;
64: }
|