View Javadoc

1   package net.sf.tomp.xtcl.command;
2   
3   import net.sf.tomp.xtcl.Context;
4   
5   /***
6    * Copies src var to var (shallow copy). 
7    * 
8    * @author tomp
9    */
10  public class SetCommand extends VarCommand {
11  	
12      /*** src var name */
13      protected String srcVar;
14  
15      /***
16       * set src var name
17       * 
18       * @param r src var name
19       */
20      public void setSrcVar(String r) {
21          srcVar = r;
22      }
23  
24      /***
25       * Copies src var to var (shallow copy).
26       * 
27       */
28      public int execute(Context context) throws Exception {
29          Object src = context.get(srcVar);
30  
31          context.put(var, src);
32  
33          return done(context, ((src == null) ? 1 : 0));
34      }
35  
36      /***
37       * DOCUMENT ME!
38       * 
39       * @return DOCUMENT ME!
40       */
41      public String toString() {
42          return "SET " + var + "=" + srcVar;
43      }
44  }
45  
46  /*
47   * The contents of this file are subject to the Mozilla Public License Version
48   * 1.1 (the "License"); you may not use this file except in compliance with the
49   * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
50   * Software distributed under the License is distributed on an "AS IS" basis,
51   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
52   * the specific language governing rights and limitations under the License. The
53   * Original Code is: all this file. The Initial Developer of the Original Code
54   * is: Tomas Pitner, Masaryk University in Brno, Czech Republic. Contributor(s):
55   */