01: /*
02: * @(#)dataInput.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.io;
10:
11: import java.io.InputStream;
12: import java.io.DataInputStream;
13: import pnuts.lang.Context;
14: import pnuts.lang.PnutsFunction;
15:
16: public class dataInput extends PnutsFunction {
17:
18: public dataInput() {
19: super ("dataInput");
20: }
21:
22: public boolean defined(int narg) {
23: return (narg == 1);
24: }
25:
26: protected Object exec(Object[] args, Context context) {
27: if (args.length == 1) {
28: return new DataInputStream((InputStream) args[0]);
29: } else {
30: undefined(args, context);
31: return null;
32: }
33: }
34:
35: public String toString() {
36: return "function dataInput(InputStream)";
37: }
38: }
|