|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
TimerInstruction.java | - | 100% | 100% | 100% |
|
1 |
/*
|
|
2 |
|
|
3 |
VRMoo Server - Virtual Reality Object Oriented MUD Server
|
|
4 |
Copyright (C) 2001 - 2003 VRMoo Development Team
|
|
5 |
|
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or modify
|
|
8 |
it under the terms of the GNU General Public License as published by
|
|
9 |
the Free Software Foundation; either version 2 of the License, or
|
|
10 |
(at your option) any later version.
|
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful,
|
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 |
GNU General Public License for more details.
|
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License
|
|
18 |
along with this program; if not, write to the Free Software
|
|
19 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
20 |
|
|
21 |
|
|
22 |
For information about VRMoo and its authors, please visit the website:
|
|
23 |
http://www.vrmoo.org/
|
|
24 |
|
|
25 |
*/
|
|
26 |
|
|
27 |
package org.vrmoo.server.vrmoopl;
|
|
28 |
|
|
29 |
import org.vrmoo.common.exception.VRMooParseException;
|
|
30 |
import org.vrmoo.common.util.ParserUtility;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* This class represents the <code>timer</code> instruction in a vrmoopl
|
|
34 |
* program. The <code>timer</code> instruction sets up a timer to call a
|
|
35 |
* specified function within the program at the specified interval.
|
|
36 |
*
|
|
37 |
* @author Jeff Weston
|
|
38 |
*/
|
|
39 |
public class TimerInstruction extends Instruction |
|
40 |
{ |
|
41 |
/**
|
|
42 |
* The name of the function that the timer will call.
|
|
43 |
*/
|
|
44 |
private String functionName;
|
|
45 |
|
|
46 |
/**
|
|
47 |
* The interval for calling the function from the timer.
|
|
48 |
*/
|
|
49 |
private int interval; |
|
50 |
|
|
51 |
/**
|
|
52 |
* Construct a <code>timer<code> instruction from the specified parameters.
|
|
53 |
*
|
|
54 |
* @param params the specified parameters
|
|
55 |
*
|
|
56 |
* @throws VRMooParseException for any parsing errors that occur
|
|
57 |
*/
|
|
58 | 2 |
public TimerInstruction( String params ) throws VRMooParseException |
59 |
{ |
|
60 | 2 |
int splitIndex = params.indexOf( "," ); |
61 | 2 |
functionName = params.substring( 0, splitIndex ).trim( ); |
62 | 2 |
interval = ParserUtility.parseInt( params.substring( splitIndex + 1 ) ); |
63 |
} |
|
64 |
|
|
65 |
/**
|
|
66 |
* Get the name of the function the timer will call.
|
|
67 |
*
|
|
68 |
* @return the name of the function the timer will call
|
|
69 |
*/
|
|
70 | 1 |
public String getFunctionName( )
|
71 |
{ |
|
72 | 1 |
return functionName;
|
73 |
} |
|
74 |
|
|
75 |
/**
|
|
76 |
* Get the interval for calling the function from the timer
|
|
77 |
*
|
|
78 |
* @return the interval for calling the function from the timer
|
|
79 |
*/
|
|
80 | 1 |
public int getInterval( ) |
81 |
{ |
|
82 | 1 |
return interval;
|
83 |
} |
|
84 |
} |
|
85 |
|
|