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

Last change on this file since 68 was 67, checked in by sherbold, 14 years ago

+ added command numStates

  • Property svn:mime-type set to text/plain
File size: 1.2 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.FirstOrderMarkovModel;
8import de.ugoe.cs.eventbench.models.IStochasticProcess;
9import de.ugoe.cs.util.console.Command;
10import de.ugoe.cs.util.console.Console;
11
12public class CMDnumStates implements Command {
13
14        @Override
15        public void run(List<Object> parameters) {
16                String modelname = "";
17                try {
18                        modelname = (String) parameters.get(0);
19                } catch (Exception e) {
20                        throw new InvalidParameterException();
21                }
22               
23                IStochasticProcess model = null;
24                Object dataObject = GlobalDataContainer.getInstance().getData(modelname);
25                if( dataObject==null ) {
26                        Console.println("Model " + modelname + "not found in storage.");
27                }
28                else if( !(dataObject instanceof IStochasticProcess) ) {
29                        Console.println("Object " + modelname + " is not a stochastic process!");
30                } else {
31                        model = (IStochasticProcess) dataObject;
32                        Console.println("" + model.getNumStates() + " states");
33                }
34        }
35
36        @Override
37        public void help() {
38                Console.println("Usage: numStates <modelName>");
39        }
40
41}
Note: See TracBrowser for help on using the repository browser.