KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > console > text > commands > dbadmin > DebugMode


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright 2005-2006 Continuent, Inc.
4  * Contact: sequoia@continuent.org
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Initial developer(s): Jeff Mesnil.
19  * Contributor(s): ______________________.
20  */

21
22 package org.continuent.sequoia.console.text.commands.dbadmin;
23
24 import org.continuent.sequoia.common.i18n.ConsoleTranslate;
25 import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
26
27 /**
28  * This class defines the command used to switch to <em>debug mode</em> (i.e.
29  * debug commands are available).
30  *
31  * @author <a HREF="mailto:jeff.mesnil@emicnetworks.com">Jeff Mesnil</a>
32  * @version 1.0
33  */

34 public class DebugMode extends AbstractAdminCommand
35 {
36
37   private static final String JavaDoc ON = "on"; //$NON-NLS-1$
38
private static final String JavaDoc OFF = "off"; //$NON-NLS-1$
39

40   /**
41    * Creates a new <code>DebugMode</code> object
42    *
43    * @param module module that owns this commands
44    */

45   public DebugMode(VirtualDatabaseAdmin module)
46   {
47     super(module);
48   }
49
50   /**
51    * mbean.hasVirtualDatabase(vdbName)
52    *
53    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
54    */

55   public void parse(String JavaDoc commandText) throws Exception JavaDoc
56   {
57     if (ON.equals(commandText.trim()))
58     {
59       ((VirtualDatabaseAdmin) module).addDebugCommands();
60       console.printInfo(ConsoleTranslate.get("DebugMode.on")); //$NON-NLS-1$
61
}
62     else if (OFF.equals(commandText.trim()))
63     {
64       ((VirtualDatabaseAdmin) module).removeDebugCommands();
65       console.printInfo(ConsoleTranslate.get("DebugMode.off")); //$NON-NLS-1$
66
}
67     else
68     {
69       console.printError(getUsage());
70     }
71   }
72
73   /**
74    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
75    */

76   public String JavaDoc getCommandName()
77   {
78     return "debug"; //$NON-NLS-1$
79
}
80
81   /**
82    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
83    */

84   public String JavaDoc getCommandDescription()
85   {
86     return ConsoleTranslate.get("DebugMode.description"); //$NON-NLS-1$
87
}
88
89   /**
90    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
91    */

92   public String JavaDoc getCommandParameters()
93   {
94     return ConsoleTranslate.get("DebugMode.params"); //$NON-NLS-1$
95
}
96 }
97
Popular Tags