source: trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/misc/CMDdeleteObject.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:mime-type set to text/plain
File size: 1.7 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.commands.misc;
16
17import java.util.List;
18
19import de.ugoe.cs.autoquest.CommandHelpers;
20import de.ugoe.cs.util.console.Command;
21import de.ugoe.cs.util.console.GlobalDataContainer;
22
23/**
24 * <p>
25 * Command to delete object from {@link GlobalDataContainer}.
26 * </p>
27 *
28 * @author Steffen Herbold
29 * @version 1.0
30 */
31public class CMDdeleteObject implements Command {
32
33        /*
34         * (non-Javadoc)
35         *
36         * @see de.ugoe.cs.util.console.Command#help()
37         */
38        @Override
39        public String help() {
40                return "deleteObject <objectname>";
41        }
42
43        /*
44         * (non-Javadoc)
45         *
46         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
47         */
48        @Override
49        public void run(List<Object> parameters) {
50                String objectName;
51                try {
52                        objectName = (String) parameters.get(0);
53                } catch (Exception e) {
54                        throw new IllegalArgumentException();
55                }
56                boolean deleted = GlobalDataContainer.getInstance().removeData(
57                                objectName);
58                if (!deleted) {
59                        CommandHelpers.objectNotFoundMessage(objectName);
60                }
61        }
62}
Note: See TracBrowser for help on using the repository browser.