|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.empire.xml.XMLUtil
public class XMLUtil
This class provides a collection of static helper functions for common XML tasks. The class cannot be instanciated since all. methods provided are declared static.
Field Summary | |
---|---|
protected static org.slf4j.Logger |
log
|
Method Summary | |
---|---|
static Element |
addElement(Element parent,
String name)
Adds a child element to the parent. |
static Element |
addElement(Node parent,
String name,
String value)
Adds a new child element to a parent. |
static Element |
addElementNS(Element parent,
String prefix,
String name)
|
static Element |
addElementNS(Node parent,
String prefix,
String name,
String value)
Adds a new child element to a parent with a namespace. |
static boolean |
addNamespaceURIs(Document doc,
Map<String,String> nsMap)
|
static boolean |
changeTagName(Element elem,
String newName)
Changes the tag name of an element. |
static Document |
createDocument()
Returns a document newly created by the class's static DocumentBuilder. |
static Element |
createDocument(String rootElemName)
|
static Element |
createDocumentNS(String prefix,
String rootElemName,
Map<String,String> nsMap)
|
static Element |
findFirstChild(Node parent,
String tagName)
Finds the first (direct) child Element with a given tag name. |
static Element |
findFirstChildDeep(Document doc,
String tagName)
Returns the first element which name matchtes a given tag name. |
static Element |
findFirstChildDeep(Element parent,
String tagName)
Finds the first element which name matchtes a given tag name that is locacted anywhere below the given parent. |
static Element |
findFirstChildWithAttrib(Node parent,
String tagName,
String attrName,
Object value)
Finds the first (direct) child element with a given tag name and attribute. |
static String |
getChildText(Node parent,
String childName)
Returns the text value of a given child element. |
static DocumentBuilder |
getDocumentBuilder()
Returns an initialzed, namespace aware DocumentBuilder. |
static String |
getElementText(Node elem)
Retrieves the text of a given element. |
static Element |
getFirstChild(Node parent)
Gets the first (direct) child Element. |
static String |
getNamespaceURI(Document doc,
String prefix)
|
static Element |
getNextSiblingElement(Element child,
boolean sameName)
Returns the next sibling Element for an element, optionally matching tag names. |
static Element |
insertElement(Node parent,
String name,
Element pos)
|
static Element |
insertElement(Node parent,
String name,
String value,
Element pos)
Inserts a new child element to a parent. |
static Element |
insertElementNS(Node parent,
String prefix,
String name,
Element pos)
|
static Element |
insertElementNS(Node parent,
String prefix,
String name,
String value,
Element pos)
Inserts a new child element to a parent. |
static boolean |
setElementText(Node elem,
Object text)
Sets the text value of an Element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.slf4j.Logger log
Method Detail |
---|
public static Document createDocument()
public static DocumentBuilder getDocumentBuilder()
public static Element createDocument(String rootElemName)
public static Element createDocumentNS(String prefix, String rootElemName, Map<String,String> nsMap)
public static boolean addNamespaceURIs(Document doc, Map<String,String> nsMap)
public static String getNamespaceURI(Document doc, String prefix)
public static Element getFirstChild(Node parent)
parent
- the parent element below which to search the child
public static Element findFirstChild(Node parent, String tagName)
parent
- the parent element below which to search the childtagName
- the (tag) name of the desired child element
public static Element getNextSiblingElement(Element child, boolean sameName)
child
- the element from which to search for a next siblingsameName
- true to retrive the next sibling element of the same name, of false if any name is allowed
public static Element findFirstChildWithAttrib(Node parent, String tagName, String attrName, Object value)
parent
- the parent element below which to search the childtagName
- the (tag) name of the desired child elementattrName
- the name of the attribute which value must match the given valuevalue
- the attribute value to which elements are matched.
public static Element findFirstChildDeep(Element parent, String tagName)
parent
- the parent element below which to search the childtagName
- the (tag) name of the desired child element
public static Element findFirstChildDeep(Document doc, String tagName)
doc
- the xml document in which to find an element of the given nametagName
- the (tag) name of the desired child element
public static String getElementText(Node elem)
elem
- the Element for which the text value is requested
public static boolean setElementText(Node elem, Object text)
elem
- the Element for which the text value should be settext
- the new text value of the element
public static Element addElement(Node parent, String name, String value)
parent
- the Element to which to append the childname
- the (tag) name of the new childvalue
- the text value of the new element. (can be null!)
public static Element addElement(Element parent, String name)
parent
- name
-
public static Element addElementNS(Node parent, String prefix, String name, String value)
parent
- the Element to which to append the childprefix
- the name of the namespace this element belongs toname
- the (tag) name of the new childvalue
- the text value of the new element. (can be null!)
public static Element addElementNS(Element parent, String prefix, String name)
public static Element insertElement(Node parent, String name, String value, Element pos)
parent
- the Element to which to append the childname
- the (tag) name of the new childvalue
- the text value of the new element. (can be null!)pos
- the inserted element will be placed before this element
public static Element insertElement(Node parent, String name, Element pos)
public static Element insertElementNS(Node parent, String prefix, String name, String value, Element pos)
parent
- the Element to which to append the childprefix
- name
- the (tag) name of the new childvalue
- the text value of the new element. (can be null!)pos
- pos the inserted element will be placed before this element
public static Element insertElementNS(Node parent, String prefix, String name, Element pos)
public static String getChildText(Node parent, String childName)
parent
- the Element which contains the childchildName
- the (tag) name of the child
public static boolean changeTagName(Element elem, String newName)
elem
- Element which name should be changednewName
- new tag name of the element
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |