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

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