Examples of EnterableState


Examples of org.apache.commons.scxml2.model.EnterableState

     * @return The context.
     */
    public Context getContext(final EnterableState state) {
        Context context = contexts.get(state);
        if (context == null) {
            EnterableState parent = state.getParent();
            if (parent == null) {
                // docroot
                context = evaluator.newContext(getGlobalContext());
            } else {
                context = evaluator.newContext(getContext(parent));
View Full Code Here

Examples of org.apache.commons.scxml2.model.EnterableState

        Set<EnterableState> parents = new HashSet<EnterableState>();
        for (TransitionTarget tt : tts) {
            boolean hasParallelParent = false;
            for (int i = tt.getNumberOfAncestors()-1; i > -1; i--) {
                EnterableState parent = tt.getAncestor(i);
                if (parent instanceof Parallel) {
                    hasParallelParent = true;
                    // keep on 'reading' as a parallel may have a parent parallel (and even intermediate states)
                }
                else {
View Full Code Here

Examples of org.apache.commons.scxml2.model.EnterableState

        } else if (errCode == ErrorConstants.ILLEGAL_CONFIG) {
            //isLegalConfig
            if (errCtx instanceof Map.Entry) { //unchecked cast below
                Map.Entry<EnterableState, Set<EnterableState>> badConfigMap =
                    (Map.Entry<EnterableState, Set<EnterableState>>) errCtx;
                EnterableState es = badConfigMap.getKey();
                Set<EnterableState> vals = badConfigMap.getValue();
                msg.append(LogUtils.getTTPath(es) + " : [");
                for (Iterator<EnterableState> i = vals.iterator(); i.hasNext();) {
                    EnterableState ex = i.next();
                    msg.append(LogUtils.getTTPath(ex));
                    if (i.hasNext()) { // reason for iterator usage
                        msg.append(", ");
                    }
                }
                msg.append(']');
            } else if (errCtx instanceof Set) { //unchecked cast below
                Set<EnterableState> vals = (Set<EnterableState>) errCtx;
                msg.append("<SCXML> : [");
                for (Iterator<EnterableState> i = vals.iterator(); i.hasNext();) {
                    EnterableState ex = i.next();
                    msg.append(LogUtils.getTTPath(ex));
                    if (i.hasNext()) {
                        msg.append(", ");
                    }
                }
View Full Code Here

Examples of org.apache.commons.scxml2.model.EnterableState

    /**
     * @return Returns the single top level final state in which the state machine terminated, or null otherwise
     */
    public Final getFinalState() {
        if (states.size() == 1) {
            EnterableState es = states.iterator().next();
            if (es instanceof Final && es.getParent() == null) {
                return (Final)es;
            }
        }
        return null;
    }
View Full Code Here

Examples of org.apache.commons.scxml2.model.EnterableState

     *         complex ancestors up to the root.
     */
    public Set<EnterableState> getAllStates() {
        Set<EnterableState> allStates = new HashSet<EnterableState>(states.size() * 2);
        for (EnterableState es : states) {
            EnterableState state = es;
            while (state != null && allStates.add(state)) {
                state = state.getParent();
            }
        }
        return allStates;
    }
View Full Code Here

Examples of org.apache.commons.scxml2.model.EnterableState

                    addAncestorStatesToEnter(exctx, step, dtt, tt.getParent());
                }
            }
        }
        else { // tt instanceof EnterableState
            EnterableState es = (EnterableState)tt;
            step.getEntrySet().add(es);
            if (es instanceof Parallel) {
                for (EnterableState child : ((Parallel)es).getChildren()) {
                    if (!containsDescendant(step.getEntrySet(), child)) {
                        addDescendantStatesToEnter(exctx, step, child);
View Full Code Here

Examples of org.apache.commons.scxml2.model.EnterableState

     */
    public void addAncestorStatesToEnter(final SCXMLExecutionContext exctx, final Step step,
                                            final TransitionTarget tt, TransitionTarget ancestor) {
        // for for anc in getProperAncestors(tt,ancestor)
        for (int i = tt.getNumberOfAncestors()-1; i > -1; i--) {
            EnterableState anc = tt.getAncestor(i);
            if (anc == ancestor) {
                break;
            }
            step.getEntrySet().add(anc);
            if (anc instanceof Parallel) {
View Full Code Here

Examples of org.apache.commons.scxml2.model.EnterableState

         */
        boolean legalConfig = true; // let's be optimists
        Map<EnterableState, Set<EnterableState>> counts = new HashMap<EnterableState, Set<EnterableState>>();
        Set<EnterableState> scxmlCount = new HashSet<EnterableState>();
        for (EnterableState es : states) {
            EnterableState parent;
            while ((parent = es.getParent()) != null) {
                Set<EnterableState> cnt = counts.get(parent);
                if (cnt == null) {
                    cnt = new HashSet<EnterableState>();
                    counts.put(parent, cnt);
                }
                cnt.add(es);
                es = parent;
            }
            //top-level contribution
            scxmlCount.add(es);
        }
        if (scxmlCount.size() > 1) {
            errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Multiple top-level OR states active!", scxmlCount);
        }
        //Validate child counts:
        for (Map.Entry<EnterableState, Set<EnterableState>> entry : counts.entrySet()) {
            EnterableState es = entry.getKey();
            Set<EnterableState> count = entry.getValue();
            if (es instanceof Parallel) {
                Parallel p = (Parallel) es;
                if (count.size() < p.getChildren().size()) {
                    errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Not all AND states active for parallel " + p.getId(), entry);
                    legalConfig = false;
                }
            } else {
                if (count.size() > 1) {
                    errRep.onError(ErrorConstants.ILLEGAL_CONFIG, "Multiple OR states active for state " + es.getId(), entry);
                    legalConfig = false;
                }
            }
            count.clear(); //cleanup
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.