source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDprintDot.java @ 425

Last change on this file since 425 was 240, checked in by sherbold, 13 years ago
File size: 1.5 KB
Line 
1package de.ugoe.cs.eventbench.commands;
2
3import java.security.InvalidParameterException;
4import java.util.List;
5
6import de.ugoe.cs.eventbench.CommandHelpers;
7import de.ugoe.cs.eventbench.data.GlobalDataContainer;
8import de.ugoe.cs.eventbench.models.IDotCompatible;
9import de.ugoe.cs.util.console.Command;
10import de.ugoe.cs.util.console.Console;
11
12/**
13 * <p>
14 * Command that prints a dot representation of a model (if supported) to the
15 * console.
16 * </p>
17 *
18 * @author Steffen Herbold
19 * @version 1.0
20 */
21public class CMDprintDot implements Command {
22
23        /*
24         * (non-Javadoc)
25         *
26         * @see de.ugoe.cs.util.console.Command#help()
27         */
28        @Override
29        public void help() {
30                Console.println("Usage: printDot <modelname>");
31        }
32
33        /*
34         * (non-Javadoc)
35         *
36         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
37         */
38        @Override
39        public void run(List<Object> parameters) {
40                String modelname = "";
41                try {
42                        modelname = (String) parameters.get(0);
43                } catch (Exception e) {
44                        throw new InvalidParameterException();
45                }
46
47                IDotCompatible model = null;
48                Object dataObject = GlobalDataContainer.getInstance()
49                                .getData(modelname);
50                if (dataObject == null) {
51                        CommandHelpers.objectNotFoundMessage(modelname);
52                        return;
53                }
54                if (!(dataObject instanceof IDotCompatible)) {
55                        CommandHelpers.objectNotType(modelname, "IDotCompatible");
56                        return;
57                }
58
59                model = (IDotCompatible) dataObject;
60                Console.println(model.getDotRepresentation());
61        }
62
63}
Note: See TracBrowser for help on using the repository browser.