List of usage examples for org.dom4j DocumentHelper createElement
public static Element createElement(String name)
From source file:org.infoglue.cms.applications.contenttool.actions.SimpleContentXmlAction.java
License:Open Source License
public Element getContentVersionElement(ContentVersionVO vo) throws SystemException, Bug, UnsupportedEncodingException { Element element = DocumentHelper.createElement("contentVersion"); element.add(getContentVersionHeadElement(vo)); element.add(getContentVersionValueElement(vo)); return element; }
From source file:org.infoglue.cms.applications.contenttool.actions.SimpleContentXmlAction.java
License:Open Source License
public Element getContentVersionHeadElement(ContentVersionVO vo) throws SystemException, Bug, UnsupportedEncodingException { Element head = DocumentHelper.createElement("head"); head.addAttribute("id", "" + vo.getContentVersionId()); head.addAttribute("languageId", "" + vo.getLanguageId()); head.addAttribute("contentId", "" + vo.getContentId()); head.addAttribute("languageName", vo.getLanguageName()); head.addAttribute("isActive", "" + vo.getIsActive()); head.addAttribute("mod", "" + vo.getModifiedDateTime().getTime()); head.addAttribute("activeVersionModifier", "" + vo.getVersionModifier()); head.addAttribute("activeVersionStateId", "" + vo.getStateId()); return head;//from www . j a v a 2 s.c o m }
From source file:org.infoglue.cms.applications.contenttool.actions.SimpleContentXmlAction.java
License:Open Source License
public Element getContentVersionValueElement(ContentVersionVO vo) throws SystemException, Bug, UnsupportedEncodingException { Element value = DocumentHelper.createElement("value"); if (enableCompression) { Base64Encoder encoder = new Base64Encoder(); CompressionHelper zip = new CompressionHelper(); byte[] val = zip.compress(vo.getVersionValue()); value.addCDATA(encoder.encode(val)); } else {//from ww w.jav a 2 s. c o m value.addCDATA(URLEncoder.encode(vo.getVersionValue(), "UTF-8")); } return value; }
From source file:org.infoglue.cms.applications.contenttool.actions.SimpleContentXmlAction.java
License:Open Source License
public String doContentVersionHead() throws Exception { Document doc = DocumentHelper.createDocument(); Element element = DocumentHelper.createElement("contentVersion"); element.add(getContentVersionHeadElement(parent)); element.add(DocumentHelper.createElement("value")); doc.add(element);/*from w w w . j a v a2 s .co m*/ return out(getFormattedDocument(doc)); }
From source file:org.jasig.portal.layout.dlm.FragmentDefinition.java
License:Apache License
@Override public void toElement(org.dom4j.Element parent) { // Assertions. if (parent == null) { String msg = "Argument 'parent' cannot be null."; throw new IllegalArgumentException(msg); }/*from w ww. j a va 2s. co m*/ QName q = new QName("fragment", FragmentDefinition.NAMESPACE); org.dom4j.Element rslt = DocumentHelper.createElement(q); rslt.addAttribute("name", this.getName()); rslt.addAttribute("ownerID", this.getOwnerId()); rslt.addAttribute("precedence", Double.toString(this.getPrecedence())); rslt.addAttribute("description", this.getDescription()); // Serialize our children... for (Evaluator v : this.evaluators) { v.toElement(rslt); } parent.add(rslt); }
From source file:org.jasig.portal.layout.dlm.providers.AllUsersEvaluatorFactory.java
License:Apache License
@Override public void toElement(Element parent) { // Assertions. if (parent == null) { String msg = "Argument 'parent' cannot be null."; throw new IllegalArgumentException(msg); }//from w w w . ja v a2 s .co m Element rslt = null; QName q = new QName("audience", FragmentDefinition.NAMESPACE); rslt = DocumentHelper.createElement(q); rslt.addAttribute("evaluatorFactory", this.getFactoryClass().getName()); parent.add(rslt); }
From source file:org.jasig.portal.layout.dlm.providers.AttributeEvaluator.java
License:Apache License
@Override public void toElement(Element parent) { // Assertions. if (parent == null) { String msg = "Argument 'parent' cannot be null."; throw new IllegalArgumentException(msg); }//from w ww.ja va 2s. c o m String mde = null; switch (this.mode) { case AttributeEvaluator.CONTAINS: mde = "contains"; break; case AttributeEvaluator.EQUALS: mde = "equals"; break; case AttributeEvaluator.STARTS_WITH: mde = "startsWith"; break; case AttributeEvaluator.ENDS_WITH: mde = "endsWith"; break; case AttributeEvaluator.EXISTS: mde = "exists"; break; default: throw new IllegalStateException("Unrecognized mode constant: " + this.mode); } Element rslt = DocumentHelper.createElement("attribute"); rslt.addAttribute("name", this.name); rslt.addAttribute("mode", mde); rslt.addAttribute("value", this.value); parent.add(rslt); }
From source file:org.jasig.portal.layout.dlm.providers.GroupMembershipEvaluator.java
License:Apache License
@Override public void toElement(Element parent) { // Assertions. if (parent == null) { String msg = "Argument 'parent' cannot be null."; throw new IllegalArgumentException(msg); }/*from www . j a v a2 s. c o m*/ String mde = null; switch (this.evaluatorMode) { case MEMBER_OF_MODE: mde = "memberOf"; break; case DEEP_MEMBER_OF_MODE: mde = "deepMemberOf"; break; default: throw new IllegalStateException("Unrecognized evaluatorMode constant: " + this.evaluatorMode); } Element rslt = DocumentHelper.createElement("attribute"); rslt.addAttribute("mode", mde); rslt.addAttribute("name", this.groupName); parent.add(rslt); }
From source file:org.jasig.portal.layout.dlm.providers.Paren.java
License:Apache License
@Override public void toElement(Element parent) { // Assertions. if (parent == null) { String msg = "Argument 'parent' cannot be null."; throw new IllegalArgumentException(msg); }/* w ww . j av a2 s.c om*/ // NB: This method behaves vastly different depending on whether // the parent of this Paren is an instance of FragmentDefinition. Element rslt = null; if (parent.getName().equals("fragment")) { // The parent is a fragment, so we render as a <dlm:audience> element... QName q = new QName("audience", FragmentDefinition.NAMESPACE); rslt = DocumentHelper.createElement(q); // Discover the EvaluatorFactory class... rslt.addAttribute("evaluatorFactory", this.getFactoryClass().getName()); } else { // The parent is *not* a fragment, so we render as a <paren> element... rslt = DocumentHelper.createElement("paren"); rslt.addAttribute("mode", this.type.toString()); } // Serialize our children... for (Evaluator v : this.evaluators) { v.toElement(rslt); } // Append ourself... parent.add(rslt); }
From source file:org.jboss.tools.jbpm.convert.bpmnto.util.DomXmlWriter.java
License:Open Source License
@SuppressWarnings("unchecked") public static Element addElement(Element element, String elementName, int location) { Element newElement = null;/*from www. j a v a2 s .com*/ if (element.elements(elementName) != null && element.elements(elementName).size() > location && location >= 0) { newElement = DocumentHelper.createElement(elementName); element.elements(elementName).add(location, newElement); } return newElement; }