source: trunk/quest-ui-core/src/de/ugoe/cs/quest/ui/commands/CMDstopFileListener.java @ 434

Last change on this file since 434 was 434, checked in by sherbold, 12 years ago
  • renamed packages to fit QUEST project structure
  • Property svn:mime-type set to text/plain
File size: 1.3 KB
Line 
1package de.ugoe.cs.quest.ui.commands;
2
3import java.security.InvalidParameterException;
4import java.util.List;
5
6import de.ugoe.cs.quest.CommandHelpers;
7import de.ugoe.cs.quest.ui.GlobalDataContainer;
8import de.ugoe.cs.util.console.Command;
9import de.ugoe.cs.util.console.Console;
10import de.ugoe.cs.util.console.FileOutputListener;
11
12/**
13 * <p>
14 * Command to stop a {@link FileOutputListener}.
15 * </p>
16 * @author Steffen Herbold
17 * @version 1.0
18 */
19public class CMDstopFileListener implements Command {
20
21        @Override
22        public void run(List<Object> parameters) {
23                String filename;
24                try {
25                        filename = (String) parameters.get(0);
26                } catch (Exception e) {
27                        throw new InvalidParameterException();
28                }
29
30                Object dataObject = GlobalDataContainer.getInstance().getData(filename);
31                if( dataObject==null ) {
32                        CommandHelpers.objectNotFoundMessage(filename);
33                        return;
34                }
35                if( !(dataObject instanceof FileOutputListener) ) {
36                        CommandHelpers.objectNotType(filename, "FileOutputListener");
37                        return;
38                }
39               
40                FileOutputListener listener = (FileOutputListener) dataObject;
41                listener.stop();
42                GlobalDataContainer.getInstance().removeData(filename);
43        }
44
45        @Override
46        public void help() {
47                Console.println("Command: stopFileListener <filename>");
48
49        }
50
51}
Note: See TracBrowser for help on using the repository browser.