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