source: trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/usage/CMDprintDot.java @ 1934

Last change on this file since 1934 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
File size: 2.1 KB
RevLine 
[927]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
[922]15package de.ugoe.cs.autoquest.commands.usage;
[1]16
17import java.util.List;
18
[922]19import de.ugoe.cs.autoquest.CommandHelpers;
20import de.ugoe.cs.autoquest.usageprofiles.IDotCompatible;
[1]21import de.ugoe.cs.util.console.Command;
22import de.ugoe.cs.util.console.Console;
[667]23import de.ugoe.cs.util.console.GlobalDataContainer;
[1]24
[171]25/**
26 * <p>
27 * Command that prints a dot representation of a model (if supported) to the
28 * console.
29 * </p>
30 *
31 * @author Steffen Herbold
32 * @version 1.0
33 */
[1]34public class CMDprintDot implements Command {
35
[171]36        /*
37         * (non-Javadoc)
38         *
39         * @see de.ugoe.cs.util.console.Command#help()
40         */
[1]41        @Override
[664]42        public String help() {
43                return "printDot <modelname>";
[1]44        }
45
[171]46        /*
47         * (non-Javadoc)
48         *
49         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
50         */
[1]51        @Override
52        public void run(List<Object> parameters) {
53                String modelname = "";
54                try {
55                        modelname = (String) parameters.get(0);
56                } catch (Exception e) {
[766]57                        throw new IllegalArgumentException();
[1]58                }
[171]59
60                IDotCompatible model = null;
61                Object dataObject = GlobalDataContainer.getInstance()
62                                .getData(modelname);
63                if (dataObject == null) {
[240]64                        CommandHelpers.objectNotFoundMessage(modelname);
[209]65                        return;
66                }
67                if (!(dataObject instanceof IDotCompatible)) {
[240]68                        CommandHelpers.objectNotType(modelname, "IDotCompatible");
[209]69                        return;
[1]70                }
[209]71
72                model = (IDotCompatible) dataObject;
73                Console.println(model.getDotRepresentation());
[1]74        }
75
76}
Note: See TracBrowser for help on using the repository browser.