List of usage examples for org.dom4j DocumentHelper makeElement
public static Element makeElement(Branch source, String path)
makeElement
a helper method which navigates from the given Document or Element node to some Element using the path expression, creating any necessary elements along the way.From source file:org.pentaho.actionsequence.dom.ImplicitActionResource.java
License:Open Source License
public void setName(String resourceName) { if (actionDefinition != null) { IActionResource actionResource = actionDefinition.getResource(this.resourceName, false); if (actionResource != null) { actionResource.setName(resourceName); } else {/* ww w . ja v a 2s. co m*/ Element tempElement = getElement(); Element resourcesParent = DocumentHelper.makeElement(actionDefinition.getElement(), ActionSequenceDocument.ACTION_RESOURCES_NAME); //$NON-NLS-1$ resourcesParent.add(tempElement); super.setName(resourceName); } } else { super.setName(resourceName); } this.resourceName = resourceName; }
From source file:org.pentaho.actionsequence.dom.ImplicitActionResource.java
License:Open Source License
public void setType(String ioType) { if (actionDefinition != null) { IActionResource actionResource = actionDefinition.getResource(resourceName, false); if (actionResource != null) { actionResource.setType(ioType); } else {//from w ww.ja va2 s . co m Element tempElement = getElement(); Element resourcesParent = DocumentHelper.makeElement(actionDefinition.getElement(), ActionSequenceDocument.ACTION_RESOURCES_NAME); //$NON-NLS-1$ resourcesParent.add(tempElement); super.setType(ioType); } } else { super.setType(ioType); } }
From source file:org.pentaho.actionsequence.dom.ImplicitActionResource.java
License:Open Source License
public void setURI(URI uri) { if (actionDefinition != null) { IActionResource actionResource = actionDefinition.getResource(resourceName, false); if (actionResource != null) { actionResource.setURI(uri);//from w w w .ja v a 2s . c o m } else { Element tempElement = getElement(); Element resourcesParent = DocumentHelper.makeElement(actionDefinition.getElement(), ActionSequenceDocument.ACTION_RESOURCES_NAME); //$NON-NLS-1$ resourcesParent.add(tempElement); super.setURI(uri); } } else { super.setURI(uri); } }
From source file:org.pentaho.pac.server.config.AbstractDiagnosticsJmxXml.java
License:Open Source License
protected void setAttributeResultCode(String attributeName, String resultCode) { String attrXPath = MessageFormat.format(ATTRIBUTE_RESULT_CODE_XPATH, attributeName); Element attrElement = (Element) document.selectSingleNode(attrXPath); if (resultCode == null) { if (attrElement != null) { attrElement.detach();//from ww w . j av a2 s. c om } } else { if (attrElement == null) { attrElement = document.getRootElement().addElement(ATTRIBUTE_ELEMENT); attrElement.addAttribute(ID_ATTRIBUTE, attributeName); } Element attrValueElement = DocumentHelper.makeElement(attrElement, RESULT_CODE_ELEMENT); attrValueElement.setText(resultCode); } }
From source file:org.pentaho.pac.server.config.AbstractDiagnosticsJmxXml.java
License:Open Source License
protected void setAttributeValue(String attributeName, String attributeValue) { String attrXPath = MessageFormat.format(ATTRIBUTE_XPATH, attributeName); Element attrElement = (Element) document.selectSingleNode(attrXPath); if (attributeValue == null) { if (attrElement != null) { attrElement.detach();/*from w ww .j av a 2 s . c o m*/ } } else { if (attrElement == null) { attrElement = document.getRootElement().addElement(ATTRIBUTE_ELEMENT); attrElement.addAttribute(ID_ATTRIBUTE, attributeName); } Element attrValueElement = DocumentHelper.makeElement(attrElement, VALUE_ELEMENT); attrValueElement.setText(attributeValue); } }
From source file:org.pentaho.pac.server.config.ConsoleConfigXml.java
License:Open Source License
public void setValue(String xPath, String value) { Element element = (Element) document.selectSingleNode(xPath); if (element == null) { element = DocumentHelper.makeElement(document, xPath); }//w w w . ja v a2s.c o m element.setText(value); }
From source file:org.pentaho.pac.server.config.EmailConfigXml.java
License:Open Source License
private void setValue(String xPath, String value) { Element element = (Element) document.selectSingleNode(xPath); if (element == null) { element = DocumentHelper.makeElement(document, xPath); }// www.j av a 2 s . c o m element.setText(value); }
From source file:org.pentaho.pac.server.config.HibernateConfigXml.java
License:Open Source License
private void setValue(String xPath, String value, boolean useCData) { Element element = (Element) document.selectSingleNode(xPath); if (element == null) { element = DocumentHelper.makeElement(document, xPath); }/*from w w w. j ava2s .c om*/ if (useCData) { element.clearContent(); element.addCDATA(value); } else { element.setText(value); } }
From source file:org.pentaho.pac.server.config.PublisherConfigXml.java
License:Open Source License
private void setValue(Document document, String xPath, String value) { Element element = (Element) document.selectSingleNode(xPath); if (element == null) { element = DocumentHelper.makeElement(document, xPath); }/*from w ww . j ava 2 s .co m*/ element.setText(value); }
From source file:org.pentaho.pac.server.config.SystemListenersConfig.java
License:Open Source License
private Element addSystemListenerElement(String listenerId, String listenerClassName) { DocumentHelper.makeElement(document, LISTENER_LIST_XPATH); Element listenerBeanElement = getSystemListenerElement(listenerId, listenerClassName); if (listenerBeanElement == null) { Element listenerListElement = (Element) document.selectSingleNode(LISTENER_LIST_XPATH); listenerBeanElement = listenerListElement.addElement(BEAN_ELEMENT); listenerBeanElement.addAttribute(CLASS_ATTRIBUTE, listenerClassName); if (listenerId != null) { listenerBeanElement.addAttribute(ID_ATTRIBUTE, listenerClassName); }//w w w . ja v a 2s . c om } return listenerBeanElement; }