|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Program.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 java.util.HashMap;
|
|
30 |
import java.util.Map;
|
|
31 |
import java.util.Set;
|
|
32 |
|
|
33 |
/**
|
|
34 |
* This class holds the data and functionality for handling a vrmoopl program.
|
|
35 |
*
|
|
36 |
* @author Jeff Weston
|
|
37 |
*/
|
|
38 |
public class Program |
|
39 |
{ |
|
40 |
/**
|
|
41 |
* The name of the program.
|
|
42 |
*/
|
|
43 |
private String name;
|
|
44 |
|
|
45 |
/**
|
|
46 |
* The set of functions that comprise the program.
|
|
47 |
*/
|
|
48 |
private Map functions;
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Constructs a new empty program with the given name.
|
|
52 |
*
|
|
53 |
* @param name the name of the program
|
|
54 |
*/
|
|
55 | 4 |
public Program( String name )
|
56 |
{ |
|
57 | 4 |
this.name = name;
|
58 | 4 |
functions = new HashMap( );
|
59 |
} |
|
60 |
|
|
61 |
/**
|
|
62 |
* Add the specified function to the program.
|
|
63 |
*
|
|
64 |
* @param function the function to add
|
|
65 |
*/
|
|
66 | 2 |
public void addFunction( Function function ) |
67 |
{ |
|
68 | 2 |
functions.put( function.getName( ), function ); |
69 |
} |
|
70 |
|
|
71 |
/**
|
|
72 |
* Return the name of all functions in the program.
|
|
73 |
*
|
|
74 |
* @return the set of function names
|
|
75 |
*/
|
|
76 | 1 |
public Set getFunctionNames( )
|
77 |
{ |
|
78 | 1 |
return functions.keySet( );
|
79 |
} |
|
80 |
|
|
81 |
/**
|
|
82 |
* Get the name of the program.
|
|
83 |
*
|
|
84 |
* @return the name of the program
|
|
85 |
*/
|
|
86 | 1 |
public String getName( )
|
87 |
{ |
|
88 | 1 |
return name;
|
89 |
} |
|
90 |
|
|
91 |
/**
|
|
92 |
* Get the function with the specified name.
|
|
93 |
*
|
|
94 |
* @param name the name of the function to get
|
|
95 |
*
|
|
96 |
* @return the function with the specified name
|
|
97 |
*/
|
|
98 | 2 |
public Function getFunction( String name )
|
99 |
{ |
|
100 | 2 |
return ( Function ) functions.get( name );
|
101 |
} |
|
102 |
} |
|
103 |
|
|