Last change
on this file since 664 was
664,
checked in by sherbold, 12 years ago
|
- modified Command.help(): the help now returns a string with its usage instead of writing directly to the console
- modified listCommands: now writes the help string of each command instead of just the name; this way, the parameters are displayed directly
- moved listCommands from quest-ui-core to java-utils
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.5 KB
|
Rev | Line | |
---|
[434] | 1 | package de.ugoe.cs.quest.ui.commands;
|
---|
[31] | 2 |
|
---|
| 3 | import java.security.InvalidParameterException;
|
---|
| 4 | import java.util.List;
|
---|
| 5 |
|
---|
[432] | 6 | import de.ugoe.cs.quest.CommandHelpers;
|
---|
[434] | 7 | import de.ugoe.cs.quest.ui.GlobalDataContainer;
|
---|
[433] | 8 | import de.ugoe.cs.quest.usageprofiles.Trie;
|
---|
| 9 | import de.ugoe.cs.quest.usageprofiles.TrieBasedModel;
|
---|
[31] | 10 | import de.ugoe.cs.util.console.Command;
|
---|
| 11 | import de.ugoe.cs.util.console.Console;
|
---|
| 12 |
|
---|
[171] | 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
|
---|
[223] | 20 | * @version 1.0
|
---|
[171] | 21 | */
|
---|
[31] | 22 | public class CMDprintTrieDot implements Command {
|
---|
[171] | 23 |
|
---|
| 24 | /*
|
---|
| 25 | * (non-Javadoc)
|
---|
| 26 | *
|
---|
| 27 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 28 | */
|
---|
[31] | 29 | @Override
|
---|
[664] | 30 | public String help() {
|
---|
| 31 | return "printTreeDot <modelname>";
|
---|
[31] | 32 | }
|
---|
| 33 |
|
---|
[171] | 34 | /*
|
---|
| 35 | * (non-Javadoc)
|
---|
| 36 | *
|
---|
| 37 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
| 38 | */
|
---|
[31] | 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 | }
|
---|
[171] | 47 |
|
---|
| 48 | TrieBasedModel model = null;
|
---|
| 49 | Object dataObject = GlobalDataContainer.getInstance()
|
---|
| 50 | .getData(modelname);
|
---|
| 51 | if (dataObject == null) {
|
---|
[240] | 52 | CommandHelpers.objectNotFoundMessage(modelname);
|
---|
[209] | 53 | return;
|
---|
| 54 | }
|
---|
| 55 | if (!(dataObject instanceof TrieBasedModel)) {
|
---|
[240] | 56 | CommandHelpers.objectNotType(modelname, "TrieBasedModel");
|
---|
[209] | 57 | return;
|
---|
[31] | 58 | }
|
---|
[209] | 59 |
|
---|
| 60 | model = (TrieBasedModel) dataObject;
|
---|
| 61 | Console.println(model.getTrieDotRepresentation());
|
---|
[31] | 62 | }
|
---|
[171] | 63 |
|
---|
[31] | 64 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.