[927] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
| 14 |
|
---|
[922] | 15 | package de.ugoe.cs.autoquest.commands.usage;
|
---|
[130] | 16 |
|
---|
| 17 | import java.util.List;
|
---|
| 18 |
|
---|
[922] | 19 | import de.ugoe.cs.autoquest.CommandHelpers;
|
---|
| 20 | import de.ugoe.cs.autoquest.usageprofiles.IStochasticProcess;
|
---|
[130] | 21 | import de.ugoe.cs.util.console.Command;
|
---|
| 22 | import de.ugoe.cs.util.console.Console;
|
---|
[667] | 23 | import de.ugoe.cs.util.console.GlobalDataContainer;
|
---|
[130] | 24 |
|
---|
| 25 | /**
|
---|
[171] | 26 | * <p>
|
---|
| 27 | * Command that prints the size of a stochastic process to the console.
|
---|
| 28 | * </p>
|
---|
| 29 | *
|
---|
| 30 | * @author Steffen Herbold
|
---|
| 31 | * @version 1.0
|
---|
[130] | 32 | */
|
---|
| 33 | public class CMDmodelSize implements Command {
|
---|
| 34 |
|
---|
[171] | 35 | /*
|
---|
| 36 | * (non-Javadoc)
|
---|
| 37 | *
|
---|
[130] | 38 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
| 39 | */
|
---|
| 40 | @Override
|
---|
| 41 | public void run(List<Object> parameters) {
|
---|
| 42 | String modelname;
|
---|
| 43 | try {
|
---|
| 44 | modelname = (String) parameters.get(0);
|
---|
| 45 | } catch (Exception e) {
|
---|
[766] | 46 | throw new IllegalArgumentException();
|
---|
[130] | 47 | }
|
---|
[171] | 48 |
|
---|
| 49 | Object dataObject = GlobalDataContainer.getInstance()
|
---|
| 50 | .getData(modelname);
|
---|
| 51 | if (dataObject == null) {
|
---|
[240] | 52 | CommandHelpers.objectNotFoundMessage(modelname);
|
---|
[130] | 53 | return;
|
---|
| 54 | }
|
---|
[171] | 55 | if (!(dataObject instanceof IStochasticProcess)) {
|
---|
[240] | 56 | CommandHelpers.objectNotType(modelname, "IStochasticProcess");
|
---|
[130] | 57 | return;
|
---|
| 58 | }
|
---|
[171] | 59 |
|
---|
[130] | 60 | IStochasticProcess process = (IStochasticProcess) dataObject;
|
---|
[171] | 61 | Console.println("#symbols: " + process.getNumSymbols()
|
---|
[249] | 62 | + " ; #FOMstates " + process.getNumFOMStates()
|
---|
| 63 | + " ; #transitions: " + process.getNumTransitions());
|
---|
[130] | 64 | }
|
---|
| 65 |
|
---|
[171] | 66 | /*
|
---|
| 67 | * (non-Javadoc)
|
---|
| 68 | *
|
---|
[130] | 69 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 70 | */
|
---|
| 71 | @Override
|
---|
[664] | 72 | public String help() {
|
---|
[726] | 73 | return "modelSize <modelname>";
|
---|
[130] | 74 | }
|
---|
| 75 |
|
---|
| 76 | }
|
---|