Package org.apache.commons.scxml2

Examples of org.apache.commons.scxml2.EventDispatcher


        if (!(actionObject instanceof Action)) {
            throw new IllegalArgumentException(ERR_CUSTOM_ACTION_TYPE + className);
        }

        // Set the attribute values as properties
        Action action = (Action) actionObject;
        for (int i = 0; i < reader.getAttributeCount(); i++) {
            String name = reader.getAttributeLocalName(i);
            String value = reader.getAttributeValue(i);
            String setter = "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
            Method method = null;
            try {
                method = clazz.getMethod(setter, String.class);
                method.invoke(action, value);
            } catch (NoSuchMethodException nsme) {
                throw new XMLStreamException("No setter in class:" + className + ", for string property:" + name,
                        nsme);
            } catch (InvocationTargetException ite) {
                throw new XMLStreamException("Exception calling setter for string property:" + name + " in class:"
                        + className, ite);
            } catch (IllegalAccessException iae) {
                throw new XMLStreamException("Cannot access setter for string property:" + name + " in class:"
                        + className, iae);
            }
        }

        // Add any body content if necessary
        if (action instanceof ExternalContent) {
            Node body = readNode(reader, configuration, customAction.getNamespaceURI(),
                    customAction.getLocalName(), new String [] {});
            NodeList childNodes = body.getChildNodes();
            List<Node> externalNodes = ((ExternalContent) action).getExternalNodes();
            for (int i = 0; i < childNodes.getLength(); i++) {
                externalNodes.add(childNodes.item(i));
            }
        }

        // Wire in the action and add to parent
        readNamespaces(configuration, action);
        action.setParent(executable);
        if (parent != null) {
            parent.addAction(action);
        } else {
            executable.addAction(action);
        }
View Full Code Here


     */
    private static void readAssign(final XMLStreamReader reader, final Configuration configuration,
                                   final Executable executable, final ActionsContainer parent)
            throws XMLStreamException, ModelException {

        Assign assign = new Assign();
        assign.setExpr(readAV(reader, ATTR_EXPR));
        assign.setName(readAV(reader, ATTR_NAME));
        if (assign.getName() != null && assign.getName().trim().length() > 0) {
            // if 'non-standard' name attribute is defined, don't require location (as per the spec. 20130831)
            assign.setLocation(readAV(reader, ATTR_LOCATION));
        }
        else {
            assign.setLocation(readRequiredAV(reader, ELEM_ASSIGN, ATTR_LOCATION));
        }
        assign.setSrc(readAV(reader, ATTR_SRC));
        assign.setPathResolver(configuration.pathResolver);
        readNamespaces(configuration, assign);
        assign.setParent(executable);
        if (parent != null) {
            parent.addAction(assign);
        } else {
            executable.addAction(assign);
        }
View Full Code Here

     */
    private static void readCancel(final XMLStreamReader reader, final Configuration configuration,
                                   final Executable executable, final ActionsContainer parent)
            throws XMLStreamException {

        Cancel cancel = new Cancel();
        readNamespaces(configuration, cancel);
        cancel.setParent(executable);
        if (parent != null) {
            parent.addAction(cancel);
        } else {
            executable.addAction(cancel);
        }
View Full Code Here

                            readVar(reader, configuration, executable, parent);
                        } else {
                            reportIgnoredElement(reader, configuration, end, nsURI, name);
                        }
                    } else { // custom action
                        CustomAction customAction = null;
                        if (!configuration.customActions.isEmpty()) {
                            for (CustomAction ca : configuration.customActions) {
                                if (ca.getNamespaceURI().equals(nsURI) && ca.getLocalName().equals(name)) {
                                    customAction = ca;
                                }
View Full Code Here

     * @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
     */
    private static void readData(final XMLStreamReader reader, final Configuration configuration, final Datamodel dm)
            throws XMLStreamException, ModelException {

        Data datum = new Data();
        datum.setId(readRequiredAV(reader, ELEM_DATA, ATTR_ID));
        datum.setExpr(readAV(reader, ATTR_EXPR));
        readNamespaces(configuration, datum);
        datum.setNode(readNode(reader, configuration, XMLNS_SCXML, ELEM_DATA, new String[] {"id"}));
        dm.addData(datum);
    }
View Full Code Here

        contexts.clear();
        histories.clear();
        currentStatus.clear();

        // Clone root datamodel
        Datamodel rootdm = stateMachine.getDatamodel();
        cloneDatamodel(rootdm, getRootContext(), evaluator, errorReporter);
        initialized = true;
    }
View Full Code Here

                context = evaluator.newContext(getGlobalContext());
            } else {
                context = evaluator.newContext(getContext(parent));
            }
            if (state instanceof TransitionalState) {
                Datamodel datamodel = ((TransitionalState)state).getDatamodel();
                cloneDatamodel(datamodel, context, evaluator, errorReporter);
            }
            contexts.put(state, context);
        }
        return context;
View Full Code Here

     */
    private static void readDatamodel(final XMLStreamReader reader, final Configuration configuration,
                                      final SCXML scxml, final TransitionalState parent)
            throws XMLStreamException, ModelException {

        Datamodel dm = new Datamodel();

        loop : while (reader.hasNext()) {
            String name, nsURI;
            switch (reader.next()) {
                case XMLStreamConstants.START_ELEMENT:
View Full Code Here

     */
    private static void readElse(final XMLStreamReader reader, final Configuration configuration,
                                 final Executable executable, final If iff)
            throws XMLStreamException {

        Else els = new Else();
        readNamespaces(configuration, els);
        els.setParent(executable);
        iff.addAction(els);
    }
View Full Code Here

     */
    private static void readElseIf(final XMLStreamReader reader, final Configuration configuration,
                                   final Executable executable, final If iff)
            throws XMLStreamException, ModelException {

        ElseIf elseif = new ElseIf();
        elseif.setCond(readRequiredAV(reader, ELEM_ELSEIF, ATTR_COND));
        readNamespaces(configuration, elseif);
        elseif.setParent(executable);
        iff.addAction(elseif);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.scxml2.EventDispatcher

Copyright © 2018 www.massapicom. 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.