##### Coverage Report - org.apache.commons.scxml.model.Transition

Classes in this File | Line Coverage | Branch Coverage | Complexity
Transition |
100% |
100% |
| 1.2727272727272727;1.273

1 |  |
     /*
2 |  |
      *
3 |  |
      *   Copyright 2005-2006 The Apache Software Foundation.
4 |  |
      *
5 |  |
      *  Licensed under the Apache License, Version 2.0 (the "License");
6 |  |
      *  you may not use this file except in compliance with the License.
7 |  |
      *  You may obtain a copy of the License at
8 |  |
      *
9 |  |
      *      http://www.apache.org/licenses/LICENSE-2.0
10 |  |
      *
11 |  |
      *  Unless required by applicable law or agreed to in writing, software
12 |  |
      *  distributed under the License is distributed on an "AS IS" BASIS,
13 |  |
      *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 |  |
      *  See the License for the specific language governing permissions and
15 |  |
      *  limitations under the License.
16 |  |
      *
17 |  |
      */
18 |  |
     package org.apache.commons.scxml.model;
19 |  |
20 |  |
     /**
21 |  |
      * The class in this SCXML object model that corresponds to the
22 |  |
      * &lt;transition&gt; SCXML element. Transition rules are triggered
23 |  |
      * by &quot;events&quot; and conditionalized via
24 |  |
      * &quot;guard-conditions&quot;.
25 |  |
      *
26 |  |
      */
27 |  |
     public class Transition extends Executable {
28 |  |
29 |  |
         /**
30 |  |
          * Property that specifies the trigger for this transition.
31 |  |
          */
32 |  |
         private String event;
33 |  |
34 |  |
         /**
35 |  |
          * Optional guard condition.
36 |  |
          */
37 |  |
         private String cond;
38 |  |
39 |  |
         /**
40 |  |
          * Optional property that specifies the new state or parallel
41 |  |
          * element to transition to. May be specified by reference or in-line.
42 |  |
          */
43 |  |
         private TransitionTarget target;
44 |  |
45 |  |
         /**
46 |  |
          * The transition target ID (used by XML Digester only).
47 |  |
          */
48 |  |
         private String next;
49 |  |
50 |  |
         /**
51 |  |
          * The path for this transition.
52 |  |
          * @see Path
53 |  |
          */
54 |  |
         private Path path;
55 |  |
56 |  |
         /**
57 |  |
          * Constructor.
58 |  |
          */
59 |  |
         public Transition() {
60 | 217 |
             super();
61 | 217 |
             this.target = null;
62 | 217 |
             this.path = null;
63 | 217 |
         }
64 |  |
65 |  |
         /**
66 |  |
          * Get the guard condition (may be null).
67 |  |
          *
68 |  |
          * @return Returns the cond.
69 |  |
          */
70 |  |
         public final String getCond() {
71 | 197 |
             return cond;
72 |  |
         }
73 |  |
74 |  |
         /**
75 |  |
          * Set the guard condition.
76 |  |
          *
77 |  |
          * @param cond The cond to set.
78 |  |
          */
79 |  |
         public final void setCond(final String cond) {
80 | 58 |
             this.cond = cond;
81 | 58 |
         }
82 |  |
83 |  |
         /**
84 |  |
          * Get the event that will trigger this transition (pending
85 |  |
          * evaluation of the guard condition in favor).
86 |  |
          *
87 |  |
          * @return Returns the event.
88 |  |
          */
89 |  |
         public final String getEvent() {
90 | 520 |
             return event;
91 |  |
         }
92 |  |
93 |  |
         /**
94 |  |
          * Set the event that will trigger this transition (pending
95 |  |
          * evaluation of the guard condition in favor).
96 |  |
          *
97 |  |
          * @param event The event to set.
98 |  |
          */
99 |  |
         public final void setEvent(final String event) {
100 | 148 |
             this.event = event;
101 | 148 |
         }
102 |  |
103 |  |
         /**
104 |  |
          * Get the transition target (may be null).
105 |  |
          *
106 |  |
          * @return Returns the target as specified in SCXML markup.
107 |  |
          * <p>Remarks: Is <code>null</code> for &quot;stay&quot; transitions.
108 |  |
          *  Returns parent (the source node) for &quot;self&quot; transitions.</p>
109 |  |
          */
110 |  |
         public final TransitionTarget getTarget() {
111 | 527 |
             return target;
112 |  |
         }
113 |  |
114 |  |
         /**
115 |  |
          * Get the runtime transition target, which always resolves to
116 |  |
          * a TransitionTarget instance.
117 |  |
          *
118 |  |
          * @return Returns the actual target of a transition at runtime.
119 |  |
          * <p>Remarks: For both the &quot;stay&quot; and &quot;self&quot;
120 |  |
          * transitions it returns parent (the source node). This method should
121 |  |
          * never return <code>null</code>.</p>
122 |  |
          */
123 |  |
         public final TransitionTarget getRuntimeTarget() {
124 | 282 |
             if (target != null) {
125 | 280 |
                 return target;
126 |  |
             }
127 | 2 |
             return getParent();
128 |  |
         }
129 |  |
130 |  |
131 |  |
         /**
132 |  |
          * Set the transition target.
133 |  |
          *
134 |  |
          * @param target The target to set.
135 |  |
          */
136 |  |
         public final void setTarget(final TransitionTarget target) {
137 | 206 |
             this.target = target;
138 | 206 |
         }
139 |  |
140 |  |
         /**
141 |  |
          * Get the ID of the transition target (may be null, if, for example,
142 |  |
          * the target is specified inline).
143 |  |
          *
144 |  |
          * @return String Returns the transition target ID
145 |  |
          *                (used by SCXML Digester only).
146 |  |
          * @see #getTarget()
147 |  |
          */
148 |  |
         public final String getNext() {
149 | 233 |
             return next;
150 |  |
         }
151 |  |
152 |  |
         /**
153 |  |
          * Set the transition target by specifying its ID.
154 |  |
          *
155 |  |
          * @param next The the transition target ID (used by SCXML Digester only).
156 |  |
          * @see #setTarget(TransitionTarget)
157 |  |
          */
158 |  |
         public final void setNext(final String next) {
159 | 203 |
             this.next = next;
160 | 203 |
         }
161 |  |
162 |  |
         /**
163 |  |
          * Get the path of this transiton.
164 |  |
          *
165 |  |
          * @see Path
166 |  |
          * @return Path returns the transition path
167 |  |
          */
168 |  |
         public final Path getPath() {
169 | 268 |
             if (path == null) {
170 | 66 |
                 path = new Path(getParent(), getTarget());
171 |  |
             }
172 | 268 |
             return path;
173 |  |
         }
174 |  |
175 |  |
     }
176 |  |