private static void writeExecutableContent()

in src/main/java/org/apache/commons/scxml2/io/SCXMLWriter.java [791:870]


    private static void writeExecutableContent(final XMLStreamWriter writer, final List<Action> actions)
            throws XMLStreamException {

        if (actions == null) {
            return;
        }
        for (final Action a : actions) {
            if (a instanceof Assign) {
                final Assign asn = (Assign) a;
                writer.writeStartElement(SCXMLConstants.XMLNS_SCXML, SCXMLConstants.ELEM_ASSIGN);
                writeAV(writer, SCXMLConstants.ATTR_LOCATION, asn.getLocation());
                writeAV(writer, SCXMLConstants.ATTR_SRC, asn.getSrc());
                writeAV(writer, SCXMLConstants.ATTR_EXPR, escapeXML(asn.getExpr()));
                writeParsedValue(writer, ((Assign) a).getParsedValue());
                writer.writeEndElement();
            } else if (a instanceof Send) {
                writeSend(writer, (Send) a);
            } else if (a instanceof Cancel) {
                final Cancel c = (Cancel) a;
                writer.writeStartElement(SCXMLConstants.XMLNS_SCXML, SCXMLConstants.ELEM_CANCEL);
                writeAV(writer, SCXMLConstants.ATTR_SENDID, c.getSendid());
                writer.writeEndElement();
            } else if (a instanceof Foreach) {
                writeForeach(writer, (Foreach) a);
            } else if (a instanceof Log) {
                final Log lg = (Log) a;
                writer.writeStartElement(SCXMLConstants.XMLNS_SCXML, SCXMLConstants.ELEM_LOG);
                writeAV(writer, SCXMLConstants.ATTR_LABEL, lg.getLabel());
                writeAV(writer, SCXMLConstants.ATTR_EXPR, escapeXML(lg.getExpr()));
                writer.writeEndElement();
            } else if (a instanceof Raise) {
                final Raise e = (Raise) a;
                writer.writeStartElement(SCXMLConstants.XMLNS_SCXML, SCXMLConstants.ELEM_RAISE);
                writeAV(writer, SCXMLConstants.ATTR_EVENT, e.getEvent());
                writer.writeEndElement();
            } else if (a instanceof Script) {
                final Script s = (Script) a;
                writer.writeStartElement(SCXMLConstants.XMLNS_SCXML, SCXMLConstants.ELEM_SCRIPT);
                if (s.getSrc() != null) {
                    writeAV(writer, SCXMLConstants.ATTR_SRC, s.getSrc());
                } else {
                    writer.writeCData(s.getScript());
                }
                writer.writeEndElement();
            } else if (a instanceof If) {
                writeIf(writer, (If) a);
            } else if (a instanceof Else) {
                writer.writeEmptyElement(SCXMLConstants.ELEM_ELSE);
            } else if (a instanceof ElseIf) {
                final ElseIf eif = (ElseIf) a;
                writer.writeStartElement(SCXMLConstants.XMLNS_SCXML, SCXMLConstants.ELEM_ELSEIF);
                writeAV(writer, SCXMLConstants.ATTR_COND, escapeXML(eif.getCond()));
                writer.writeEndElement();
            } else if (a instanceof Var) {
                // 'naked' Var custom action, not wrapped in a CustomActionWrapper
                final Var v = (Var) a;
                writer.writeStartElement(SCXMLConstants.XMLNS_COMMONS_SCXML, SCXMLConstants.ELEM_VAR);
                writeAV(writer, SCXMLConstants.ATTR_NAME, v.getName());
                writeAV(writer, SCXMLConstants.ATTR_EXPR, escapeXML(v.getExpr()));
                writer.writeEndElement();
            } else if (a instanceof CustomActionWrapper) {
                final CustomActionWrapper actionWrapper = (CustomActionWrapper)a;
                writer.writeStartElement(createQualifiedName(actionWrapper.getPrefix(), actionWrapper.getLocalName()));
                if (actionWrapper.getAttributes() != null) {
                    for (final String attr : actionWrapper.getAttributes().keySet()) {
                        writer.writeAttribute(attr, escapeXML(actionWrapper.getAttributes().get(attr)));
                    }
                }
                for (final String prefix : actionWrapper.getNamespaces().keySet()) {
                    writer.writeNamespace(prefix, actionWrapper.getNamespaces().get(prefix));
                }
                if (actionWrapper.getAction() instanceof ParsedValueContainer) {
                    writeParsedValue(writer, ((ParsedValueContainer)actionWrapper.getAction()).getParsedValue());
                }
                writer.writeEndElement();
            } else {
                writer.writeComment("Unknown action with class name '" + a.getClass().getName() + "' not serialized");
            }
        }
    }