source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDmodelSize.java

Last change on this file was 249, checked in by sherbold, 13 years ago
  • Property svn:mime-type set to text/plain
File size: 1.6 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.IStochasticProcess;
9import de.ugoe.cs.util.console.Command;
10import de.ugoe.cs.util.console.Console;
11
12/**
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
19 */
20public class CMDmodelSize implements Command {
21
22        /*
23         * (non-Javadoc)
24         *
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                }
35
36                Object dataObject = GlobalDataContainer.getInstance()
37                                .getData(modelname);
38                if (dataObject == null) {
39                        CommandHelpers.objectNotFoundMessage(modelname);
40                        return;
41                }
42                if (!(dataObject instanceof IStochasticProcess)) {
43                        CommandHelpers.objectNotType(modelname, "IStochasticProcess");
44                        return;
45                }
46
47                IStochasticProcess process = (IStochasticProcess) dataObject;
48                Console.println("#symbols: " + process.getNumSymbols()
49                                + " ; #FOMstates " + process.getNumFOMStates()
50                                + " ; #transitions: " + process.getNumTransitions());
51        }
52
53        /*
54         * (non-Javadoc)
55         *
56         * @see de.ugoe.cs.util.console.Command#help()
57         */
58        @Override
59        public void help() {
60                Console.println("Usage: modelSize <modelName>");
61        }
62
63}
Note: See TracBrowser for help on using the repository browser.