source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDprintTrieDot.java @ 211

Last change on this file since 211 was 209, checked in by sherbold, 13 years ago
  • greatly improved type checking and consistency of type checking for objects checked out of the GlobalDataContainer?
  • Property svn:mime-type set to text/plain
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.Trie;
8import de.ugoe.cs.eventbench.models.TrieBasedModel;
9import de.ugoe.cs.util.console.Command;
10import de.ugoe.cs.util.console.Console;
11
12/**
13 * <p>
14 * Command that prints the {@link Trie} of a {@link TrieBasedModel} as dot to
15 * the console.
16 * </p>
17 *
18 * @author Steffen Herbold
19 * @version
20 */
21public class CMDprintTrieDot 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: printTreeDot <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                TrieBasedModel model = null;
48                Object dataObject = GlobalDataContainer.getInstance()
49                                .getData(modelname);
50                if (dataObject == null) {
51                        Console.println("Model " + modelname + "not found in storage.");
52                        return;
53                }
54                if (!(dataObject instanceof TrieBasedModel)) {
55                        Console.println("Object " + modelname + " is not a TrieBasedModel!");
56                        return;
57                }
58
59                model = (TrieBasedModel) dataObject;
60                Console.println(model.getTrieDotRepresentation());
61        }
62
63}
Note: See TracBrowser for help on using the repository browser.