01: package sisc.data;
02:
03: import java.io.IOException;
04: import java.io.InputStream;
05:
06: import sisc.io.InputPort;
07: import sisc.io.ValueWriter;
08:
09: /**
10: * A Scheme binary input port.
11: *
12: * Binary input ports are wrappers around Java's InputStreams.
13: */
14: public class SchemeBinaryInputPort extends Value implements InputPort,
15: NamedValue {
16:
17: protected InputStream in;
18:
19: public SchemeBinaryInputPort(InputStream out) {
20: this .in = out;
21: }
22:
23: public InputStream getInputStream() {
24: return in;
25: }
26:
27: public void display(ValueWriter w) throws IOException {
28: displayNamedOpaque(w, "binary-input-port");
29: }
30:
31: public void close() throws IOException {
32: in.close();
33: }
34:
35: public boolean ready() throws IOException {
36: return in.available() > 0;
37: }
38: }
39: /*
40: * The contents of this file are subject to the Mozilla Public
41: * License Version 1.1 (the "License"); you may not use this file
42: * except in compliance with the License. You may obtain a copy of
43: * the License at http://www.mozilla.org/MPL/
44: *
45: * Software distributed under the License is distributed on an "AS
46: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
47: * implied. See the License for the specific language governing
48: * rights and limitations under the License.
49: *
50: * The Original Code is the Second Interpreter of Scheme Code (SISC).
51: *
52: * The Initial Developer of the Original Code is Scott G. Miller.
53: * Portions created by Scott G. Miller are Copyright (C) 2000-2007
54: * Scott G. Miller. All Rights Reserved.
55: *
56: * Contributor(s):
57: * Matthias Radestock
58: *
59: * Alternatively, the contents of this file may be used under the
60: * terms of the GNU General Public License Version 2 or later (the
61: * "GPL"), in which case the provisions of the GPL are applicable
62: * instead of those above. If you wish to allow use of your
63: * version of this file only under the terms of the GPL and not to
64: * allow others to use your version of this file under the MPL,
65: * indicate your decision by deleting the provisions above and
66: * replace them with the notice and other provisions required by
67: * the GPL. If you do not delete the provisions above, a recipient
68: * may use your version of this file under either the MPL or the
69: * GPL.
70: */
|