Package com.im.df.api.util.xml
Class XMLUtils
- java.lang.Object
-
- com.im.df.api.util.xml.XMLUtils
-
public final class XMLUtils extends java.lang.ObjectThis class should collect various XML manipulation utilities not found in JAXP APIs.- Author:
- svata
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.w3c.dom.ElementfindFirstChild(org.w3c.dom.Node parent, java.lang.String name)Finds the first direct child element named "name" under the specified parent.static java.lang.StringgetAttributeValue(org.w3c.dom.Element parent, java.lang.String attribute)Helper method, that returns the attribute value or null, if the attribute is not defined.static java.util.List<org.w3c.dom.Element>getChildren(org.w3c.dom.Element parent, java.lang.String tagName)Builds a list of direct childNodes of an Element with the specified tag name.static java.lang.ObjectloadBean(java.lang.String content, java.lang.Object prototype, org.openide.util.Lookup context)static java.lang.ObjectloadBean(java.lang.String content, java.lang.Object prototype, org.openide.util.Lookup context, PersisterRegistry registry)static java.lang.StringmakeXmlPretty(java.lang.String xml)static java.lang.StringmakeXmlPretty(org.dom4j.Document doc)static java.lang.StringsaveBean(java.lang.Object bean, org.openide.util.Lookup context)static java.lang.StringsaveBean(java.lang.Object bean, org.openide.util.Lookup context, PersisterRegistry registry)static voidthrowWrappedIOException(java.lang.Throwable cause)
-
-
-
Method Detail
-
makeXmlPretty
public static java.lang.String makeXmlPretty(java.lang.String xml)
-
makeXmlPretty
public static java.lang.String makeXmlPretty(org.dom4j.Document doc)
-
getAttributeValue
public static java.lang.String getAttributeValue(org.w3c.dom.Element parent, java.lang.String attribute)Helper method, that returns the attribute value or null, if the attribute is not defined. DOM method getAttribute will return an empty string, if the attribute node does not exist, which is not desirable in some cases.
-
findFirstChild
public static org.w3c.dom.Element findFirstChild(org.w3c.dom.Node parent, java.lang.String name)Finds the first direct child element named "name" under the specified parent. The method ignores XML namespaces.- Parameters:
parent- The parent to search inname- The tag name to search for- Returns:
- The Element or null, if there's no such child.
-
getChildren
public static java.util.List<org.w3c.dom.Element> getChildren(org.w3c.dom.Element parent, java.lang.String tagName)Builds a list of direct childNodes of an Element with the specified tag name. This method does not respect XML namespaces. Note that the DOM method getElementsByTagName returns all descendants that use the specified tag, not just direct children.
-
throwWrappedIOException
public static void throwWrappedIOException(java.lang.Throwable cause) throws java.io.IOException- Throws:
java.io.IOException
-
loadBean
public static java.lang.Object loadBean(java.lang.String content, java.lang.Object prototype, org.openide.util.Lookup context) throws java.io.IOException- Throws:
java.io.IOException
-
loadBean
public static java.lang.Object loadBean(java.lang.String content, java.lang.Object prototype, org.openide.util.Lookup context, PersisterRegistry registry) throws java.io.IOException- Throws:
java.io.IOException
-
saveBean
public static java.lang.String saveBean(java.lang.Object bean, org.openide.util.Lookup context) throws java.io.IOException- Throws:
java.io.IOException
-
saveBean
public static java.lang.String saveBean(java.lang.Object bean, org.openide.util.Lookup context, PersisterRegistry registry) throws java.io.IOException- Throws:
java.io.IOException
-
-