source: trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/ui/commands/CMDmodelSize.java @ 664

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
RevLine 
[434]1package de.ugoe.cs.quest.ui.commands;
[130]2
3import java.security.InvalidParameterException;
4import java.util.List;
5
[432]6import de.ugoe.cs.quest.CommandHelpers;
[434]7import de.ugoe.cs.quest.ui.GlobalDataContainer;
[433]8import de.ugoe.cs.quest.usageprofiles.IStochasticProcess;
[130]9import de.ugoe.cs.util.console.Command;
10import de.ugoe.cs.util.console.Console;
11
12/**
[171]13 * <p>
14 * Command that prints the size of a stochastic process to the console.
15 * </p>
16 *
17 * @author Steffen Herbold
18 * @version 1.0
[130]19 */
20public class CMDmodelSize implements Command {
21
[171]22        /*
23         * (non-Javadoc)
24         *
[130]25         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
26         */
27        @Override
28        public void run(List<Object> parameters) {
29                String modelname;
30                try {
31                        modelname = (String) parameters.get(0);
32                } catch (Exception e) {
33                        throw new InvalidParameterException();
34                }
[171]35
36                Object dataObject = GlobalDataContainer.getInstance()
37                                .getData(modelname);
38                if (dataObject == null) {
[240]39                        CommandHelpers.objectNotFoundMessage(modelname);
[130]40                        return;
41                }
[171]42                if (!(dataObject instanceof IStochasticProcess)) {
[240]43                        CommandHelpers.objectNotType(modelname, "IStochasticProcess");
[130]44                        return;
45                }
[171]46
[130]47                IStochasticProcess process = (IStochasticProcess) dataObject;
[171]48                Console.println("#symbols: " + process.getNumSymbols()
[249]49                                + " ; #FOMstates " + process.getNumFOMStates()
50                                + " ; #transitions: " + process.getNumTransitions());
[130]51        }
52
[171]53        /*
54         * (non-Javadoc)
55         *
[130]56         * @see de.ugoe.cs.util.console.Command#help()
57         */
58        @Override
[664]59        public String help() {
60                return "modelSize <modelName>";
[130]61        }
62
63}
Note: See TracBrowser for help on using the repository browser.