01: /*
02: * @(#)flush.java 1.2 04/12/06
03: *
04: * Copyright (c) 2003,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.lib;
10:
11: import pnuts.lang.*;
12: import java.io.*;
13:
14: public class flush extends PnutsFunction {
15:
16: public flush() {
17: super ("flush");
18: }
19:
20: public boolean defined(int narg) {
21: return narg == 0;
22: }
23:
24: public Object exec(Object[] args, Context context) {
25: PrintWriter output = context.getWriter();
26: if (output == null) {
27: return null;
28: }
29: if (args.length == 0) {
30: output.flush();
31: } else {
32: undefined(args, context);
33: }
34: return null;
35: }
36:
37: public String toString() {
38: return "function flush()";
39: }
40: }
|