public class ConfigXmlUtils extends Object
Modifier and Type | Method and Description |
---|---|
static org.dom4j.Element |
createNewElement(org.dom4j.Element parent,
String elementName)
Add a new child element to the passed parent.
|
static org.dom4j.Element |
getElementByXpath(org.dom4j.Document document,
String xpath)
Return the element matched by the passed XPath.
|
static List<org.dom4j.Element> |
getElementsByXpath(org.dom4j.Document document,
String xpath)
Find all the elements returned by the passed xpath.
|
static Integer |
getIntegerValue(org.dom4j.Element element,
String attribute)
Get the integer value of the passed attribute off the passed element.
|
static Long |
getLongValue(org.dom4j.Element element,
String attribute)
Get the long value of the passed attribute off the passed element.
|
static String |
getTextValue(org.dom4j.Element element,
String attribute)
Get the text value of the passed attribute off the passed element.
|
static List<org.dom4j.Element> |
getTopElementsByName(org.dom4j.Document document,
String name)
Return all the elements directly under the root of the passed document with the passed name.
|
static void |
removeAttribute(org.dom4j.Element element,
String attributeName)
Remove the attribute from the passed element.
|
static boolean |
removeElement(org.dom4j.Element element)
Remove the passed element from dom tree.
|
static void |
setAttribute(org.dom4j.Element element,
String attributeName,
Object attributeValue)
Sets the attribute of the passed element.
|
public static org.dom4j.Element createNewElement(org.dom4j.Element parent, String elementName)
parent
- the node to add the element to.elementName
- the name of the element to add.public static void setAttribute(org.dom4j.Element element, String attributeName, Object attributeValue)
element
- the element to set the attribute on.attributeName
- the name of the attribute to set.attributeValue
- the value of the attribute.public static void removeAttribute(org.dom4j.Element element, String attributeName)
element
- the element to remove the attribute from.attributeName
- the name of the attribute to remove.public static String getTextValue(org.dom4j.Element element, String attribute)
element
- the element to get the attribute off.attribute
- the name of the attribute to find.public static Long getLongValue(org.dom4j.Element element, String attribute)
element
- the element to get the attribute off.attribute
- the name of the attribute to find.public static Integer getIntegerValue(org.dom4j.Element element, String attribute)
element
- the element to get the attribute off.attribute
- the name of the attribute to find.public static boolean removeElement(org.dom4j.Element element)
element
- the element to remove.public static List<org.dom4j.Element> getElementsByXpath(org.dom4j.Document document, String xpath)
IllegalArgumentException
if the passed
xpath returns anything by Element
s.document
- the document to run the xpath on.xpath
- the xpath to run.IllegalArgumentException
- if the xpath returns non-element nodes.public static org.dom4j.Element getElementByXpath(org.dom4j.Document document, String xpath)
IllegalArgumentException
will be thrown. A null value will be returned if the xpath matches nothing.document
- the document to run the xpath over.xpath
- the xpath to run.public static List<org.dom4j.Element> getTopElementsByName(org.dom4j.Document document, String name)
document
- the document to look through.name
- the name of the elements to return.Copyright © 2002-2015 Atlassian. All Rights Reserved.