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