source: trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/misc/CMDshowTimer.java @ 922

Last change on this file since 922 was 922, checked in by sherbold, 12 years ago
  • renaming of packages from de.ugoe.cs.quest to de.ugoe.cs.autoquest
  • Property svn:mime-type set to text/plain
File size: 1.4 KB
Line 
1package de.ugoe.cs.autoquest.commands.misc;
2
3import java.util.List;
4import java.util.logging.Level;
5
6import de.ugoe.cs.autoquest.CommandHelpers;
7import de.ugoe.cs.util.console.Command;
8import de.ugoe.cs.util.console.Console;
9import de.ugoe.cs.util.console.GlobalDataContainer;
10
11/**
12 * <p>
13 * Command to show the time elapsed since a timer has been started.
14 * </p>
15 *
16 * @author Steffen Herbold
17 * @version 1.0
18 */
19public class CMDshowTimer implements Command {
20
21        /*
22         * (non-Javadoc)
23         *
24         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
25         */
26        @Override
27        public void run(List<Object> parameters) {
28                String timerName;
29                try {
30                        timerName = (String) parameters.get(0);
31                } catch (Exception e) {
32                        throw new IllegalArgumentException();
33                }
34
35                Object dataObject = GlobalDataContainer.getInstance().getData(timerName);
36                if (dataObject == null) {
37                        CommandHelpers.objectNotFoundMessage(timerName);
38                        return;
39                }
40                if (!(dataObject instanceof Long)) {
41                        CommandHelpers.objectNotType(timerName, "Long");
42                        return;
43                }
44
45                long startTime = (Long) dataObject;
46                long currentTime = System.currentTimeMillis();
47                Console.traceln(Level.INFO, "" + (currentTime - startTime) + " milliseconds");
48        }
49
50        /*
51         * (non-Javadoc)
52         *
53         * @see de.ugoe.cs.util.console.Command#help()
54         */
55        @Override
56        public String help() {
57                return "showTimer <timerName>";
58        }
59
60}
Note: See TracBrowser for help on using the repository browser.