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

Last change on this file since 766 was 766, checked in by sherbold, 12 years ago
  • Property svn:mime-type set to text/plain
File size: 1.5 KB
Line 
1package de.ugoe.cs.quest.commands.usage;
2
3import java.util.List;
4
5import de.ugoe.cs.quest.CommandHelpers;
6import de.ugoe.cs.quest.usageprofiles.IStochasticProcess;
7import de.ugoe.cs.util.console.Command;
8import de.ugoe.cs.util.console.Console;
9import de.ugoe.cs.util.console.GlobalDataContainer;
10
11/**
12 * <p>
13 * Command that prints the size of a stochastic process to the console.
14 * </p>
15 *
16 * @author Steffen Herbold
17 * @version 1.0
18 */
19public class CMDmodelSize implements Command {
20
21        /*
22         * (non-Javadoc)
23         *
24         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
25         */
26        @Override
27        public void run(List<Object> parameters) {
28                String modelname;
29                try {
30                        modelname = (String) parameters.get(0);
31                } catch (Exception e) {
32                        throw new IllegalArgumentException();
33                }
34
35                Object dataObject = GlobalDataContainer.getInstance()
36                                .getData(modelname);
37                if (dataObject == null) {
38                        CommandHelpers.objectNotFoundMessage(modelname);
39                        return;
40                }
41                if (!(dataObject instanceof IStochasticProcess)) {
42                        CommandHelpers.objectNotType(modelname, "IStochasticProcess");
43                        return;
44                }
45
46                IStochasticProcess process = (IStochasticProcess) dataObject;
47                Console.println("#symbols: " + process.getNumSymbols()
48                                + " ; #FOMstates " + process.getNumFOMStates()
49                                + " ; #transitions: " + process.getNumTransitions());
50        }
51
52        /*
53         * (non-Javadoc)
54         *
55         * @see de.ugoe.cs.util.console.Command#help()
56         */
57        @Override
58        public String help() {
59                return "modelSize <modelname>";
60        }
61
62}
Note: See TracBrowser for help on using the repository browser.