1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.scxml;
19
20 import java.util.Map;
21
22 /***
23 * A Context or "scope" for storing variables; usually tied to
24 * a SCXML root or State object.
25 */
26 public interface Context {
27 /***
28 * Assigns a new value to an existing variable or creates a new one.
29 * The method searches the chain of parent Contexts for variable
30 * existence.
31 *
32 * @param name The variable name
33 * @param value The variable value
34 */
35 void set(String name, Object value);
36
37 /***
38 * Assigns a new value to an existing variable or creates a new one.
39 * The method allows to shaddow a variable of the same name up the
40 * Context chain.
41 *
42 * @param name The variable name
43 * @param value The variable value
44 */
45 void setLocal(String name, Object value);
46
47 /***
48 * Get the value of this variable; delegating to parent.
49 *
50 * @param name The name of the variable
51 * @return The value (or null)
52 */
53 Object get(String name);
54
55 /***
56 * Check if this variable exists, delegating to parent.
57 *
58 * @param name The name of the variable
59 * @return Whether a variable with the name exists in this Context
60 */
61 boolean has(String name);
62
63 /***
64 * Get the Map of all variables in this Context.
65 *
66 * @return Local variable entries Map
67 * To get variables in parent Context, call getParent().getVars().
68 * @see #getParent()
69 */
70 Map getVars();
71
72 /***
73 * Clear this Context.
74 */
75 void reset();
76
77 /***
78 * Get the parent Context, may be null.
79 *
80 * @return The parent Context in a chained Context environment
81 */
82 Context getParent();
83
84 }