[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.misc;
|
---|
[235] | 16 |
|
---|
| 17 | import java.util.List;
|
---|
| 18 |
|
---|
[922] | 19 | import de.ugoe.cs.autoquest.CommandHelpers;
|
---|
[235] | 20 | import de.ugoe.cs.util.console.Command;
|
---|
[667] | 21 | import de.ugoe.cs.util.console.GlobalDataContainer;
|
---|
[235] | 22 |
|
---|
| 23 | /**
|
---|
| 24 | * <p>
|
---|
| 25 | * Command to start a time.
|
---|
| 26 | * </p>
|
---|
| 27 | *
|
---|
| 28 | * @author Steffen Herbold
|
---|
| 29 | * @version 1.0
|
---|
| 30 | */
|
---|
| 31 | public class CMDstartTimer implements Command {
|
---|
| 32 |
|
---|
| 33 | /*
|
---|
| 34 | * (non-Javadoc)
|
---|
| 35 | *
|
---|
| 36 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
| 37 | */
|
---|
| 38 | @Override
|
---|
| 39 | public void run(List<Object> parameters) {
|
---|
| 40 | String timerName;
|
---|
| 41 | try {
|
---|
| 42 | timerName = (String) parameters.get(0);
|
---|
| 43 | } catch (Exception e) {
|
---|
[766] | 44 | throw new IllegalArgumentException();
|
---|
[235] | 45 | }
|
---|
| 46 | Long time = System.currentTimeMillis();
|
---|
| 47 | if (GlobalDataContainer.getInstance().addData(timerName, time)) {
|
---|
[240] | 48 | CommandHelpers.dataOverwritten(timerName);
|
---|
[235] | 49 | }
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | /*
|
---|
| 53 | * (non-Javadoc)
|
---|
| 54 | *
|
---|
| 55 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 56 | */
|
---|
| 57 | @Override
|
---|
[664] | 58 | public String help() {
|
---|
| 59 | return "startTimer <timerName>";
|
---|
[235] | 60 | }
|
---|
| 61 |
|
---|
| 62 | }
|
---|