1 /**
2 * AUTOHIT 2003
3 * Copyright Erich P Gatejen (c) 1989,1997,2003,2004
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Additional license information can be found in the documentation.
19 * @author Erich P Gatejen
20 */
21 package autohit.call;
22
23 import autohit.common.Constants;
24 import autohit.universe.Universe;
25
26 /**
27 * CALL. REMOVE_TABLE Remove a table in persist.
28 * <pre>
29 * REQURIES: logger, core
30 * IGNORES: uni
31 * PARAMETERS (INPUT):
32 * name= table name
33 * </pre>
34 * RETURNS: defined by the method, but will always be a String.
35 *
36 * @author Erich P. Gatejen
37 * @version 1.0
38 * <i>Version History</i>
39 * <code>EPG - Initial - 30Jun03</code>
40 */
41 public class Call_REMOVE_TABLE extends Call {
42
43 /**
44 * Implement this to handle load time initialization. The
45 * four main fields will already be set--vmc, sc, log, and u.
46 * You must implement this, but you don't have to do anything.
47 * Remember that calls are cached per VM and reused as often
48 * as possible. There will be no thread-safety issues with the
49 * VMCore or log, but the SystemContecxt and Universe may be shared.
50 * @throws CallException
51 */
52 public void load_chain() throws CallException {
53 // Nothing to do.
54 }
55
56 /**
57 * Implement this to return the name of the CALL
58 * @return name of the CALL
59 */
60 public String name() {
61 return "REMOVE_TABLE";
62 }
63
64 /**
65 * Execute it.
66 * @return the result or null if there is no result
67 */
68 public String call() throws CallException {
69
70 String name;
71
72 try {
73
74 // see if the parameter is passed
75 name = this.requiredString("name");
76
77 if (vmc.has(name)) {
78 vmc.free(name);
79 this.debug("Removed a table named=" + name);
80 } else {
81 this.debug(
82 "Table "
83 + name
84 + " not in persist. Obviously, I cannot remove it.");
85 }
86
87 } catch (CallException ce) {
88 throw ce;
89 } catch (Exception e) {
90 throw new CallException(
91 this.format(
92 "Exception while removing table. error=" + e.getMessage()),
93 CallException.CODE_CALL_ERROR,
94 e);
95 }
96 return Constants.EMPTY_LEFT;
97 }
98
99 /**
100 * Execute using the passed universe, rather than the loaded.
101 * @param uni a universe
102 * @return the result or null if there is no result
103 * @see autohit.universe.Universe
104 */
105 public String call(Universe uni) throws CallException {
106 return this.call();
107 }
108 }
|