KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > rero > script > GlobalVariables


1 /**
2  *
3  *
4  *
5  **/

6
7 package rero.script;
8  
9 import sleep.interfaces.*;
10 import sleep.runtime.*;
11
12 import rero.ircfw.*;
13
14 import java.util.*;
15
16 public class GlobalVariables implements Variable
17 {
18     protected HashMap data = new HashMap();
19     protected Variable alternateVariables = null;
20     
21
22     public void setOtherVariables(Variable _alternateVariables)
23     {
24        alternateVariables = _alternateVariables;
25     }
26
27     public boolean scalarExists(String JavaDoc key)
28     {
29        if (alternateVariables != null && alternateVariables.scalarExists(key))
30        {
31           return true;
32        }
33
34        return data.containsKey(key);
35     }
36
37     public Scalar getScalar(String JavaDoc key)
38     {
39        if (alternateVariables != null && alternateVariables.scalarExists(key))
40        {
41           return alternateVariables.getScalar(key);
42        }
43
44        return (Scalar)data.get(key);
45     }
46
47     public Scalar putScalar(String JavaDoc key, Scalar value)
48     {
49        return (Scalar)data.put(key, value);
50     }
51
52     public void removeScalar(String JavaDoc key)
53     {
54        data.remove(key);
55     }
56
57     public Variable createLocalVariableContainer() // create our variable container using our hashmap as the base of it.
58
{ // this way the user has access to all of the "local" variables for an
59
return new LocalVariables(); // event. This should also do the $0 $1- $2-3 $-4 stuff
60
}
61
62     public Variable createInternalVariableContainer()
63     {
64        return new GlobalVariables();
65     }
66 }
67
Popular Tags