1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.scxml.model;
19
20 /***
21 * An abstract base class for elements in SCXML that can serve as a
22 * <target> for a <transition>, such as State or Parallel.
23 *
24 */
25 public abstract class TransitionTarget {
26
27 /***
28 * Identifier for this transition target. Other parts of the SCXML
29 * document may refer to this <state> using this ID.
30 */
31 private String id;
32
33 /***
34 * Optional property holding executable content to be run upon
35 * entering this transition target.
36 */
37 private OnEntry onEntry;
38
39 /***
40 * Optional property holding executable content to be run upon
41 * exiting this transition target.
42 */
43 private OnExit onExit;
44
45 /***
46 * Optional property holding the data model for this transition target.
47 */
48 private Datamodel datamodel;
49
50 /***
51 * The parent of this transition target (may be null, if the parent
52 * is the SCXML document root).
53 */
54 private TransitionTarget parent;
55
56 /***
57 * Constructor.
58 */
59 public TransitionTarget() {
60 super();
61 onEntry = new OnEntry();
62 onEntry.setParent(this);
63 onExit = new OnExit();
64 onExit.setParent(this);
65 parent = null;
66 }
67
68 /***
69 * Get the identifier for this transition target (may be null).
70 *
71 * @return Returns the id.
72 */
73 public final String getId() {
74 return id;
75 }
76
77 /***
78 * Set the identifier for this transition target.
79 *
80 * @param id The id to set.
81 */
82 public final void setId(final String id) {
83 this.id = id;
84 }
85
86 /***
87 * Get the onentry property.
88 *
89 * @return Returns the onEntry.
90 */
91 public final OnEntry getOnEntry() {
92 return onEntry;
93 }
94
95 /***
96 * Set the onentry property.
97 *
98 * @param onEntry The onEntry to set.
99 */
100 public final void setOnEntry(final OnEntry onEntry) {
101 this.onEntry = onEntry;
102 }
103
104 /***
105 * Get the onexit property.
106 *
107 * @return Returns the onExit.
108 */
109 public final OnExit getOnExit() {
110 return onExit;
111 }
112
113 /***
114 * Set the onexit property.
115 *
116 * @param onExit The onExit to set.
117 */
118 public final void setOnExit(final OnExit onExit) {
119 this.onExit = onExit;
120 }
121
122 /***
123 * Get the data model for this transition target.
124 *
125 * @return Returns the data model.
126 */
127 public final Datamodel getDatamodel() {
128 return datamodel;
129 }
130
131 /***
132 * Set the data model for this transition target.
133 *
134 * @param datamodel The Datamodel to set.
135 */
136 public final void setDatamodel(final Datamodel datamodel) {
137 this.datamodel = datamodel;
138 }
139
140 /***
141 * Get the parent TransitionTarget.
142 *
143 * @return Returns the parent state
144 * (null if parent is <scxml> element)
145 */
146 public final TransitionTarget getParent() {
147 return parent;
148 }
149
150 /***
151 * Set the parent TransitionTarget.
152 *
153 * @param parent The parent state to set
154 */
155 public final void setParent(final TransitionTarget parent) {
156 this.parent = parent;
157 }
158
159 /***
160 * Get the parent State.
161 *
162 * @return The parent State
163 */
164 public final State getParentState() {
165 TransitionTarget tt = this.getParent();
166 if (tt == null) {
167 return null;
168 } else {
169 if (tt instanceof State) {
170 return (State) tt;
171 } else {
172 return tt.getParentState();
173 }
174 }
175 }
176
177 }
178