Java Code Examples for javax.xml.stream.XMLStreamWriter#writeCData()
The following examples show how to use
javax.xml.stream.XMLStreamWriter#writeCData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimerEventListenerExport.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override protected void writePlanItemDefinitionBody(CmmnModel model, TimerEventListener timerEventListener, XMLStreamWriter xtw) throws Exception { if (StringUtils.isNotEmpty(timerEventListener.getTimerExpression())) { xtw.writeStartElement(ELEMENT_TIMER_EXPRESSION); xtw.writeCData(timerEventListener.getTimerExpression()); xtw.writeEndElement(); } if (StringUtils.isNotEmpty(timerEventListener.getTimerStartTriggerSourceRef())) { xtw.writeStartElement(ELEMENT_PLAN_ITEM_START_TRIGGER); xtw.writeAttribute(ATTRIBUTE_PLAN_ITEM_START_TRIGGER_SRC_REF, timerEventListener.getTimerStartTriggerSourceRef()); xtw.writeStartElement(ELEMENT_STANDARD_EVENT); xtw.writeCData(timerEventListener.getTimerStartTriggerStandardEvent()); xtw.writeEndElement(); xtw.writeEndElement(); } }
Example 2
Source File: EwsServiceXmlWriter.java From ews-java-api with MIT License | 6 votes |
/** * @param xmlNode XML node * @param xmlStreamWriter XML stream writer * @throws XMLStreamException the XML stream exception */ public static void writeNode(Node xmlNode, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { if (xmlNode instanceof Element) { addElement((Element) xmlNode, xmlStreamWriter); } else if (xmlNode instanceof Text) { xmlStreamWriter.writeCharacters(xmlNode.getNodeValue()); } else if (xmlNode instanceof CDATASection) { xmlStreamWriter.writeCData(((CDATASection) xmlNode).getData()); } else if (xmlNode instanceof Comment) { xmlStreamWriter.writeComment(((Comment) xmlNode).getData()); } else if (xmlNode instanceof EntityReference) { xmlStreamWriter.writeEntityRef(xmlNode.getNodeValue()); } else if (xmlNode instanceof ProcessingInstruction) { ProcessingInstruction procInst = (ProcessingInstruction) xmlNode; xmlStreamWriter.writeProcessingInstruction(procInst.getTarget(), procInst.getData()); } else if (xmlNode instanceof Document) { writeToDocument((Document) xmlNode, xmlStreamWriter); } }
Example 3
Source File: NSWriter.java From softwarecave with GNU General Public License v3.0 | 6 votes |
private void writeBookElem(XMLStreamWriter writer, Book book) throws XMLStreamException { writer.writeStartElement(NS, "book"); writer.writeAttribute(NS, "language", book.getLanguage()); writeAuthorsElem(writer, book.getAuthors()); writer.writeStartElement(NS, "title"); writer.writeCData(book.getTitle()); writer.writeEndElement(); writer.writeStartElement(NS, "category"); writer.writeCharacters(book.getCategory().name()); writer.writeEndElement(); writer.writeStartElement(NS, "year"); writer.writeCharacters(Integer.toString(book.getYear())); writer.writeEndElement(); writer.writeEndElement(); }
Example 4
Source File: MapExceptionExport.java From flowable-engine with Apache License 2.0 | 6 votes |
public static boolean writeMapExceptionExtensions(List<MapExceptionEntry> mapExceptionList, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { for (MapExceptionEntry mapException : mapExceptionList) { if (!didWriteExtensionStartElement) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; } if (StringUtils.isNotEmpty(mapException.getErrorCode())) { xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, MAP_EXCEPTION, FLOWABLE_EXTENSIONS_NAMESPACE); BpmnXMLUtil.writeDefaultAttribute(MAP_EXCEPTION_ERRORCODE, mapException.getErrorCode(), xtw); BpmnXMLUtil.writeDefaultAttribute(MAP_EXCEPTION_ANDCHILDREN, Boolean.toString(mapException.isAndChildren()), xtw); if (StringUtils.isNotEmpty(mapException.getClassName())) { xtw.writeCData(mapException.getClassName()); } xtw.writeEndElement(); //end flowable:mapException } } return didWriteExtensionStartElement; }
Example 5
Source File: PlanItemControlExport.java From flowable-engine with Apache License 2.0 | 6 votes |
public static boolean writeCompletionNeutralRule(CompletionNeutralRule completionNeutralRule, XMLStreamWriter xtw) throws XMLStreamException { boolean hasWrittenExtensionElements = false; if (completionNeutralRule != null) { xtw.writeStartElement(ELEMENT_EXTENSION_ELEMENTS); xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_COMPLETION_NEUTRAL_RULE, FLOWABLE_EXTENSIONS_NAMESPACE); if (StringUtils.isNotBlank(completionNeutralRule.getCondition())) { xtw.writeStartElement(ELEMENT_CONDITION); xtw.writeCData(completionNeutralRule.getCondition()); xtw.writeEndElement(); } xtw.writeEndElement(); hasWrittenExtensionElements = true; } return hasWrittenExtensionElements; }
Example 6
Source File: DOMUtil.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Traverses a DOM node and writes out on a streaming writer. * * @param node * @param writer */ public static void serializeNode(Element node, XMLStreamWriter writer) throws XMLStreamException { writeTagWithAttributes(node, writer); if (node.hasChildNodes()) { NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); switch (child.getNodeType()) { case Node.PROCESSING_INSTRUCTION_NODE: writer.writeProcessingInstruction(child.getNodeValue()); break; case Node.DOCUMENT_TYPE_NODE: break; case Node.CDATA_SECTION_NODE: writer.writeCData(child.getNodeValue()); break; case Node.COMMENT_NODE: writer.writeComment(child.getNodeValue()); break; case Node.TEXT_NODE: writer.writeCharacters(child.getNodeValue()); break; case Node.ELEMENT_NODE: serializeNode((Element) child, writer); break; default: break; } } } writer.writeEndElement(); }
Example 7
Source File: DecisionTaskExport.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override protected void writePlanItemDefinitionBody(CmmnModel model, DecisionTask decisionTask, XMLStreamWriter xtw) throws Exception { super.writePlanItemDefinitionBody(model, decisionTask, xtw); if (StringUtils.isNotEmpty(decisionTask.getDecisionRef()) || StringUtils.isNotEmpty(decisionTask.getDecisionRefExpression())) { xtw.writeStartElement(ELEMENT_DECISION_REF_EXPRESSION); xtw.writeCData( StringUtils.isNotEmpty(decisionTask.getDecisionRef()) ? decisionTask.getDecisionRef() : decisionTask.getDecisionRefExpression() ); xtw.writeEndElement(); } }
Example 8
Source File: DOMUtil.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Traverses a DOM node and writes out on a streaming writer. * * @param node * @param writer */ public static void serializeNode(Element node, XMLStreamWriter writer) throws XMLStreamException { writeTagWithAttributes(node, writer); if (node.hasChildNodes()) { NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); switch (child.getNodeType()) { case Node.PROCESSING_INSTRUCTION_NODE: writer.writeProcessingInstruction(child.getNodeValue()); break; case Node.DOCUMENT_TYPE_NODE: break; case Node.CDATA_SECTION_NODE: writer.writeCData(child.getNodeValue()); break; case Node.COMMENT_NODE: writer.writeComment(child.getNodeValue()); break; case Node.TEXT_NODE: writer.writeCharacters(child.getNodeValue()); break; case Node.ELEMENT_NODE: serializeNode((Element) child, writer); break; default: break; } } } writer.writeEndElement(); }
Example 9
Source File: ServiceTaskXMLConverter.java From flowable-engine with Apache License 2.0 | 5 votes |
protected boolean writeSendServiceExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { SendEventServiceTask sendEventServiceTask = (SendEventServiceTask) element; if (!didWriteExtensionStartElement) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; } xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_EVENT_TYPE, FLOWABLE_EXTENSIONS_NAMESPACE); if (StringUtils.isNotEmpty(sendEventServiceTask.getEventType())) { xtw.writeCData(sendEventServiceTask.getEventType()); } else { LOGGER.warn("No event type configured for send event task {}", sendEventServiceTask.getId()); } xtw.writeEndElement(); if (StringUtils.isNotEmpty(sendEventServiceTask.getTriggerEventType())) { xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_TRIGGER_EVENT_TYPE, FLOWABLE_EXTENSIONS_NAMESPACE); xtw.writeCData(sendEventServiceTask.getTriggerEventType()); xtw.writeEndElement(); } if (sendEventServiceTask.isSendSynchronously()) { xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_SEND_SYNCHRONOUSLY, FLOWABLE_EXTENSIONS_NAMESPACE); xtw.writeCData(String.valueOf(sendEventServiceTask.isSendSynchronously())); xtw.writeEndElement(); } BpmnXMLUtil.writeIOParameters(ELEMENT_EVENT_IN_PARAMETER, sendEventServiceTask.getEventInParameters(), didWriteExtensionStartElement, xtw); BpmnXMLUtil.writeIOParameters(ELEMENT_EVENT_OUT_PARAMETER, sendEventServiceTask.getEventOutParameters(), didWriteExtensionStartElement, xtw); return didWriteExtensionStartElement; }
Example 10
Source File: ScriptsWidgetProperty.java From phoebus with Eclipse Public License 1.0 | 5 votes |
@Override public void writeToXML(final ModelWriter model_writer, final XMLStreamWriter writer) throws Exception { // <script file=".."> // <pv trigger="true">pv_name</pv> // </script> for (final ScriptInfo info : value) { writer.writeStartElement(XMLTags.SCRIPT); writer.writeAttribute(XMLTags.FILE, info.getPath()); if (! info.getCheckConnections()) writer.writeAttribute(XMLTags.CHECK_CONNECTIONS, Boolean.FALSE.toString()); final String text = info.getText(); if (text != null) { writer.writeStartElement(XMLTags.TEXT); writer.writeCData(text); writer.writeEndElement(); } for (final ScriptPV pv : info.getPVs()) { writer.writeStartElement(XMLTags.PV_NAME); if (! pv.isTrigger()) writer.writeAttribute(XMLTags.TRIGGER, Boolean.FALSE.toString()); writer.writeCharacters(pv.getName()); writer.writeEndElement(); } writer.writeEndElement(); } }
Example 11
Source File: DocumentStaxUtils.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Write the given string to the given writer, using either * writeCharacters or, if there are more than a few less than signs in * the string (e.g. if it is an XML fragment itself), write it with * writeCData. This method properly handles the case where the string * contains other CDATA sections - as a CDATA section cannot contain * the CDATA end marker <code>]]></code>, we split the output CDATA * at any occurrences of this marker and write the marker using a * normal writeCharacters call in between. * * @param xsw the writer to write to * @param string the string to write * @throws XMLStreamException */ static void writeCharactersOrCDATA(XMLStreamWriter xsw, String string) throws XMLStreamException { if(containsEnoughLTs(string)) { Matcher m = CDATA_END_PATTERN.matcher(string); int startFrom = 0; while(m.find()) { // we found a CDATA end marker, so write everything up to the // marker as CDATA... xsw.writeCData(string.substring(startFrom, m.start())); // then write the marker as characters xsw.writeCharacters("]]>"); startFrom = m.end(); } if(startFrom == 0) { // no "]]>" in the string, the normal case xsw.writeCData(string); } else if(startFrom < string.length()) { // there is some trailing text after the last ]]> xsw.writeCData(string.substring(startFrom)); } // else the last ]]> was the end of the string, so nothing more to // do. } else { // if fewer '<' characters, just writeCharacters as normal xsw.writeCharacters(string); } }
Example 12
Source File: ValuedDataObjectXMLConverter.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override protected boolean writeExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { ValuedDataObject dataObject = (ValuedDataObject) element; if (StringUtils.isNotEmpty(dataObject.getId()) && dataObject.getValue() != null) { if (!didWriteExtensionStartElement) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; } xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_DATA_VALUE, FLOWABLE_EXTENSIONS_NAMESPACE); if (dataObject.getValue() != null) { String value = null; if (dataObject instanceof DateDataObject) { value = sdf.format(dataObject.getValue()); } else { value = dataObject.getValue().toString(); } if (dataObject instanceof StringDataObject && xmlChars.matcher(value).find()) { xtw.writeCData(value); } else { xtw.writeCharacters(value); } } xtw.writeEndElement(); } return didWriteExtensionStartElement; }
Example 13
Source File: SequenceFlowXMLConverter.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { SequenceFlow sequenceFlow = (SequenceFlow) element; if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) { xtw.writeStartElement(ELEMENT_FLOW_CONDITION); xtw.writeAttribute(XSI_PREFIX, XSI_NAMESPACE, "type", "tFormalExpression"); xtw.writeCData(sequenceFlow.getConditionExpression()); xtw.writeEndElement(); } }
Example 14
Source File: ValuedDataObjectXMLConverter.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected boolean writeExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { ValuedDataObject dataObject = (ValuedDataObject) element; if (StringUtils.isNotEmpty(dataObject.getId()) && dataObject.getValue() != null) { if (didWriteExtensionStartElement == false) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; } xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ELEMENT_DATA_VALUE, ACTIVITI_EXTENSIONS_NAMESPACE); if (dataObject.getValue() != null) { String value = null; if (dataObject instanceof DateDataObject) { value = sdf.format(dataObject.getValue()); } else { value = dataObject.getValue().toString(); } if (dataObject instanceof StringDataObject && xmlChars.matcher(value).find()) { xtw.writeCData(value); } else { xtw.writeCharacters(value); } } xtw.writeEndElement(); } return didWriteExtensionStartElement; }
Example 15
Source File: CaseTaskExport.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override protected void writePlanItemDefinitionBody(CmmnModel model, CaseTask caseTask, XMLStreamWriter xtw) throws Exception { super.writePlanItemDefinitionBody(model, caseTask, xtw); // Always export the case reference as an expression, even if the caseRef is set if (StringUtils.isNotEmpty(caseTask.getCaseRef()) || StringUtils.isNotEmpty(caseTask.getCaseRefExpression())) { xtw.writeStartElement(ELEMENT_CASE_REF_EXPRESSION); xtw.writeCData( StringUtils.isNotEmpty(caseTask.getCaseRef()) ? caseTask.getCaseRef() : caseTask.getCaseRefExpression() ); xtw.writeEndElement(); } }
Example 16
Source File: BpmnXMLUtil.java From flowable-engine with Apache License 2.0 | 4 votes |
protected static void writeExtensionElement(ExtensionElement extensionElement, Map<String, String> namespaceMap, XMLStreamWriter xtw) throws Exception { if (StringUtils.isNotEmpty(extensionElement.getName())) { Map<String, String> localNamespaceMap = new HashMap<>(); if (StringUtils.isNotEmpty(extensionElement.getNamespace())) { if (StringUtils.isNotEmpty(extensionElement.getNamespacePrefix())) { xtw.writeStartElement(extensionElement.getNamespacePrefix(), extensionElement.getName(), extensionElement.getNamespace()); if (!namespaceMap.containsKey(extensionElement.getNamespacePrefix()) || !namespaceMap.get(extensionElement.getNamespacePrefix()).equals(extensionElement.getNamespace())) { xtw.writeNamespace(extensionElement.getNamespacePrefix(), extensionElement.getNamespace()); namespaceMap.put(extensionElement.getNamespacePrefix(), extensionElement.getNamespace()); localNamespaceMap.put(extensionElement.getNamespacePrefix(), extensionElement.getNamespace()); } } else { xtw.writeStartElement(extensionElement.getNamespace(), extensionElement.getName()); } } else { xtw.writeStartElement(extensionElement.getName()); } for (List<ExtensionAttribute> attributes : extensionElement.getAttributes().values()) { for (ExtensionAttribute attribute : attributes) { if (StringUtils.isNotEmpty(attribute.getName()) && attribute.getValue() != null) { if (StringUtils.isNotEmpty(attribute.getNamespace())) { if (StringUtils.isNotEmpty(attribute.getNamespacePrefix())) { if (!namespaceMap.containsKey(attribute.getNamespacePrefix()) || !namespaceMap.get(attribute.getNamespacePrefix()).equals(attribute.getNamespace())) { xtw.writeNamespace(attribute.getNamespacePrefix(), attribute.getNamespace()); namespaceMap.put(attribute.getNamespacePrefix(), attribute.getNamespace()); localNamespaceMap.put(attribute.getNamespacePrefix(), attribute.getNamespace()); } xtw.writeAttribute(attribute.getNamespacePrefix(), attribute.getNamespace(), attribute.getName(), attribute.getValue()); } else { xtw.writeAttribute(attribute.getNamespace(), attribute.getName(), attribute.getValue()); } } else { xtw.writeAttribute(attribute.getName(), attribute.getValue()); } } } } if (extensionElement.getElementText() != null) { xtw.writeCData(extensionElement.getElementText()); } else { for (List<ExtensionElement> childElements : extensionElement.getChildElements().values()) { for (ExtensionElement childElement : childElements) { writeExtensionElement(childElement, namespaceMap, xtw); } } } for (String prefix : localNamespaceMap.keySet()) { namespaceMap.remove(prefix); } xtw.writeEndElement(); } }
Example 17
Source File: SentryExport.java From flowable-engine with Apache License 2.0 | 4 votes |
public static void writeSentry(CmmnModel model, Sentry sentry, XMLStreamWriter xtw) throws Exception { // start sentry element xtw.writeStartElement(ELEMENT_SENTRY); xtw.writeAttribute(ATTRIBUTE_ID, sentry.getId()); if (StringUtils.isNotEmpty(sentry.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, sentry.getName()); } if (StringUtils.isNotEmpty(sentry.getTriggerMode()) && !Sentry.TRIGGER_MODE_DEFAULT.equals(sentry.getTriggerMode())) { // default is not exported. If missing, default is assumed xtw.writeAttribute(FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_TRIGGER_MODE, sentry.getTriggerMode()); } if (StringUtils.isNotEmpty(sentry.getDocumentation())) { xtw.writeStartElement(ELEMENT_DOCUMENTATION); xtw.writeCharacters(sentry.getDocumentation()); xtw.writeEndElement(); } boolean didWriteExtensionElement = CmmnXmlUtil.writeExtensionElements(sentry, false, model.getNamespaces(), xtw); if (didWriteExtensionElement) { xtw.writeEndElement(); } for (SentryOnPart sentryOnPart : sentry.getOnParts()) { // start sentry on part element xtw.writeStartElement(ELEMENT_PLAN_ITEM_ON_PART); xtw.writeAttribute(ATTRIBUTE_ID, sentryOnPart.getId()); xtw.writeAttribute(ATTRIBUTE_SOURCE_REF, sentryOnPart.getSourceRef()); // start standard event element xtw.writeStartElement(ELEMENT_STANDARD_EVENT); xtw.writeCharacters(sentryOnPart.getStandardEvent()); xtw.writeEndElement(); // end sentry on part element xtw.writeEndElement(); } // If part if (sentry.getSentryIfPart() != null) { xtw.writeStartElement(ELEMENT_IF_PART); xtw.writeStartElement(ELEMENT_CONDITION); xtw.writeCData(sentry.getSentryIfPart().getCondition()); xtw.writeEndElement(); xtw.writeEndElement(); } // end plan item element xtw.writeEndElement(); }
Example 18
Source File: CmmnXmlUtil.java From flowable-engine with Apache License 2.0 | 4 votes |
protected static void writeExtensionElement(ExtensionElement extensionElement, Map<String, String> namespaceMap, XMLStreamWriter xtw) throws Exception { if (StringUtils.isNotEmpty(extensionElement.getName())) { Map<String, String> localNamespaceMap = new HashMap<>(); if (StringUtils.isNotEmpty(extensionElement.getNamespace())) { if (StringUtils.isNotEmpty(extensionElement.getNamespacePrefix())) { xtw.writeStartElement(extensionElement.getNamespacePrefix(), extensionElement.getName(), extensionElement.getNamespace()); if (!namespaceMap.containsKey(extensionElement.getNamespacePrefix()) || !namespaceMap.get(extensionElement.getNamespacePrefix()).equals(extensionElement.getNamespace())) { xtw.writeNamespace(extensionElement.getNamespacePrefix(), extensionElement.getNamespace()); namespaceMap.put(extensionElement.getNamespacePrefix(), extensionElement.getNamespace()); localNamespaceMap.put(extensionElement.getNamespacePrefix(), extensionElement.getNamespace()); } } else { xtw.writeStartElement(extensionElement.getNamespace(), extensionElement.getName()); } } else { xtw.writeStartElement(extensionElement.getName()); } for (List<ExtensionAttribute> attributes : extensionElement.getAttributes().values()) { for (ExtensionAttribute attribute : attributes) { if (StringUtils.isNotEmpty(attribute.getName()) && attribute.getValue() != null) { if (StringUtils.isNotEmpty(attribute.getNamespace())) { if (StringUtils.isNotEmpty(attribute.getNamespacePrefix())) { if (!namespaceMap.containsKey(attribute.getNamespacePrefix()) || !namespaceMap.get(attribute.getNamespacePrefix()).equals(attribute.getNamespace())) { xtw.writeNamespace(attribute.getNamespacePrefix(), attribute.getNamespace()); namespaceMap.put(attribute.getNamespacePrefix(), attribute.getNamespace()); } xtw.writeAttribute(attribute.getNamespacePrefix(), attribute.getNamespace(), attribute.getName(), attribute.getValue()); } else { xtw.writeAttribute(attribute.getNamespace(), attribute.getName(), attribute.getValue()); } } else { xtw.writeAttribute(attribute.getName(), attribute.getValue()); } } } } if (extensionElement.getElementText() != null) { xtw.writeCData(extensionElement.getElementText()); } else { for (List<ExtensionElement> childElements : extensionElement.getChildElements().values()) { for (ExtensionElement childElement : childElements) { writeExtensionElement(childElement, namespaceMap, xtw); } } } for (String prefix : localNamespaceMap.keySet()) { namespaceMap.remove(prefix); } xtw.writeEndElement(); } }
Example 19
Source File: MultiInstanceExport.java From flowable-engine with Apache License 2.0 | 4 votes |
public static void writeMultiInstance(Activity activity, BpmnModel model, XMLStreamWriter xtw) throws Exception { if (activity.getLoopCharacteristics() != null) { MultiInstanceLoopCharacteristics multiInstanceObject = activity.getLoopCharacteristics(); CollectionHandler handler = multiInstanceObject.getHandler(); boolean didWriteExtensionStartElement = false; if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality()) || StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem()) || StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition()) || StringUtils.isNotEmpty(multiInstanceObject.getCollectionString())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE); BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL, String.valueOf(multiInstanceObject.isSequential()).toLowerCase(), xtw); // if a custom handler is not specified, then use the attribute if (handler == null && StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem())) { BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_MULTIINSTANCE_COLLECTION, multiInstanceObject.getInputDataItem(), xtw); } if (StringUtils.isNotEmpty(multiInstanceObject.getElementVariable())) { BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_MULTIINSTANCE_VARIABLE, multiInstanceObject.getElementVariable(), xtw); } if (StringUtils.isNotEmpty(multiInstanceObject.getElementIndexVariable())) { BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_MULTIINSTANCE_INDEX_VARIABLE, multiInstanceObject.getElementIndexVariable(), xtw); } // check for collection element handler extension first since process validation is order-dependent if (handler != null) { // start extensions xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; // start collection element xtw.writeStartElement(FLOWABLE_EXTENSIONS_NAMESPACE, ELEMENT_MULTIINSTANCE_COLLECTION); // collection handler attribute BpmnXMLUtil.writeQualifiedAttribute(handler.getImplementationType(), handler.getImplementation(), xtw); if (StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem())) { // use an expression element if there is a handler specified xtw.writeStartElement(FLOWABLE_EXTENSIONS_NAMESPACE, ELEMENT_MULTIINSTANCE_COLLECTION_EXPRESSION); xtw.writeCharacters(multiInstanceObject.getInputDataItem()); xtw.writeEndElement(); } else if (StringUtils.isNotEmpty(multiInstanceObject.getCollectionString())) { xtw.writeStartElement(FLOWABLE_EXTENSIONS_NAMESPACE, ELEMENT_MULTIINSTANCE_COLLECTION_STRING); xtw.writeCData(multiInstanceObject.getCollectionString().trim()); xtw.writeEndElement(); } // end collection element xtw.writeEndElement(); } // check for other custom extension elements Map<String, List<ExtensionElement>> extensions = multiInstanceObject.getExtensionElements(); if (!extensions.isEmpty()) { didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(multiInstanceObject, didWriteExtensionStartElement, model.getNamespaces(), xtw); } // end extensions element if (didWriteExtensionStartElement) { xtw.writeEndElement(); } if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CARDINALITY); xtw.writeCharacters(multiInstanceObject.getLoopCardinality()); xtw.writeEndElement(); } if (StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CONDITION); xtw.writeCharacters(multiInstanceObject.getCompletionCondition()); xtw.writeEndElement(); } // end multi-instance element xtw.writeEndElement(); } } }
Example 20
Source File: CDataNode.java From galleon with Apache License 2.0 | 4 votes |
@Override public void marshall(XMLStreamWriter writer) throws XMLStreamException { writer.writeCData(cdata); }