*/
private static void readState(final XMLStreamReader reader, final Configuration configuration, final SCXML scxml,
final TransitionalState parent)
throws IOException, ModelException, XMLStreamException {
State state = new State();
state.setId(readOrGeneratedTransitionTargetId(reader, scxml, ELEM_STATE));
String initial = readAV(reader, ATTR_INITIAL);
if (initial != null) {
state.setFirst(initial);
}
String src = readAV(reader, ATTR_SRC);
if (src != null) {
String source = src;
Configuration copy = new Configuration(configuration);
if (copy.parent == null) {
copy.parent = scxml;
}
if (configuration.pathResolver != null) {
source = configuration.pathResolver.resolvePath(src);
copy.pathResolver = configuration.pathResolver.getResolver(src);
}
readTransitionalStateSrc(copy, source, state);
}
if (parent == null) {
scxml.addChild(state);
} else if (parent instanceof State) {
((State)parent).addChild(state);
}
else {
((Parallel)parent).addChild(state);
}
scxml.addTarget(state);
if (configuration.parent != null) {
configuration.parent.addTarget(state);
}
loop : while (reader.hasNext()) {
String name, nsURI;
switch (reader.next()) {
case XMLStreamConstants.START_ELEMENT:
pushNamespaces(reader, configuration);
nsURI = reader.getNamespaceURI();
name = reader.getLocalName();
if (XMLNS_SCXML.equals(nsURI)) {
if (ELEM_TRANSITION.equals(name)) {
state.addTransition(readTransition(reader, configuration));
} else if (ELEM_STATE.equals(name)) {
readState(reader, configuration, scxml, state);
} else if (ELEM_INITIAL.equals(name)) {
readInitial(reader, configuration, state);
} else if (ELEM_FINAL.equals(name)) {