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