01: /*
02: * EofCmd.java --
03: *
04: * Copyright (c) 1997 Sun Microsystems, Inc.
05: *
06: * See the file "license.terms" for information on usage and
07: * redistribution of this file, and for a DISCLAIMER OF ALL
08: * WARRANTIES.
09: *
10: * RCS: @(#) $Id: EofCmd.java,v 1.2 2005/10/07 06:50:09 mdejong Exp $
11: *
12: */
13:
14: package tcl.lang;
15:
16: import java.util.*;
17:
18: /**
19: * This class implements the built-in "eof" command in Tcl.
20: */
21:
22: class EofCmd implements Command {
23: /**
24: * This procedure is invoked to process the "eof" Tcl command.
25: * See the user documentation for details on what it does.
26: *
27: * @param interp the current interpreter.
28: * @param argv command arguments.
29: */
30:
31: public void cmdProc(Interp interp, TclObject argv[])
32: throws TclException {
33:
34: Channel chan; /* The channel being operated on this method */
35:
36: if (argv.length != 2) {
37: throw new TclNumArgsException(interp, 1, argv, "channelId");
38: }
39:
40: chan = TclIO.getChannel(interp, argv[1].toString());
41: if (chan == null) {
42: throw new TclException(interp,
43: "can not find channel named \""
44: + argv[1].toString() + "\"");
45: }
46:
47: if (chan.eof()) {
48: interp.setResult(true);
49: } else {
50: interp.setResult(false);
51: }
52: }
53: }
|