View Javadoc

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