Last change
on this file since 87 was
71,
checked in by sherbold, 13 years ago
|
+ added command listStates
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.4 KB
|
Rev | Line | |
---|
[71] | 1 | package de.ugoe.cs.eventbench.commands;
|
---|
| 2 |
|
---|
| 3 | import java.security.InvalidParameterException;
|
---|
| 4 | import java.util.Arrays;
|
---|
| 5 | import java.util.List;
|
---|
| 6 |
|
---|
| 7 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
| 8 | import de.ugoe.cs.eventbench.models.IStochasticProcess;
|
---|
| 9 | import de.ugoe.cs.util.console.Command;
|
---|
| 10 | import de.ugoe.cs.util.console.Console;
|
---|
| 11 |
|
---|
| 12 | public class CMDlistStates implements Command {
|
---|
| 13 |
|
---|
| 14 | @Override
|
---|
| 15 | public void run(List<Object> parameters) {
|
---|
| 16 | String modelname = "";
|
---|
| 17 | boolean sort = false;
|
---|
| 18 | try {
|
---|
| 19 | modelname = (String) parameters.get(0);
|
---|
| 20 | if( parameters.size()==2 ) {
|
---|
| 21 | sort = Boolean.parseBoolean((String) parameters.get(1));
|
---|
| 22 | }
|
---|
| 23 | } catch (Exception e) {
|
---|
| 24 | throw new InvalidParameterException();
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | IStochasticProcess model = null;
|
---|
| 28 | Object dataObject = GlobalDataContainer.getInstance().getData(modelname);
|
---|
| 29 | if( dataObject==null ) {
|
---|
| 30 | Console.println("Model " + modelname + "not found in storage.");
|
---|
| 31 | }
|
---|
| 32 | else if( !(dataObject instanceof IStochasticProcess) ) {
|
---|
| 33 | Console.println("Object " + modelname + " is not a stochastic process!");
|
---|
| 34 | } else {
|
---|
| 35 | model = (IStochasticProcess) dataObject;
|
---|
| 36 | String[] stateStrings = model.getStateStrings();
|
---|
| 37 | if( sort ) {
|
---|
| 38 | Arrays.sort(stateStrings);
|
---|
| 39 | }
|
---|
| 40 | for( String stateString : stateStrings ) {
|
---|
| 41 | Console.println(stateString);
|
---|
| 42 | }
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | @Override
|
---|
| 47 | public void help() {
|
---|
| 48 | Console.println("Usage: listStates <modelName>");
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.