source: trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/usage/CMDprintTrieDot.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:mime-type set to text/plain
File size: 2.1 KB
Line 
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
15package de.ugoe.cs.autoquest.commands.usage;
16
17import java.util.List;
18
19import de.ugoe.cs.autoquest.CommandHelpers;
20import de.ugoe.cs.autoquest.usageprofiles.Trie;
21import de.ugoe.cs.autoquest.usageprofiles.TrieBasedModel;
22import de.ugoe.cs.util.console.Command;
23import de.ugoe.cs.util.console.Console;
24import de.ugoe.cs.util.console.GlobalDataContainer;
25
26/**
27 * <p>
28 * Command that prints the {@link Trie} of a {@link TrieBasedModel} as dot to
29 * the console.
30 * </p>
31 *
32 * @author Steffen Herbold
33 * @version 1.0
34 */
35public class CMDprintTrieDot implements Command {
36
37        /*
38         * (non-Javadoc)
39         *
40         * @see de.ugoe.cs.util.console.Command#help()
41         */
42        @Override
43        public String help() {
44                return "printTreeDot <modelname>";
45        }
46
47        /*
48         * (non-Javadoc)
49         *
50         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
51         */
52        @Override
53        public void run(List<Object> parameters) {
54                String modelname = "";
55                try {
56                        modelname = (String) parameters.get(0);
57                } catch (Exception e) {
58                        throw new IllegalArgumentException();
59                }
60
61                TrieBasedModel model = null;
62                Object dataObject = GlobalDataContainer.getInstance()
63                                .getData(modelname);
64                if (dataObject == null) {
65                        CommandHelpers.objectNotFoundMessage(modelname);
66                        return;
67                }
68                if (!(dataObject instanceof TrieBasedModel)) {
69                        CommandHelpers.objectNotType(modelname, "TrieBasedModel");
70                        return;
71                }
72
73                model = (TrieBasedModel) dataObject;
74                Console.println(model.getTrieDotRepresentation());
75        }
76
77}
Note: See TracBrowser for help on using the repository browser.