if (!c.isEmpty()) {
if (ini == null) {
logAndThrowModelError(ERR_STATE_NO_INIT,
new Object[] {getStateName(s)});
}
Transition initialTransition = ini.getTransition();
updateTransition(initialTransition, targets);
initialState = initialTransition.getTarget();
// we have to allow for an indirect descendant initial (targets)
//check that initialState is a descendant of s
if (initialState == null
|| !SCXMLHelper.isDescendant(initialState, s)) {
logAndThrowModelError(ERR_STATE_BAD_INIT,
new Object[] {getStateName(s)});
}
}
List histories = s.getHistory();
Iterator histIter = histories.iterator();
while (histIter.hasNext()) {
if (s.isSimple()) {
logAndThrowModelError(ERR_HISTORY_SIMPLE_STATE,
new Object[] {getStateName(s)});
}
History h = (History) histIter.next();
Transition historyTransition = h.getTransition();
if (historyTransition == null) {
// try to assign initial as default
if (initialState != null
&& !(initialState instanceof History)) {
historyTransition = new Transition();
historyTransition.setNext(initialState.getId());
historyTransition.setParent(h);
h.setTransition(historyTransition);
} else {
logAndThrowModelError(ERR_HISTORY_NO_DEFAULT,
new Object[] {h.getId(), getStateName(s)});
}
}
updateTransition(historyTransition, targets);
State historyState = (State) historyTransition.getTarget();
if (historyState == null) {
logAndThrowModelError(ERR_STATE_NO_HIST,
new Object[] {getStateName(s)});
}
if (!h.isDeep()) {
if (!c.containsValue(historyState)) {
logAndThrowModelError(ERR_STATE_BAD_SHALLOW_HIST,
new Object[] {getStateName(s)});
}
} else {
if (!SCXMLHelper.isDescendant(historyState, s)) {
logAndThrowModelError(ERR_STATE_BAD_DEEP_HIST,
new Object[] {getStateName(s)});
}
}
}
Map t = s.getTransitions();
Iterator i = t.keySet().iterator();
while (i.hasNext()) {
Iterator j = ((List) t.get(i.next())).iterator();
while (j.hasNext()) {
Transition trn = (Transition) j.next();
//could add next two lines as a Digester rule for Transition
trn.setParent(s);
updateTransition(trn, targets);
}
}
Parallel p = s.getParallel();
Invoke inv = s.getInvoke();