01: /*
02: * @(#)dataOutput.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.OutputStream;
12: import java.io.DataOutputStream;
13: import pnuts.lang.Context;
14: import pnuts.lang.PnutsFunction;
15:
16: public class dataOutput extends PnutsFunction {
17:
18: public dataOutput() {
19: super ("dataOutput");
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 DataOutputStream((OutputStream) args[0]);
29: } else {
30: undefined(args, context);
31: return null;
32: }
33: }
34:
35: public String toString() {
36: return "function dataOutput(OutputStream)";
37: }
38: }
|