List of usage examples for org.w3c.dom Element getOwnerDocument
public Document getOwnerDocument();
Document
object associated with this node. From source file:org.fireflow.model.io.Util4Serializer.java
/** * Add a child element with the specific name to the given parent * element and return the child element. This method will use the * namespace of the parent element for the child element's namespace. * // w w w . j a v a 2s . c o m * @param parent The parent element * @param name The new child element name * @return The child element */ public static Element addElement(Element parent, String name) { Document doc = parent.getOwnerDocument(); String qualifiedName = name; if (!StringUtils.isEmpty(parent.getPrefix())) { qualifiedName = parent.getPrefix() + ":" + name; } Element child = doc.createElementNS(parent.getNamespaceURI(), qualifiedName); parent.appendChild(child); return child; }
From source file:org.fireflow.model.io.Util4Serializer.java
public static Element addElement(Element parent, QName qname) { Document doc = parent.getOwnerDocument(); String qualifiedName = qname.getLocalPart(); if (!StringUtils.isEmpty(qname.getPrefix())) { qualifiedName = qname.getPrefix() + ":" + qname.getLocalPart(); }//from w w w . java2 s . co m Element child = doc.createElementNS(parent.getNamespaceURI(), qualifiedName); parent.appendChild(child); return child; }
From source file:org.fireflow.model.io.Util4Serializer.java
/** * Add a child element with the specific name and the given value to * the given parent element and return the child element. This method * will use the namespace of the parent element for the child element's * namespace. If the given value is null then the default value is used. * If the value is null then this method will not add the child * element and will return null.//from ww w . j a v a 2 s . co m * * @param parent The parent element * @param name The new child element name * @param value The value * @param defaultValue The default value (if the value is null) * @return The child element */ public static Element addElement(Element parent, String name, Date value, Date defaultValue) { Document doc = parent.getOwnerDocument(); Element child = null; if (value == null) { value = defaultValue; } if (value != null) { child = addElement(parent, name); child.appendChild(doc.createTextNode(STANDARD_DF.format(value))); } return child; }
From source file:org.fireflow.model.io.Util4Serializer.java
/** * Add a child element with the specific name and the given value to * the given parent element and return the child element. This method * will use the namespace of the parent element for the child element's * namespace. If the given value is null then the default value is * used. If the value is null then this method will not add the child * element and will return null.//from ww w .java2s . co m * * @param parent The parent element * @param name The new child element name * @param value The value * @param defaultValue The default value (if the value is null) * @return The child element */ public static Element addElement(Element parent, String name, String value, String defaultValue) { Document doc = parent.getOwnerDocument(); Element child = null; if (value == null) { value = defaultValue; } if (value != null) { child = addElement(parent, name); child.appendChild(doc.createTextNode(value)); } return child; }
From source file:org.fireflow.model.io.Util4Serializer.java
/** * Add a child element with the specific name and the given value to * the given parent element and return the child element. This method * will use the namespace of the parent element for the child element's * namespace. If the given value is null then the default value is * used. If the value is null then this method will not add the child * element and will return null./*from w w w .j a va 2 s. c om*/ * * @param parent The parent element * @param name The new child element name * @param value The value * @param defaultValue The default value (if the value is null) * @return The child element */ public static Element addElement(Element parent, String name, URL value, URL defaultValue) { Document doc = parent.getOwnerDocument(); Element child = null; if (value == null) { value = defaultValue; } if (value != null) { child = addElement(parent, name); child.appendChild(doc.createTextNode(value.toString())); } return child; }
From source file:org.fireflow.model.io.Util4Serializer.java
/** * Add a child element with the specific name and the given value to * the given parent element and return the child element. This method * will use the namespace of the parent element for the child element's * namespace. If the given value is null then the default value is * used. If the value is null then this method will not add the child * element and will return null./*from w ww .j a v a 2s . c o m*/ * * @param parent The parent element * @param name The new child element name * @param value The value * @param defaultValue The default value (if the value is null) * @return The child element */ public static Element addElement(Element parent, String name, Duration value, Duration defaultValue) { Element child = null; Document doc = parent.getOwnerDocument(); if (value == null) { value = defaultValue; } if (value != null) { child = addElement(parent, name); child.appendChild(doc.createTextNode(value.toString())); } return child; }
From source file:org.fireflow.pdl.fpdl.io.FPDLSerializer.java
protected void writeLabel(Label lb, Element parentElm) { if (lb != null) { Element labelElm = Util4Serializer.addElement(parentElm, LABEL); if (!StringUtils.isEmpty(lb.getTextDirection())) { labelElm.setAttribute(TEXT_DIRECTION, lb.getTextDirection()); }/*from www.j ava 2 s . c om*/ if (!StringUtils.isEmpty(lb.getFontName())) { labelElm.setAttribute(FONT_NAME, lb.getFontName()); } labelElm.setAttribute(SIZE, Integer.toString(lb.getFontSize())); if (!StringUtils.isEmpty(lb.getFontColor())) { labelElm.setAttribute(COLOR, lb.getFontColor()); } if (!StringUtils.isEmpty(lb.getFontStyle())) { labelElm.setAttribute(FONT_STYLE, lb.getFontStyle()); } Document doc = parentElm.getOwnerDocument(); CDATASection cdata = doc .createCDATASection(useJDKTransformerFactory ? (" " + lb.getText()) : lb.getText());//?jdkGBK bug labelElm.appendChild(cdata); } }
From source file:org.fireflow.pdl.fpdl.io.FPDLSerializer.java
protected void writeExpression(Expression exp, Element parent) { if (exp == null) return;/*from w w w .ja v a 2 s . c om*/ Element expressionElem = Util4Serializer.addElement(parent, EXPRESSION); if (exp.getName() != null && !exp.getName().trim().equals("")) { expressionElem.setAttribute(NAME, exp.getName()); } if (exp.getDisplayName() != null && !exp.getDisplayName().trim().equals("")) { expressionElem.setAttribute(DISPLAY_NAME, exp.getDisplayName()); } if (exp.getDataType() != null) { expressionElem.setAttribute(DATA_TYPE, exp.getDataType().toString()); } expressionElem.setAttribute(LANGUAGE, exp.getLanguage()); Document doc = parent.getOwnerDocument(); Element bodyElem = Util4Serializer.addElement(expressionElem, BODY); String body = exp.getBody() != null ? exp.getBody() : ""; CDATASection cdata = doc.createCDATASection(useJDKTransformerFactory ? (" " + body) : body);//?jdk GBK bug bodyElem.appendChild(cdata); if (exp.getNamespaceMap() != null && exp.getNamespaceMap().size() > 0) { Element namespaceMapElem = Util4Serializer.addElement(expressionElem, NAMESPACE_PREFIX_URI_MAP); Iterator<Map.Entry<String, String>> entrys = exp.getNamespaceMap().entrySet().iterator(); while (entrys.hasNext()) { Map.Entry<String, String> entry = entrys.next(); Element entryElem = Util4Serializer.addElement(namespaceMapElem, ENTRY); entryElem.setAttribute(NAME, entry.getKey()); entryElem.setAttribute(VALUE, entry.getValue()); } } }
From source file:org.fireflow.pdl.fpdl.io.FPDLSerializer.java
protected void writeDescription(Element parent, String desc) { if (desc == null || desc.trim().equals("")) return;//w ww. java2 s . c om Document doc = parent.getOwnerDocument(); Element descElem = Util4Serializer.addElement(parent, DESCRIPTION); CDATASection cdata = doc.createCDATASection(useJDKTransformerFactory ? (" " + desc) : desc);//?jdkGBK bug descElem.appendChild(cdata); }
From source file:org.fireflow.service.email.send.MailSendServiceParser.java
@Override public void serializeService(ServiceDef service, Element parentElement) throws SerializerException { if (!(service instanceof MailSendServiceDef)) { return;/* w w w . ja va 2 s .c o m*/ } MailSendServiceDef mailSendServiceDef = (MailSendServiceDef) service; Document document = parentElement.getOwnerDocument(); Element svcElem = document.createElementNS(SERVICE_NS_URI, SERVICE_NS_PREFIX + ":" + SERVICE_NAME); parentElement.appendChild(svcElem); this.writeCommonServiceAttribute(mailSendServiceDef, svcElem); //? Element mailTemplateElement = Util4Serializer.addElement(svcElem, MAIL_TEMPLATE); Util4Serializer.addElement(mailTemplateElement, FROM, mailSendServiceDef.getFrom()); if (mailSendServiceDef.getMailTemplate() != null) { MailTemplate template = mailSendServiceDef.getMailTemplate(); if (template.getMailToList() != null) { Element _elem = Util4Serializer.addElement(mailTemplateElement, MAILTO_LIST); this.writeExpression(template.getMailToList(), _elem); } if (template.getCarbonCopyList() != null) { Element _elem = Util4Serializer.addElement(mailTemplateElement, CARBONCOPY_LIST); this.writeExpression(template.getCarbonCopyList(), _elem); } if (template.getSubject() != null) { Element _elem = Util4Serializer.addElement(mailTemplateElement, SUBJECT); this.writeExpression(template.getSubject(), _elem); } if (template.getBody() != null) { Element _elem = Util4Serializer.addElement(mailTemplateElement, EMAIL_BODY); this.writeExpression(template.getBody(), _elem); } if (template.getBodyIsHtml() != null) { Element _elem = Util4Serializer.addElement(mailTemplateElement, BODY_IS_HTML); this.writeExpression(template.getBodyIsHtml(), _elem); } } //? Element connectInfoElement = Util4Serializer.addElement(svcElem, CONNECT_INFO); Util4Serializer.addElement(connectInfoElement, PROTOCOL, mailSendServiceDef.getProtocol()); Util4Serializer.addElement(connectInfoElement, SERVER_URL, mailSendServiceDef.getSmtpServer()); Util4Serializer.addElement(connectInfoElement, PORT, Integer.toString(mailSendServiceDef.getSmtpPort())); Util4Serializer.addElement(connectInfoElement, NEED_AUTH, Boolean.toString(mailSendServiceDef.isNeedAuth())); Util4Serializer.addElement(connectInfoElement, USER_NAME, mailSendServiceDef.getUserName()); Util4Serializer.addElement(connectInfoElement, PASSWORD, mailSendServiceDef.getPassword()); Util4Serializer.addElement(connectInfoElement, USE_SSL, Boolean.toString(mailSendServiceDef.isUseSSL())); Util4Serializer.addElement(connectInfoElement, CHARSET, mailSendServiceDef.getCharset()); this.writeExtendedAttributes(mailSendServiceDef.getExtendedAttributes(), svcElem); }