Last change
on this file since 183 was
171,
checked in by sherbold, 13 years ago
|
- code documentation and formatting
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.5 KB
|
Line | |
---|
1 | package de.ugoe.cs.eventbench.commands;
|
---|
2 |
|
---|
3 | import java.security.InvalidParameterException;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
7 | import de.ugoe.cs.eventbench.models.Trie;
|
---|
8 | import de.ugoe.cs.eventbench.models.TrieBasedModel;
|
---|
9 | import de.ugoe.cs.util.console.Command;
|
---|
10 | import 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 | */
|
---|
21 | public 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 | } else if (!(dataObject instanceof TrieBasedModel)) {
|
---|
53 | Console.println("Object " + modelname + " is not a TrieBasedModel!");
|
---|
54 | } else {
|
---|
55 | model = (TrieBasedModel) dataObject;
|
---|
56 | Console.println(model.getTrieDotRepresentation());
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.