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

Last change on this file since 202 was 171, checked in by sherbold, 13 years ago
  • code documentation and formatting
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.data.GlobalDataContainer;
7import de.ugoe.cs.eventbench.models.IDotCompatible;
8import de.ugoe.cs.util.console.Command;
9import de.ugoe.cs.util.console.Console;
10
11/**
12 * <p>
13 * Command that prints a dot representation of a model (if supported) to the
14 * console.
15 * </p>
16 *
17 * @author Steffen Herbold
18 * @version 1.0
19 */
20public class CMDprintDot implements Command {
21
22        /*
23         * (non-Javadoc)
24         *
25         * @see de.ugoe.cs.util.console.Command#help()
26         */
27        @Override
28        public void help() {
29                Console.println("Usage: printDot <modelname>");
30        }
31
32        /*
33         * (non-Javadoc)
34         *
35         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
36         */
37        @Override
38        public void run(List<Object> parameters) {
39                String modelname = "";
40                try {
41                        modelname = (String) parameters.get(0);
42                } catch (Exception e) {
43                        throw new InvalidParameterException();
44                }
45
46                IDotCompatible model = null;
47                Object dataObject = GlobalDataContainer.getInstance()
48                                .getData(modelname);
49                if (dataObject == null) {
50                        Console.println("Model " + modelname + "not found in storage.");
51                } else if (!(dataObject instanceof IDotCompatible)) {
52                        Console.println("Object " + modelname
53                                        + " does not implement IDotCompatible!");
54                } else {
55                        model = (IDotCompatible) dataObject;
56                        Console.println(model.getDotRepresentation());
57                }
58        }
59
60}
Note: See TracBrowser for help on using the repository browser.