View Javadoc

1   package net.sf.tomp.xtcl.command;
2   
3   import net.sf.tomp.xtcl.Context;
4   
5   import java.io.PrintStream;
6   
7   /***
8    * Prints a String to Context's stdout
9    * 
10   * @author tomp
11   */
12  public class Echo extends AbstractCommand {
13  	
14      /*** String to be printed */
15      protected String echo;
16  
17      /***
18       * Sets the String to be echoed.
19       * 
20       * @param c DOCUMENT ME!
21       */
22      public void setEcho(String c) {
23          echo = c;
24      }
25  
26      /***
27       * Echo the String echo
28       * @see net.sf.tomp.xtcl.Command#execute(net.sf.tomp.xtcl.Context)
29       */
30      public int execute(Context c) throws Exception {
31          PrintStream out = c.getOut();
32  
33          if (out != null) {
34              out.println(echo);
35          }
36  
37          return done(c, 0);
38      }
39  
40      /***
41       * 
42       * @return "ECHO " + echo;
43       */
44      public String toString() {
45          return "ECHO " + echo;
46      }
47  }
48  
49  /*
50   * The contents of this file are subject to the Mozilla Public License Version
51   * 1.1 (the "License"); you may not use this file except in compliance with the
52   * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
53   * Software distributed under the License is distributed on an "AS IS" basis,
54   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
55   * the specific language governing rights and limitations under the License. The
56   * Original Code is: all this file. The Initial Developer of the Original Code
57   * is: Tomas Pitner, Masaryk University in Brno, Czech Republic. Contributor(s):
58   */