You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by at...@apache.org on 2014/03/23 00:34:23 UTC
svn commit: r1580369 [2/5] - in /commons/proper/scxml/trunk/src:
main/java/org/apache/commons/scxml2/ main/java/org/apache/commons/scxml2/env/
main/java/org/apache/commons/scxml2/env/groovy/
main/java/org/apache/commons/scxml2/env/jexl/ main/java/org/a...
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java Sat Mar 22 23:34:20 2014
@@ -25,7 +25,6 @@ import java.net.URL;
import java.net.URLConnection;
import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.EmptyStackException;
import java.util.HashMap;
import java.util.List;
@@ -61,6 +60,8 @@ import org.apache.commons.scxml2.model.D
import org.apache.commons.scxml2.model.Datamodel;
import org.apache.commons.scxml2.model.Else;
import org.apache.commons.scxml2.model.ElseIf;
+import org.apache.commons.scxml2.model.EnterableState;
+import org.apache.commons.scxml2.model.TransitionalState;
import org.apache.commons.scxml2.model.Raise;
import org.apache.commons.scxml2.model.Executable;
import org.apache.commons.scxml2.model.ExternalContent;
@@ -81,9 +82,9 @@ import org.apache.commons.scxml2.model.P
import org.apache.commons.scxml2.model.SCXML;
import org.apache.commons.scxml2.model.Script;
import org.apache.commons.scxml2.model.Send;
+import org.apache.commons.scxml2.model.SimpleTransition;
import org.apache.commons.scxml2.model.State;
import org.apache.commons.scxml2.model.Transition;
-import org.apache.commons.scxml2.model.TransitionTarget;
import org.apache.commons.scxml2.model.TransitionType;
import org.apache.commons.scxml2.model.Var;
import org.w3c.dom.Attr;
@@ -255,7 +256,6 @@ public final class SCXMLReader {
private static final String ELEM_SEND = "send";
private static final String ELEM_STATE = "state";
private static final String ELEM_TRANSITION = "transition";
- private static final String ELEM_VALIDATE = "validate";
private static final String ELEM_VAR = "var";
//---- ATTRIBUTE NAMES ----//
@@ -265,7 +265,6 @@ public final class SCXMLReader {
private static final String ATTR_EVENT = "event";
private static final String ATTR_EXMODE = "exmode";
private static final String ATTR_EXPR = "expr";
- private static final String ATTR_FINAL = "final";
private static final String ATTR_HINTS = "hints";
private static final String ATTR_ID = "id";
private static final String ATTR_INDEX = "index";
@@ -664,7 +663,7 @@ public final class SCXMLReader {
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
* @param scxml The root of the object model being parsed.
- * @param parent The parent {@link TransitionTarget} for this state (null for top level state).
+ * @param parent The parent {@link TransitionalState} for this state (null for top level state).
*
* @throws IOException An IO error during parsing.
* @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
@@ -672,7 +671,7 @@ public final class SCXMLReader {
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
private static void readState(final XMLStreamReader reader, final Configuration configuration, final SCXML scxml,
- final TransitionTarget parent)
+ final TransitionalState parent)
throws IOException, ModelException, XMLStreamException {
State state = new State();
@@ -681,10 +680,6 @@ public final class SCXMLReader {
if (initial != null) {
state.setFirst(initial);
}
- String isFinal = readAV(reader, ATTR_FINAL);
- if ("true".equals(isFinal)) {
- state.setFinal(true);
- }
String src = readAV(reader, ATTR_SRC);
if (src != null) {
String source = src;
@@ -696,7 +691,17 @@ public final class SCXMLReader {
source = configuration.pathResolver.resolvePath(src);
copy.pathResolver = configuration.pathResolver.getResolver(src);
}
- readTransitionTargetSrc(copy, source, state);
+ readTransitionalStateSrc(copy, source, state);
+ }
+
+ if (parent == null) {
+ scxml.addChild(state);
+ } else {
+ parent.addChild(state);
+ }
+ scxml.addTarget(state);
+ if (configuration.parent != null) {
+ configuration.parent.addTarget(state);
}
loop : while (reader.hasNext()) {
@@ -708,7 +713,7 @@ public final class SCXMLReader {
name = reader.getLocalName();
if (XMLNS_SCXML.equals(nsURI)) {
if (ELEM_TRANSITION.equals(name)) {
- readTransition(reader, configuration, state);
+ state.addTransition(readTransition(reader, configuration));
} else if (ELEM_STATE.equals(name)) {
readState(reader, configuration, scxml, state);
} else if (ELEM_INITIAL.equals(name)) {
@@ -716,9 +721,9 @@ public final class SCXMLReader {
} else if (ELEM_FINAL.equals(name)) {
readFinal(reader, configuration, scxml, state);
} else if (ELEM_ONENTRY.equals(name)) {
- readOnEntry(reader, configuration, scxml, state);
+ readOnEntry(reader, configuration, state);
} else if (ELEM_ONEXIT.equals(name)) {
- readOnExit(reader, configuration, scxml, state);
+ readOnExit(reader, configuration, state);
} else if (ELEM_PARALLEL.equals(name)) {
readParallel(reader, configuration, scxml, state);
} else if (ELEM_DATAMODEL.equals(name)) {
@@ -745,18 +750,6 @@ public final class SCXMLReader {
default:
}
}
-
- if (parent == null) {
- scxml.addChild(state);
- } else if (parent instanceof State) {
- ((State) parent).addChild(state);
- } else if (parent instanceof Parallel) {
- ((Parallel) parent).addChild(state);
- }
- scxml.addTarget(state);
- if (configuration.parent != null) {
- configuration.parent.addTarget(state);
- }
}
/**
@@ -765,7 +758,7 @@ public final class SCXMLReader {
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
* @param scxml The root of the object model being parsed.
- * @param parent The parent {@link TransitionTarget} for this parallel (null for top level state).
+ * @param parent The parent {@link TransitionalState} for this parallel (null for top level state).
*
* @throws IOException An IO error during parsing.
* @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
@@ -773,7 +766,7 @@ public final class SCXMLReader {
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
private static void readParallel(final XMLStreamReader reader, final Configuration configuration, final SCXML scxml,
- final TransitionTarget parent)
+ final TransitionalState parent)
throws IOException, ModelException, XMLStreamException {
Parallel parallel = new Parallel();
@@ -789,7 +782,17 @@ public final class SCXMLReader {
source = configuration.pathResolver.resolvePath(src);
copy.pathResolver = configuration.pathResolver.getResolver(src);
}
- readTransitionTargetSrc(copy, source, parallel);
+ readTransitionalStateSrc(copy, source, parallel);
+ }
+
+ if (parent == null) {
+ scxml.addChild(parallel);
+ } else {
+ parent.addChild(parallel);
+ }
+ scxml.addTarget(parallel);
+ if (configuration.parent != null) {
+ configuration.parent.addTarget(parallel);
}
loop : while (reader.hasNext()) {
@@ -801,16 +804,18 @@ public final class SCXMLReader {
name = reader.getLocalName();
if (XMLNS_SCXML.equals(nsURI)) {
if (ELEM_TRANSITION.equals(name)) {
- readTransition(reader, configuration, parallel);
+ parallel.addTransition(readTransition(reader, configuration));
} else if (ELEM_STATE.equals(name)) {
readState(reader, configuration, scxml, parallel);
} else if (ELEM_ONENTRY.equals(name)) {
- readOnEntry(reader, configuration, scxml, parallel);
+ readOnEntry(reader, configuration, parallel);
} else if (ELEM_ONEXIT.equals(name)) {
- readOnExit(reader, configuration, scxml, parallel);
+ readOnExit(reader, configuration, parallel);
} else if (ELEM_DATAMODEL.equals(name)) {
readDatamodel(reader, configuration, null, parallel);
- } else if (ELEM_HISTORY.equals(name)) { // TODO Check parallel history
+ } else if (ELEM_INVOKE.equals(name)) {
+ readInvoke(reader, configuration, parallel);
+ } else if (ELEM_HISTORY.equals(name)) {
readHistory(reader, configuration, scxml, parallel);
} else {
reportIgnoredElement(reader, configuration, ELEM_PARALLEL, nsURI, name);
@@ -830,17 +835,6 @@ public final class SCXMLReader {
default:
}
}
-
- if (parent == null) {
- scxml.addChild(parallel);
- } else if (parent instanceof State) {
- ((State) parent).addChild(parallel);
- }
- // TODO parallel child of parallel?
- scxml.addTarget(parallel);
- if (configuration.parent != null) {
- configuration.parent.addTarget(parallel);
- }
}
/**
@@ -849,19 +843,31 @@ public final class SCXMLReader {
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
* @param scxml The root of the object model being parsed.
- * @param parent The parent {@link TransitionTarget} for this final (null for top level state).
+ * @param parent The parent {@link State} for this final (null for top level state).
*
+ * @throws IOException An IO error during parsing.
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
* @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
* errors in the SCXML document that may not be identified by the schema).
*/
private static void readFinal(final XMLStreamReader reader, final Configuration configuration, final SCXML scxml,
- final TransitionTarget parent)
- throws XMLStreamException, ModelException {
+ final State parent)
+ throws XMLStreamException, ModelException, IOException {
Final end = new Final();
end.setId(readOrGeneratedTransitionTargetId(reader, scxml, ELEM_FINAL));
+ if (parent == null) {
+ scxml.addChild(end);
+ } else {
+ parent.addChild(end);
+ }
+
+ scxml.addTarget(end);
+ if (configuration.parent != null) {
+ configuration.parent.addTarget(end);
+ }
+
loop : while (reader.hasNext()) {
String name, nsURI;
switch (reader.next()) {
@@ -871,9 +877,9 @@ public final class SCXMLReader {
name = reader.getLocalName();
if (XMLNS_SCXML.equals(nsURI)) {
if (ELEM_ONENTRY.equals(name)) {
- readOnEntry(reader, configuration, scxml, end);
+ readOnEntry(reader, configuration, end);
} else if (ELEM_ONEXIT.equals(name)) {
- readOnExit(reader, configuration, scxml, end);
+ readOnExit(reader, configuration, end);
} else {
reportIgnoredElement(reader, configuration, ELEM_FINAL, nsURI, name);
}
@@ -892,13 +898,6 @@ public final class SCXMLReader {
default:
}
}
-
- if (parent == null) {
- scxml.addChild(end);
- } else if (parent instanceof State) {
- ((State) parent).addChild(end);
- }
- scxml.addTarget(end);
}
/**
@@ -909,15 +908,15 @@ public final class SCXMLReader {
*
* @param configuration The {@link Configuration} to use while parsing.
* @param src The "src" attribute value.
- * @param tt The parent {@link TransitionTarget} that specifies this "src" attribute.
+ * @param ts The parent {@link TransitionalState} that specifies this "src" attribute.
*
* @throws IOException An IO error during parsing.
* @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
* errors in the SCXML document that may not be identified by the schema).
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
- private static void readTransitionTargetSrc(final Configuration configuration, final String src,
- final TransitionTarget tt)
+ private static void readTransitionalStateSrc(final Configuration configuration, final String src,
+ final TransitionalState ts)
throws IOException, ModelException, XMLStreamException {
// Check for URI fragment
@@ -939,21 +938,20 @@ public final class SCXMLReader {
}
// Pull in the parts of the external document as needed
- State s = (State) tt;
if (fragment == null) {
// All targets pulled in since its not a src fragment
- if (tt instanceof State) {
+ if (ts instanceof State) {
+ State s = (State) ts;
Initial ini = new Initial();
- Transition t = new Transition();
+ SimpleTransition t = new SimpleTransition();
t.setNext(externalSCXML.getInitial());
ini.setTransition(t);
s.setInitial(ini);
- Collection<TransitionTarget> children = externalSCXML.getChildren().values();
- for (TransitionTarget child : children) {
+ for (EnterableState child : externalSCXML.getChildren()) {
s.addChild(child);
}
s.setDatamodel(externalSCXML.getDatamodel());
- } else if (tt instanceof Parallel) {
+ } else if (ts instanceof Parallel) {
// TODO src attribute for <parallel>
}
} else {
@@ -964,7 +962,8 @@ public final class SCXMLReader {
String errMsg = msgFormat.format(new Object[] {src});
throw new ModelException(errMsg);
}
- if (source instanceof State) {
+ if (source instanceof State && ts instanceof State) {
+ State s = (State) ts;
State include = (State) source;
s.setOnEntry(include.getOnEntry());
s.setOnExit(include.getOnExit());
@@ -974,15 +973,12 @@ public final class SCXMLReader {
s.addHistory(h);
configuration.parent.addTarget(h);
}
- Collection<TransitionTarget> children = include.getChildren().
- values();
- for (TransitionTarget child : children) {
+ for (EnterableState child : include.getChildren()) {
s.addChild(child);
configuration.parent.addTarget(child);
readInExternalTargets(configuration.parent, child);
}
s.setInvoke(include.getInvoke());
- s.setFinal(include.isFinal());
if (include.getInitial() != null) {
s.setInitial(include.getInitial());
}
@@ -990,7 +986,7 @@ public final class SCXMLReader {
for (Transition t : transitions) {
s.addTransition(t);
}
- } else if (tt instanceof Parallel) {
+ } else if (ts instanceof Parallel && source instanceof Parallel) {
// TODO src attribute for <parallel>
} else {
MessageFormat msgFormat =
@@ -1005,23 +1001,14 @@ public final class SCXMLReader {
* Add all the nested targets from given target to given parent state machine.
*
* @param parent The state machine
- * @param tt The transition target to import
+ * @param es The target to import
*/
- private static void readInExternalTargets(final SCXML parent, final TransitionTarget tt) {
- List<History> histories = tt.getHistory();
- for (History h : histories) {
- parent.addTarget(h);
- }
- if (tt instanceof State) {
- Collection<TransitionTarget> children = ((State) tt).getChildren().
- values();
- for (TransitionTarget child : children) {
- parent.addTarget(child);
- readInExternalTargets(parent, child);
+ private static void readInExternalTargets(final SCXML parent, final EnterableState es) {
+ if (es instanceof TransitionalState) {
+ for (History h : ((TransitionalState)es).getHistory()) {
+ parent.addTarget(h);
}
- } else if (tt instanceof Parallel) {
- Collection<TransitionTarget> children = ((Parallel) tt).getChildren();
- for (TransitionTarget child : children) {
+ for (EnterableState child : ((TransitionalState) es).getChildren()) {
parent.addTarget(child);
readInExternalTargets(parent, child);
}
@@ -1034,14 +1021,14 @@ public final class SCXMLReader {
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
* @param scxml The root of the object model being parsed.
- * @param parent The parent {@link TransitionTarget} for this datamodel (null for top level).
+ * @param parent The parent {@link TransitionalState} for this datamodel (null for top level).
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
* @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
* errors in the SCXML document that may not be identified by the schema).
*/
- private static void readDatamodel(final XMLStreamReader reader, final Configuration configuration, final SCXML scxml,
- final TransitionTarget parent)
+ private static void readDatamodel(final XMLStreamReader reader, final Configuration configuration,
+ final SCXML scxml, final TransitionalState parent)
throws XMLStreamException, ModelException {
Datamodel dm = new Datamodel();
@@ -1107,14 +1094,14 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param parent The parent {@link State} for this invoke.
+ * @param parent The parent {@link TransitionalState} for this invoke.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
* @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
* errors in the SCXML document that may not be identified by the schema).
*/
private static void readInvoke(final XMLStreamReader reader, final Configuration configuration,
- final State parent)
+ final TransitionalState parent)
throws XMLStreamException, ModelException {
Invoke invoke = new Invoke();
@@ -1185,7 +1172,7 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param state The {@link State} which contains the parent {@link Invoke}.
+ * @param state The {@link TransitionalState} which contains the parent {@link Invoke}.
* @param invoke The parent {@link Invoke} for this finalize.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
@@ -1193,11 +1180,11 @@ public final class SCXMLReader {
* errors in the SCXML document that may not be identified by the schema).
*/
private static void readFinalize(final XMLStreamReader reader, final Configuration configuration,
- final State state, final Invoke invoke)
+ final TransitionalState state, final Invoke invoke)
throws XMLStreamException, ModelException {
Finalize finalize = new Finalize();
- readExecutableContext(reader, configuration, state, finalize, null);
+ readExecutableContext(reader, configuration, finalize, null);
invoke.setFinalize(finalize);
finalize.setParent(state);
}
@@ -1207,13 +1194,13 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param state The {@link State} which contains the parent {@link Invoke}.
+ * @param state The {@link TransitionalState} which contains the parent {@link Invoke}.
* @param invoke The parent {@link Invoke} for this content.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
private static void readContent(final XMLStreamReader reader, final Configuration configuration,
- final State state, final Invoke invoke)
+ final TransitionalState state, final Invoke invoke)
throws XMLStreamException {
// TODO content support
@@ -1245,7 +1232,7 @@ public final class SCXMLReader {
name = reader.getLocalName();
if (XMLNS_SCXML.equals(nsURI)) {
if (ELEM_TRANSITION.equals(name)) {
- readTransition(reader, configuration, initial);
+ initial.setTransition(readSimpleTransition(reader, configuration));
} else {
reportIgnoredElement(reader, configuration, ELEM_INITIAL, nsURI, name);
}
@@ -1265,7 +1252,6 @@ public final class SCXMLReader {
}
}
- initial.setParent(state);
state.setInitial(initial);
}
@@ -1275,20 +1261,23 @@ public final class SCXMLReader {
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
* @param scxml The root of the object model being parsed.
- * @param tt The parent {@link TransitionTarget} for this history.
+ * @param ts The parent {@link org.apache.commons.scxml2.model.TransitionalState} for this history.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
* @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
* errors in the SCXML document that may not be identified by the schema).
*/
private static void readHistory(final XMLStreamReader reader, final Configuration configuration,
- final SCXML scxml, final TransitionTarget tt)
+ final SCXML scxml, final TransitionalState ts)
throws XMLStreamException, ModelException {
History history = new History();
history.setId(readOrGeneratedTransitionTargetId(reader, scxml, ELEM_HISTORY));
history.setType(readAV(reader, ATTR_TYPE));
+ ts.addHistory(history);
+ scxml.addTarget(history);
+
loop : while (reader.hasNext()) {
String name, nsURI;
switch (reader.next()) {
@@ -1298,7 +1287,7 @@ public final class SCXMLReader {
name = reader.getLocalName();
if (XMLNS_SCXML.equals(nsURI)) {
if (ELEM_TRANSITION.equals(name)) {
- readTransition(reader, configuration, history);
+ history.setTransition(readTransition(reader, configuration));
} else {
reportIgnoredElement(reader, configuration, ELEM_HISTORY, nsURI, name);
}
@@ -1317,10 +1306,6 @@ public final class SCXMLReader {
default:
}
}
-
- history.setParent(tt);
- tt.addHistory(history);
- scxml.addTarget(history);
}
/**
@@ -1328,20 +1313,19 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param scxml The root of the object model being parsed.
- * @param tt The parent {@link TransitionTarget} for this onentry.
+ * @param es The parent {@link EnterableState} for this onentry.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
* @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
* errors in the SCXML document that may not be identified by the schema).
*/
- private static void readOnEntry(final XMLStreamReader reader, final Configuration configuration, final SCXML scxml,
- final TransitionTarget tt)
+ private static void readOnEntry(final XMLStreamReader reader, final Configuration configuration,
+ final EnterableState es)
throws XMLStreamException, ModelException {
OnEntry onentry = new OnEntry();
- readExecutableContext(reader, configuration, tt, onentry, null);
- tt.setOnEntry(onentry);
+ readExecutableContext(reader, configuration, onentry, null);
+ es.setOnEntry(onentry);
}
/**
@@ -1349,45 +1333,40 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param scxml The root of the object model being parsed.
- * @param tt The parent {@link TransitionTarget} for this onexit.
+ * @param es The parent {@link EnterableState} for this onexit.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
* @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
* errors in the SCXML document that may not be identified by the schema).
*/
- private static void readOnExit(final XMLStreamReader reader, final Configuration configuration, final SCXML scxml,
- final TransitionTarget tt)
+ private static void readOnExit(final XMLStreamReader reader, final Configuration configuration,
+ final EnterableState es)
throws XMLStreamException, ModelException {
OnExit onexit = new OnExit();
- readExecutableContext(reader, configuration, tt, onexit, null);
- tt.setOnExit(onexit);
+ readExecutableContext(reader, configuration, onexit, null);
+ es.setOnExit(onexit);
}
/**
- * Read the contents of this <transition> element.
+ * Read the contents of this simple <transition> element.
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this transition.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
* @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
* errors in the SCXML document that may not be identified by the schema).
*/
- private static void readTransition(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt)
+ private static SimpleTransition readSimpleTransition(final XMLStreamReader reader, final Configuration configuration)
throws XMLStreamException, ModelException {
- Transition t = new Transition();
- t.setCond(readAV(reader, ATTR_COND));
- t.setEvent(readAV(reader, ATTR_EVENT));
- t.setNext(readAV(reader, ATTR_TARGET));
+ SimpleTransition transition = new SimpleTransition();
+ transition.setNext(readAV(reader, ATTR_TARGET));
String type = readAV(reader, ATTR_TYPE);
if (type != null) {
try {
- t.setType(TransitionType.valueOf(type));
+ transition.setType(TransitionType.valueOf(type));
}
catch (IllegalArgumentException e) {
MessageFormat msgFormat = new MessageFormat(ERR_UNSUPPORTED_TRANSITION_TYPE);
@@ -1396,19 +1375,45 @@ public final class SCXMLReader {
}
}
- readNamespaces(configuration, t);
+ readNamespaces(configuration, transition);
+ readExecutableContext(reader, configuration, transition, null);
- readExecutableContext(reader, configuration, tt, t, null);
+ return transition;
+ }
- if (tt instanceof State || tt instanceof Parallel) {
- tt.addTransition(t);
- } else if (tt instanceof Initial) {
- ((Initial) tt).setTransition(t);
- } else if (tt instanceof History) {
- ((History) tt).setTransition(t);
- } else {
- // TODO Error
+ /**
+ * Read the contents of this <transition> element.
+ *
+ * @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
+ * @param configuration The {@link Configuration} to use while parsing.
+ *
+ * @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
+ * @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
+ * errors in the SCXML document that may not be identified by the schema).
+ */
+ private static Transition readTransition(final XMLStreamReader reader, final Configuration configuration)
+ throws XMLStreamException, ModelException {
+
+ Transition transition = new Transition();
+ transition.setCond(readAV(reader, ATTR_COND));
+ transition.setEvent(readAV(reader, ATTR_EVENT));
+ transition.setNext(readAV(reader, ATTR_TARGET));
+ String type = readAV(reader, ATTR_TYPE);
+ if (type != null) {
+ try {
+ transition.setType(TransitionType.valueOf(type));
+ }
+ catch (IllegalArgumentException e) {
+ MessageFormat msgFormat = new MessageFormat(ERR_UNSUPPORTED_TRANSITION_TYPE);
+ String errMsg = msgFormat.format(new Object[] {type, reader.getLocation()});
+ throw new ModelException(errMsg);
+ }
}
+
+ readNamespaces(configuration, transition);
+ readExecutableContext(reader, configuration, transition, null);
+
+ return transition;
}
/**
@@ -1416,7 +1421,6 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this executable content.
* @param executable The parent {@link Executable} to which this content belongs.
* @param parent The optional parent {@link ActionsContainer} if this is child content of an ActionsContainer action.
*
@@ -1425,13 +1429,13 @@ public final class SCXMLReader {
* errors in the SCXML document that may not be identified by the schema).
*/
private static void readExecutableContext(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final ActionsContainer parent)
+ final Executable executable, final ActionsContainer parent)
throws XMLStreamException, ModelException {
String end = "";
if (parent != null) {
end = parent.getContainerElementName();
- } else if (executable instanceof Transition) {
+ } else if (executable instanceof SimpleTransition) {
end = ELEM_TRANSITION;
} else if (executable instanceof OnEntry) {
end = ELEM_ONENTRY;
@@ -1450,33 +1454,31 @@ public final class SCXMLReader {
name = reader.getLocalName();
if (XMLNS_SCXML.equals(nsURI)) {
if (ELEM_RAISE.equals(name)) {
- readRaise(reader, configuration, tt, executable, parent);
+ readRaise(reader, configuration, executable, parent);
} else if (ELEM_FOREACH.equals(name)) {
- readForeach(reader, configuration, tt, executable, parent);
+ readForeach(reader, configuration, executable, parent);
} else if (ELEM_IF.equals(name)) {
- readIf(reader, configuration, tt, executable, parent);
+ readIf(reader, configuration, executable, parent);
} else if (ELEM_LOG.equals(name)) {
- readLog(reader, configuration, tt, executable, parent);
+ readLog(reader, configuration, executable, parent);
} else if (ELEM_ASSIGN.equals(name)) {
- readAssign(reader, configuration, tt, executable, parent);
- } else if (ELEM_VALIDATE.equals(name)) {
- readValidate(reader, configuration, tt, executable, parent);
+ readAssign(reader, configuration, executable, parent);
} else if (ELEM_SEND.equals(name)) {
- readSend(reader, configuration, tt, executable, parent);
+ readSend(reader, configuration, executable, parent);
} else if (ELEM_CANCEL.equals(name)) {
- readCancel(reader, configuration, tt, executable, parent);
+ readCancel(reader, configuration, executable, parent);
} else if (ELEM_SCRIPT.equals(name)) {
- readScript(reader, configuration, tt, executable, parent);
+ readScript(reader, configuration, executable, parent);
} else if (ELEM_IF.equals(end) && ELEM_ELSEIF.equals(name)) {
- readElseIf(reader, configuration, tt, executable, (If) parent);
+ readElseIf(reader, configuration, executable, (If) parent);
} else if (ELEM_IF.equals(end) && ELEM_ELSE.equals(name)) {
- readElse(reader, configuration, tt, executable, (If)parent);
+ readElse(reader, configuration, executable, (If)parent);
} else {
reportIgnoredElement(reader, configuration, end, nsURI, name);
}
} else if (XMLNS_COMMONS_SCXML.equals(nsURI)) {
if (ELEM_VAR.equals(name)) {
- readVar(reader, configuration, tt, executable, parent);
+ readVar(reader, configuration, executable, parent);
} else {
reportIgnoredElement(reader, configuration, end, nsURI, name);
}
@@ -1490,7 +1492,7 @@ public final class SCXMLReader {
}
}
if (customAction != null) {
- readCustomAction(reader, configuration, customAction, tt, executable, parent);
+ readCustomAction(reader, configuration, customAction, executable, parent);
} else {
reportIgnoredElement(reader, configuration, end, nsURI, name);
}
@@ -1514,7 +1516,6 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
* @param executable The parent {@link Executable} for this action.
* @param parent The optional parent {@link ActionsContainer} if this action is a child of one.
*
@@ -1523,7 +1524,7 @@ public final class SCXMLReader {
* errors in the SCXML document that may not be identified by the schema).
*/
private static void readRaise(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final ActionsContainer parent)
+ final Executable executable, final ActionsContainer parent)
throws XMLStreamException, ModelException {
if (executable instanceof Finalize) {
@@ -1549,7 +1550,6 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
* @param executable The parent {@link Executable} for this action.
* @param parent The optional parent {@link ActionsContainer} if this <if> is a child of one.
*
@@ -1558,7 +1558,7 @@ public final class SCXMLReader {
* errors in the SCXML document that may not be identified by the schema).
*/
private static void readIf(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final ActionsContainer parent)
+ final Executable executable, final ActionsContainer parent)
throws XMLStreamException, ModelException {
If iff = new If();
@@ -1570,7 +1570,7 @@ public final class SCXMLReader {
} else {
executable.addAction(iff);
}
- readExecutableContext(reader, configuration, tt, executable, iff);
+ readExecutableContext(reader, configuration, executable, iff);
}
/**
@@ -1578,14 +1578,13 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
* @param executable The parent {@link Executable} for this action.
* @param iff The parent {@link If} for this <elseif>.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
private static void readElseIf(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final If iff)
+ final Executable executable, final If iff)
throws XMLStreamException, ModelException {
ElseIf elseif = new ElseIf();
@@ -1600,14 +1599,13 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
* @param executable The parent {@link Executable} for this action.
* @param iff The parent {@link If} for this <else>.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
private static void readElse(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final If iff)
+ final Executable executable, final If iff)
throws XMLStreamException {
Else els = new Else();
@@ -1621,7 +1619,6 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
* @param executable The parent {@link Executable} for this action.
* @param parent The optional parent {@link ActionsContainer} if this <foreach> is a child of one.
*
@@ -1630,7 +1627,7 @@ public final class SCXMLReader {
* errors in the SCXML document that may not be identified by the schema).
*/
private static void readForeach(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final ActionsContainer parent)
+ final Executable executable, final ActionsContainer parent)
throws XMLStreamException, ModelException {
Foreach fe = new Foreach();
@@ -1644,7 +1641,7 @@ public final class SCXMLReader {
} else {
executable.addAction(fe);
}
- readExecutableContext(reader, configuration, tt, executable, fe);
+ readExecutableContext(reader, configuration, executable, fe);
}
/**
@@ -1652,14 +1649,13 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
* @param executable The parent {@link Executable} for this action.
* @param parent The optional parent {@link ActionsContainer} if this action is a child of one.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
private static void readLog(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final ActionsContainer parent)
+ final Executable executable, final ActionsContainer parent)
throws XMLStreamException {
Log log = new Log();
@@ -1679,14 +1675,13 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
* @param executable The parent {@link Executable} for this action.
* @param parent The optional parent {@link ActionsContainer} if this action is a child of one.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
private static void readAssign(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final ActionsContainer parent)
+ final Executable executable, final ActionsContainer parent)
throws XMLStreamException, ModelException {
Assign assign = new Assign();
@@ -1711,29 +1706,10 @@ public final class SCXMLReader {
}
/**
- * Read the contents of this <validate> element.
- *
- * @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
- * @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
- * @param executable The parent {@link Executable} for this action.
- * @param parent The optional parent {@link ActionsContainer} if this action is a child of one.
- *
- * @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
- */
- private static void readValidate(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final ActionsContainer parent)
- throws XMLStreamException {
-
- // TODO validate support
- }
-
- /**
* Read the contents of this <send> element.
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
* @param executable The parent {@link Executable} for this action.
* @param parent The optional parent {@link ActionsContainer} if this action is a child of one.
*
@@ -1742,7 +1718,7 @@ public final class SCXMLReader {
* errors in the SCXML document that may not be identified by the schema).
*/
private static void readSend(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final ActionsContainer parent)
+ final Executable executable, final ActionsContainer parent)
throws XMLStreamException, ModelException {
if (executable instanceof Finalize) {
@@ -1782,14 +1758,13 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
* @param executable The parent {@link Executable} for this action.
* @param parent The optional parent {@link ActionsContainer} if this action is a child of one.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
private static void readCancel(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final ActionsContainer parent)
+ final Executable executable, final ActionsContainer parent)
throws XMLStreamException {
Cancel cancel = new Cancel();
@@ -1807,14 +1782,13 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
* @param executable The parent {@link Executable} for this action.
* @param parent The optional parent {@link ActionsContainer} if this action is a child of one.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
private static void readScript(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final ActionsContainer parent)
+ final Executable executable, final ActionsContainer parent)
throws XMLStreamException {
Script script = new Script();
@@ -1830,7 +1804,8 @@ public final class SCXMLReader {
/**
* Read the contents of the initial <script> element.
- * @see <a href="http://www.w3.org/TR/2013/WD-scxml-20130801/#scxml">http://www.w3.org/TR/2013/WD-scxml-20130801/#scxml<a> section 3.2.2
+ * @see <a href="http://www.w3.org/TR/2013/WD-scxml-20130801/#scxml">
+ * http://www.w3.org/TR/2013/WD-scxml-20130801/#scxml<a> section 3.2.2
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
@@ -1854,14 +1829,13 @@ public final class SCXMLReader {
*
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
- * @param tt The parent {@link TransitionTarget} for this action.
* @param executable The parent {@link Executable} for this action.
* @param parent The optional parent {@link ActionsContainer} if this action is a child of one.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
private static void readVar(final XMLStreamReader reader, final Configuration configuration,
- final TransitionTarget tt, final Executable executable, final ActionsContainer parent)
+ final Executable executable, final ActionsContainer parent)
throws XMLStreamException {
Var var = new Var();
@@ -1882,14 +1856,13 @@ public final class SCXMLReader {
* @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
* @param configuration The {@link Configuration} to use while parsing.
* @param customAction The {@link CustomAction} to read.
- * @param tt The parent {@link TransitionTarget} for this custom action.
* @param executable The parent {@link Executable} for this custom action.
* @param parent The optional parent {@link ActionsContainer} if this custom action is a child of one.
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
*/
private static void readCustomAction(final XMLStreamReader reader, final Configuration configuration,
- final CustomAction customAction, final TransitionTarget tt, final Executable executable,
+ final CustomAction customAction, final Executable executable,
final ActionsContainer parent)
throws XMLStreamException {
@@ -2202,9 +2175,11 @@ public final class SCXMLReader {
throws XMLStreamException, ModelException {
org.apache.commons.logging.Log log = LogFactory.getLog(SCXMLReader.class);
- StringBuffer sb = new StringBuffer();
- sb.append("Ignoring unknown or invalid element <").append(name).append("> in namespace \"").append(nsURI).append("\" as child ").
- append(" of <").append(parent).append("> at ").append(reader.getLocation());
+ StringBuilder sb = new StringBuilder();
+ sb.append("Ignoring unknown or invalid element <").append(name)
+ .append("> in namespace \"").append(nsURI)
+ .append("\" as child of <").append(parent)
+ .append("> at ").append(reader.getLocation());
if (!configuration.isSilent() && log.isWarnEnabled()) {
log.warn(sb.toString());
}
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLWriter.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLWriter.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLWriter.java Sat Mar 22 23:34:20 2014
@@ -50,6 +50,7 @@ import org.apache.commons.scxml2.model.D
import org.apache.commons.scxml2.model.Datamodel;
import org.apache.commons.scxml2.model.Else;
import org.apache.commons.scxml2.model.ElseIf;
+import org.apache.commons.scxml2.model.EnterableState;
import org.apache.commons.scxml2.model.Raise;
import org.apache.commons.scxml2.model.ExternalContent;
import org.apache.commons.scxml2.model.Final;
@@ -67,6 +68,7 @@ import org.apache.commons.scxml2.model.P
import org.apache.commons.scxml2.model.SCXML;
import org.apache.commons.scxml2.model.Script;
import org.apache.commons.scxml2.model.Send;
+import org.apache.commons.scxml2.model.SimpleTransition;
import org.apache.commons.scxml2.model.State;
import org.apache.commons.scxml2.model.Transition;
import org.apache.commons.scxml2.model.TransitionTarget;
@@ -150,7 +152,6 @@ public class SCXMLWriter {
private static final String ELEM_SEND = "send";
private static final String ELEM_STATE = "state";
private static final String ELEM_TRANSITION = "transition";
- //private static final String ELEM_VALIDATE = "validate"; TODO
private static final String ELEM_VAR = "var";
//---- ATTRIBUTE NAMES ----//
@@ -160,7 +161,6 @@ public class SCXMLWriter {
private static final String ATTR_EVENT = "event";
private static final String ATTR_EXMODE = "exmode";
private static final String ATTR_EXPR = "expr";
- private static final String ATTR_FINAL = "final";
private static final String ATTR_HINTS = "hints";
private static final String ATTR_ID = "id";
private static final String ATTR_INDEX = "index";
@@ -448,13 +448,13 @@ public class SCXMLWriter {
// Children
writeDatamodel(writer, scxml.getDatamodel());
- for (TransitionTarget tt : scxml.getChildren().values()) {
- if (tt instanceof Final) {
- writeFinal(writer, (Final) tt);
- } else if (tt instanceof State) {
- writeState(writer, (State) tt);
- } else if (tt instanceof Parallel) {
- writeParallel(writer, (Parallel) tt);
+ for (EnterableState es : scxml.getChildren()) {
+ if (es instanceof Final) {
+ writeFinal(writer, (Final) es);
+ } else if (es instanceof State) {
+ writeState(writer, (State) es);
+ } else if (es instanceof Parallel) {
+ writeParallel(writer, (Parallel) es);
}
}
@@ -524,11 +524,6 @@ public class SCXMLWriter {
writer.writeStartElement(ELEM_STATE);
writeTransitionTargetId(writer, state);
writeAV(writer, ATTR_INITIAL, state.getFirst());
- boolean f = state.isFinal();
- if (f) {
- writer.writeAttribute(ATTR_FINAL, "true");
- }
-
writeInitial(writer, state.getInitial());
writeDatamodel(writer, state.getDatamodel());
writeHistory(writer, state.getHistory());
@@ -541,15 +536,15 @@ public class SCXMLWriter {
Invoke inv = state.getInvoke();
if (inv != null) {
writeInvoke(writer, inv);
- } else {
- for (TransitionTarget tt : state.getChildren().values()) {
- if (tt instanceof Final) {
- writeFinal(writer, (Final) tt);
- } else if (tt instanceof State) {
- writeState(writer, (State) tt);
- } else if (tt instanceof Parallel) {
- writeParallel(writer, (Parallel) tt);
- }
+ }
+
+ for (EnterableState es : state.getChildren()) {
+ if (es instanceof Final) {
+ writeFinal(writer, (Final) es);
+ } else if (es instanceof State) {
+ writeState(writer, (State) es);
+ } else if (es instanceof Parallel) {
+ writeParallel(writer, (Parallel) es);
}
}
@@ -579,11 +574,18 @@ public class SCXMLWriter {
writeTransition(writer, t);
}
- for (TransitionTarget tt : parallel.getChildren()) {
- if (tt instanceof Final) {
- writeFinal(writer, (Final) tt);
- } else if (tt instanceof State) {
- writeState(writer, (State) tt);
+ Invoke inv = parallel.getInvoke();
+ if (inv != null) {
+ writeInvoke(writer, inv);
+ }
+
+ for (EnterableState es : parallel.getChildren()) {
+ if (es instanceof Final) {
+ writeFinal(writer, (Final) es);
+ } else if (es instanceof State) {
+ writeState(writer, (State) es);
+ } else if (es instanceof Parallel) {
+ writeParallel(writer, (Parallel) es);
}
}
@@ -605,7 +607,6 @@ public class SCXMLWriter {
writer.writeStartElement(ELEM_FINAL);
writeTransitionTargetId(writer, end);
writeOnEntry(writer, end.getOnEntry());
- // params
writeOnExit(writer, end.getOnExit());
writer.writeEndElement();
}
@@ -703,12 +704,15 @@ public class SCXMLWriter {
*
* @throws XMLStreamException An exception processing the underlying {@link XMLStreamWriter}.
*/
- private static void writeTransition(final XMLStreamWriter writer, final Transition transition)
+ private static void writeTransition(final XMLStreamWriter writer, final SimpleTransition transition)
throws XMLStreamException {
writer.writeStartElement(ELEM_TRANSITION);
- writeAV(writer, ATTR_EVENT, transition.getEvent());
- writeAV(writer, ATTR_COND, SCXMLHelper.escapeXML(transition.getCond()));
+ if (transition instanceof Transition) {
+ writeAV(writer, ATTR_EVENT, ((Transition)transition).getEvent());
+ writeAV(writer, ATTR_COND, SCXMLHelper.escapeXML(((Transition)transition).getCond()));
+ }
+
writeAV(writer, ATTR_TARGET, transition.getNext());
if (transition.getType() != null) {
writeAV(writer, ATTR_TYPE, transition.getType().name());
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Action.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Action.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Action.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Action.java Sat Mar 22 23:34:20 2014
@@ -98,25 +98,25 @@ public abstract class Action implements
}
/**
- * Return the {@link TransitionTarget} whose {@link org.apache.commons.scxml2.Context} this action
+ * Return the {@link EnterableState} whose {@link org.apache.commons.scxml2.Context} this action
* executes in.
*
- * @return The parent {@link TransitionTarget}
- * @throws ModelException For an unknown TransitionTarget subclass
+ * @return The parent {@link EnterableState}
+ * @throws ModelException For an unknown EnterableState subclass
*
* @since 0.9
*/
- public final TransitionTarget getParentTransitionTarget()
+ public final EnterableState getParentEnterableState()
throws ModelException {
if (parent == null && this instanceof Script && ((Script)this).isGlobalScript()) {
- // global script doesn't have a TransitionTarget
+ // global script doesn't have a EnterableState
return null;
}
TransitionTarget tt = parent.getParent();
- if (tt instanceof State || tt instanceof Parallel) {
- return tt;
- } else if (tt instanceof History || tt instanceof Initial) {
- return tt.getParent();
+ if (tt instanceof EnterableState) {
+ return (EnterableState)tt;
+ } else if (tt instanceof History) {
+ return ((History)tt).getParent();
} else {
throw new ModelException("Unknown TransitionTarget subclass:"
+ tt.getClass().getName());
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Assign.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Assign.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Assign.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Assign.java Sat Mar 22 23:34:20 2014
@@ -183,8 +183,8 @@ public class Assign extends Action imple
final ErrorReporter errRep, final SCInstance scInstance,
final Log appLog, final Collection<TriggerEvent> derivedEvents)
throws ModelException, SCXMLExpressionException {
- TransitionTarget parentTarget = getParentTransitionTarget();
- Context ctx = scInstance.getContext(parentTarget);
+ EnterableState parentState = getParentEnterableState();
+ Context ctx = scInstance.getContext(parentState);
Evaluator eval = scInstance.getEvaluator();
ctx.setLocal(getNamespacesKey(), getNamespaces());
// "location" gets preference over "name"
@@ -237,7 +237,7 @@ public class Assign extends Action imple
// lets try "name" (usage as in Sep '05 WD, useful with <var>)
if (!ctx.has(name)) {
errRep.onError(ErrorConstants.UNDEFINED_VARIABLE, name
- + " = null", parentTarget);
+ + " = null", parentState);
} else {
Object varObj;
if (src != null && src.trim().length() > 0) {
Added: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java?rev=1580369&view=auto
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java (added)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java Sat Mar 22 23:34:20 2014
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.scxml2.model;
+
+import java.util.Comparator;
+
+/**
+ * DocumentOrder is implemented by {@link EnterableState} and {@link Transition} elements in the SCXML document
+ * representing their document order,
+ * <p>
+ * They are ordered with ancestor states before their descendant states,
+ * and the transitions within a state in document order before any descendant states.
+ * </p>
+ * <p>Note: it is assumed there will be no more than Intger.MAX_VALUE of such elements in a single SCXML document</p>
+ */
+public interface DocumentOrder {
+
+ Comparator<DocumentOrder> documentOrderComparator = new Comparator<DocumentOrder>() {
+ @Override
+ public int compare(final DocumentOrder o1, final DocumentOrder o2) {
+ return o1.getOrder() - o2.getOrder();
+ }
+ };
+
+ Comparator<DocumentOrder> reverseDocumentOrderComparator = new Comparator<DocumentOrder>() {
+ @Override
+ public int compare(final DocumentOrder o1, final DocumentOrder o2) {
+ return o2.getOrder() - o1.getOrder();
+ }
+ };
+
+ /**
+ * @return the relative document order within the SCXML document of this element
+ */
+ int getOrder();
+}
Propchange: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/EnterableState.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/EnterableState.java?rev=1580369&view=auto
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/EnterableState.java (added)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/EnterableState.java Sat Mar 22 23:34:20 2014
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.scxml2.model;
+
+/**
+ * An abstract base class for state elements in SCXML that can be entered, such as State, Parallel or Final.
+ */
+public abstract class EnterableState extends TransitionTarget implements DocumentOrder {
+
+ /**
+ * The document order of this state
+ */
+ private int order;
+
+ /**
+ * Optional property holding executable content to be run upon
+ * entering this transition target.
+ */
+ private OnEntry onEntry;
+
+ /**
+ * Optional property holding executable content to be run upon
+ * exiting this transition target.
+ */
+ private OnExit onExit;
+
+ public EnterableState() {
+ super();
+ onEntry = new OnEntry(); //empty defaults
+ onEntry.setParent(this);
+ onExit = new OnExit(); //empty defaults
+ onExit.setParent(this);
+ }
+
+ /**
+ * @return the document order of this state
+ * @see DocumentOrder
+ */
+ @Override
+ public final int getOrder() {
+ return order;
+ }
+
+ /**
+ * Sets the document order of this state
+ * @param order the document order
+ * @see DocumentOrder
+ */
+ public final void setOrder(int order) {
+ this.order = order;
+ }
+
+ /**
+ * Get the onentry property.
+ *
+ * @return Returns the onEntry.
+ */
+ public final OnEntry getOnEntry() {
+ return onEntry;
+ }
+
+ /**
+ * Set the onentry property.
+ *
+ * @param onEntry The onEntry to set.
+ */
+ public final void setOnEntry(final OnEntry onEntry) {
+ this.onEntry = onEntry;
+ this.onEntry.setParent(this);
+ }
+
+ /**
+ * Get the onexit property.
+ *
+ * @return Returns the onExit.
+ */
+ public final OnExit getOnExit() {
+ return onExit;
+ }
+
+ /**
+ * Set the onexit property.
+ *
+ * @param onExit The onExit to set.
+ */
+ public final void setOnExit(final OnExit onExit) {
+ this.onExit = onExit;
+ this.onExit.setParent(this);
+ }
+
+ /**
+ * Set the parent TransitionState.
+ *
+ * @param parent The parent state to set
+ */
+ @Override
+ public void setParent(final TransitionTarget parent) {
+ // enforce / validate only EnterableState parents are allowed
+ EnterableState es = (EnterableState)parent;
+ super.setParent(es);
+ }
+
+ /**
+ * Get the parent EnterableState.
+ *
+ * @return Returns the parent state
+ * (null if parent is <scxml> element)
+ */
+ @Override
+ public EnterableState getParent() {
+ return (EnterableState)super.getParent();
+ }
+}
Propchange: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/EnterableState.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/EnterableState.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Final.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Final.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Final.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Final.java Sat Mar 22 23:34:20 2014
@@ -22,7 +22,7 @@ package org.apache.commons.scxml2.model;
*
* @since 0.7
*/
-public class Final extends State {
+public class Final extends EnterableState {
/**
* Serial version UID.
@@ -30,13 +30,10 @@ public class Final extends State {
private static final long serialVersionUID = 1L;
/**
- * Default no-args constructor. Sets
- * <code>isFinal</code> property of this <code>State</code>
- * to be <code>true</code>.
+ * Default no-args constructor.
*/
public Final() {
super();
- this.setFinal(true);
}
}
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Foreach.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Foreach.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Foreach.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Foreach.java Sat Mar 22 23:34:20 2014
@@ -106,7 +106,7 @@ public class Foreach extends Action impl
final ErrorReporter errRep, final SCInstance scInstance,
final Log appLog, final Collection<TriggerEvent> derivedEvents)
throws ModelException, SCXMLExpressionException {
- Context ctx = scInstance.getContext(getParentTransitionTarget());
+ Context ctx = scInstance.getContext(getParentEnterableState());
Evaluator eval = scInstance.getEvaluator();
ctx.setLocal(getNamespacesKey(), getNamespaces());
try {
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/History.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/History.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/History.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/History.java Sat Mar 22 23:34:20 2014
@@ -38,10 +38,10 @@ public class History extends TransitionT
* and indicates the state to transition to if the parent state has
* never been entered before.
*/
- private Transition transition;
+ private SimpleTransition transition;
/**
- * Default no-args constructor for XML Digester.
+ * Default no-args constructor
*/
public History() {
super();
@@ -52,7 +52,7 @@ public class History extends TransitionT
*
* @return Returns the transition.
*/
- public final Transition getTransition() {
+ public final SimpleTransition getTransition() {
return transition;
}
@@ -61,7 +61,7 @@ public class History extends TransitionT
*
* @param transition The transition to set.
*/
- public final void setTransition(final Transition transition) {
+ public final void setTransition(final SimpleTransition transition) {
this.transition = transition;
this.transition.setParent(this);
}
@@ -76,8 +76,6 @@ public class History extends TransitionT
}
/**
- * This method is invoked by XML digester when parsing SCXML markup.
- *
* @param type The history type, which can be "shallow" or
* "deep"
*/
@@ -88,5 +86,16 @@ public class History extends TransitionT
//shallow is by default
}
+ @Override
+ public TransitionalState getParent() {
+ return (TransitionalState)super.getParent();
+ }
+
+ @Override
+ public void setParent(final TransitionTarget parent) {
+ // enforce / validate only TransitionalState parents are allowed
+ TransitionalState ts = (TransitionalState)parent;
+ super.setParent(ts);
+ }
}
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/If.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/If.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/If.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/If.java Sat Mar 22 23:34:20 2014
@@ -123,8 +123,8 @@ public class If extends Action implement
final ErrorReporter errRep, final SCInstance scInstance,
final Log appLog, final Collection<TriggerEvent> derivedEvents)
throws ModelException, SCXMLExpressionException {
- TransitionTarget parentTarget = getParentTransitionTarget();
- Context ctx = scInstance.getContext(parentTarget);
+ EnterableState parentState = getParentEnterableState();
+ Context ctx = scInstance.getContext(parentState);
Evaluator eval = scInstance.getEvaluator();
ctx.setLocal(getNamespacesKey(), getNamespaces());
Boolean rslt;
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Initial.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Initial.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Initial.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Initial.java Sat Mar 22 23:34:20 2014
@@ -16,12 +16,14 @@
*/
package org.apache.commons.scxml2.model;
+import java.io.Serializable;
+
/**
* The class in this SCXML object model that corresponds to the
* <initial> SCXML pseudo state element.
*
*/
-public class Initial extends TransitionTarget {
+public class Initial implements Serializable {
/**
* Serial version UID.
@@ -29,11 +31,16 @@ public class Initial extends TransitionT
private static final long serialVersionUID = 1L;
/**
+ * The parent State of this initial
+ */
+ private State parent;
+
+ /**
* A conditionless transition that is always enabled and will be taken
* as soon as the state is entered. The target of the transition must
* be a descendant of the parent state of initial.
*/
- private Transition transition;
+ private SimpleTransition transition;
/**
* Indicator if this Initial was automatically generated and not loaded from the SCXML Document itself
@@ -48,11 +55,33 @@ public class Initial extends TransitionT
}
/**
+ * Get the parent State.
+ *
+ * @return Returns the parent state
+ */
+ public final State getParent() {
+ return parent;
+ }
+
+
+ /**
+ * Set the parent TransitionTarget.
+ *
+ * @param parent The parent state to set
+ */
+ public final void setParent(final State parent) {
+ this.parent = parent;
+ if (transition != null) {
+ transition.setParent(parent);
+ }
+ }
+
+ /**
* Get the initial transition.
*
* @return Returns the transition.
*/
- public final Transition getTransition() {
+ public final SimpleTransition getTransition() {
return transition;
}
@@ -61,9 +90,9 @@ public class Initial extends TransitionT
*
* @param transition The transition to set.
*/
- public final void setTransition(final Transition transition) {
+ public final void setTransition(final SimpleTransition transition) {
this.transition = transition;
- this.transition.setParent(this);
+ this.transition.setParent(getParent());
}
/**
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Log.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Log.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Log.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Log.java Sat Mar 22 23:34:20 2014
@@ -101,7 +101,7 @@ public class Log extends Action {
final org.apache.commons.logging.Log appLog,
final Collection<TriggerEvent> derivedEvents)
throws ModelException, SCXMLExpressionException {
- Context ctx = scInstance.getContext(getParentTransitionTarget());
+ Context ctx = scInstance.getContext(getParentEnterableState());
Evaluator eval = scInstance.getEvaluator();
ctx.setLocal(getNamespacesKey(), getNamespaces());
appLog.info(label + ": " + String.valueOf(eval.eval(ctx, expr)));
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Parallel.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Parallel.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Parallel.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Parallel.java Sat Mar 22 23:34:20 2014
@@ -16,9 +16,6 @@
*/
package org.apache.commons.scxml2.model;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
/**
* The class in this SCXML object model that corresponds to the
* <parallel> SCXML element, which is a wrapper element to
@@ -28,7 +25,7 @@ import java.util.Set;
* children.
*
*/
-public class Parallel extends TransitionTarget {
+public class Parallel extends TransitionalState {
/**
* Serial version UID.
@@ -36,39 +33,16 @@ public class Parallel extends Transition
private static final long serialVersionUID = 2L;
/**
- * The set of parallel state machines contained in this <parallel>.
- */
- private Set<TransitionTarget> children;
-
- /**
* Constructor.
*/
public Parallel() {
- children = new LinkedHashSet<TransitionTarget>();
}
- /**
- * Get the set of child transition targets (may be empty).
- *
- * @return Set Returns the children.
- *
- * @since 0.7
- */
- public final Set<TransitionTarget> getChildren() {
- return children;
+ @Override
+ public void addChild(final EnterableState es) {
+ // enforce/validate only TransitionalState children are allowed
+ TransitionalState ts = (TransitionalState)es;
+ super.addChild(ts);
}
-
- /**
- * Add a child.
- *
- * @param tt A child transition target.
- *
- * @since 0.7
- */
- public final void addChild(final TransitionTarget tt) {
- children.add(tt);
- tt.setParent(this);
- }
-
}
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Param.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Param.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Param.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Param.java Sat Mar 22 23:34:20 2014
@@ -48,7 +48,7 @@ public class Param implements NamespaceP
private Map<String, String> namespaces;
/**
- * Default no-args constructor for Digester.
+ * Default no-args constructor
*/
public Param() {
name = null;
Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SCXML.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SCXML.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SCXML.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SCXML.java Sat Mar 22 23:34:20 2014
@@ -17,8 +17,9 @@
package org.apache.commons.scxml2.model;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -59,10 +60,10 @@ public class SCXML implements Serializab
/**
* The initial Transition for the SCXML executor.
*/
- private Transition initialTransition;
+ private SimpleTransition initialTransition;
/**
- * The initial transition target ID (used by XML Digester only).
+ * The initial transition target ID
*/
private String initial;
@@ -96,7 +97,7 @@ public class SCXML implements Serializab
/**
* The immediate child targets of this SCXML document root.
*/
- private Map<String, TransitionTarget> children;
+ private List<EnterableState> children;
/**
* A global map of all States and Parallels associated with this
@@ -121,7 +122,7 @@ public class SCXML implements Serializab
* Constructor.
*/
public SCXML() {
- this.children = new LinkedHashMap<String, TransitionTarget>();
+ this.children = new ArrayList<EnterableState>();
this.targets = new HashMap<String, TransitionTarget>();
}
@@ -148,7 +149,7 @@ public class SCXML implements Serializab
*
* @since 2.0
*/
- public final Transition getInitialTransition() {
+ public final SimpleTransition getInitialTransition() {
return initialTransition;
}
@@ -160,7 +161,7 @@ public class SCXML implements Serializab
*
* @since 2.0
*/
- public final void setInitialTransition(final Transition initialTransition) {
+ public final void setInitialTransition(final SimpleTransition initialTransition) {
this.initialTransition = initialTransition;
}
@@ -185,37 +186,37 @@ public class SCXML implements Serializab
/**
* Get the immediate child targets of the SCXML root.
*
- * @return Map Returns map of the child targets.
+ * @return List Returns list of the child targets.
*
* @since 0.7
*/
- public final Map<String, TransitionTarget> getChildren() {
+ public final List<EnterableState> getChildren() {
return children;
}
/**
- * Get the first immediate child target of the SCXML root. Return null if there's no child.
+ * Get the first immediate child of the SCXML root. Return null if there's no child.
*
- * @return TransitionTarget Returns the first immediate child target of the SCXML root. Return null if there's no child.
+ * @return Returns the first immediate child of the SCXML root. Return null if there's no child.
*
* @since 2.0
*/
- public final TransitionTarget getFirstChild() {
+ public final EnterableState getFirstChild() {
if (!children.isEmpty()) {
- return children.values().iterator().next();
+ return children.get(0);
}
return null;
}
/**
- * Add an immediate child target of the SCXML root.
+ * Add an immediate child of the SCXML root.
*
- * @param tt The transition target to be added to the states Map.
+ * @param es The child to be added.
*
* @since 0.7
*/
- public final void addChild(final TransitionTarget tt) {
- children.put(tt.getId(), tt);
+ public final void addChild(final EnterableState es) {
+ children.add(es);
}
/**
@@ -308,7 +309,7 @@ public class SCXML implements Serializab
* Set the initial transition target.
*
* @param initial The initial transition target
- * @see #setInitialTransition(Transition)
+ * @see #setInitialTransition(SimpleTransition)
*/
public final void setInitial(final String initial) {
this.initial = initial;