source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDnumStates.java @ 72

Last change on this file since 72 was 69, checked in by sherbold, 14 years ago
  • minor cleanup
  • Property svn:mime-type set to text/plain
File size: 1.1 KB
Line 
1package de.ugoe.cs.eventbench.commands;
2
3import java.security.InvalidParameterException;
4import java.util.List;
5
6import de.ugoe.cs.eventbench.data.GlobalDataContainer;
7import de.ugoe.cs.eventbench.models.IStochasticProcess;
8import de.ugoe.cs.util.console.Command;
9import de.ugoe.cs.util.console.Console;
10
11public class CMDnumStates implements Command {
12
13        @Override
14        public void run(List<Object> parameters) {
15                String modelname = "";
16                try {
17                        modelname = (String) parameters.get(0);
18                } catch (Exception e) {
19                        throw new InvalidParameterException();
20                }
21               
22                IStochasticProcess model = null;
23                Object dataObject = GlobalDataContainer.getInstance().getData(modelname);
24                if( dataObject==null ) {
25                        Console.println("Model " + modelname + "not found in storage.");
26                }
27                else if( !(dataObject instanceof IStochasticProcess) ) {
28                        Console.println("Object " + modelname + " is not a stochastic process!");
29                } else {
30                        model = (IStochasticProcess) dataObject;
31                        Console.println("" + model.getNumStates() + " states");
32                }
33        }
34
35        @Override
36        public void help() {
37                Console.println("Usage: numStates <modelName>");
38        }
39
40}
Note: See TracBrowser for help on using the repository browser.