|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.backsource.utils.xml.ElementUtil
Utility methods to help working with Elements.
To work in Nodes instead, see DocumentUtil
| Method Summary | |
static java.lang.String |
getAttribute(org.w3c.dom.Element element,
java.lang.String name)
Get attribute with name name from element, only return a non null value if the attribute was not null and not an empty string. |
static java.lang.String |
getAttribute(org.w3c.dom.Element element,
java.lang.String name,
java.lang.String defaultValue)
Get attribute with name name from element, only return a non null value if the attribute was not null and not an empty string, otherwise return defaultValue. |
static boolean |
getAttributeAsBoolean(org.w3c.dom.Element e,
java.lang.String name)
Get the an attribute as a boolean. |
static float |
getAttributeAsFloat(org.w3c.dom.Element e,
java.lang.String name)
Get the an attribute as a float. |
static int |
getAttributeAsInt(org.w3c.dom.Element e,
java.lang.String name)
Get the an attribute as an int |
static long |
getAttributeAsLong(org.w3c.dom.Element e,
java.lang.String name)
Get the an attribute as a long |
static java.lang.String |
getContent(org.w3c.dom.Element element)
Get the string content of the element. |
static java.lang.String |
getContent(org.w3c.dom.Element element,
java.lang.String defaultStr)
Get the string content of the element. |
static java.util.List |
getElements(org.w3c.dom.Element element)
Get all element children of element. |
static java.util.List |
getElementsByTagName(org.w3c.dom.Element element,
java.lang.String tagName)
Get all element children of element whitch match tagName |
static org.w3c.dom.Element |
getOptionalChild(org.w3c.dom.Element element,
java.lang.String tagName)
Gets the child of the specified element having the specified name. |
static org.w3c.dom.Element |
getOptionalChild(org.w3c.dom.Element element,
java.lang.String tagName,
org.w3c.dom.Element defaultElement)
Gets the child of the specified element having the specified name. |
static org.w3c.dom.Element |
getUniqueChild(org.w3c.dom.Element element,
java.lang.String tagName)
Gets the child of the specified element having the specified unique name. |
static void |
main(java.lang.String[] args)
|
static void |
setContent(org.w3c.dom.Element element,
java.lang.String content)
Set the text content of this element. |
static void |
setElement(org.w3c.dom.Element element,
org.w3c.dom.DocumentFragment content)
Set DocumentFragment as a child element, removing all old elements. |
static void |
setElement(org.w3c.dom.Element element,
org.w3c.dom.Element content)
Set element as a child element, removing all old elements. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static java.util.List getElements(org.w3c.dom.Element element)
throws XmlException
XmlException
public static java.util.List getElementsByTagName(org.w3c.dom.Element element,
java.lang.String tagName)
throws XmlException
XmlException
public static org.w3c.dom.Element getOptionalChild(org.w3c.dom.Element element,
java.lang.String tagName)
throws XmlException
element - the parent elementtagName - the name of the desired child
XmlException
public static org.w3c.dom.Element getOptionalChild(org.w3c.dom.Element element,
java.lang.String tagName,
org.w3c.dom.Element defaultElement)
throws XmlException
element - the parent elementtagName - the name of the desired childdefaultElement - the element to return if the child
doesn't exist
XmlException
public static org.w3c.dom.Element getUniqueChild(org.w3c.dom.Element element,
java.lang.String tagName)
throws XmlException
element - The parent elementtagName - The name of the desired child
XmlException - Child was not found or was not unique.public static java.lang.String getContent(org.w3c.dom.Element element)
public static java.lang.String getContent(org.w3c.dom.Element element,
java.lang.String defaultStr)
public static void setContent(org.w3c.dom.Element element,
java.lang.String content)
throws XmlException
XmlException
public static void setElement(org.w3c.dom.Element element,
org.w3c.dom.Element content)
throws XmlException
XmlException
public static void setElement(org.w3c.dom.Element element,
org.w3c.dom.DocumentFragment content)
throws XmlException
XmlException
public static java.lang.String getAttribute(org.w3c.dom.Element element,
java.lang.String name)
throws XmlException
XmlException - if element or name is null.
public static java.lang.String getAttribute(org.w3c.dom.Element element,
java.lang.String name,
java.lang.String defaultValue)
throws XmlException
XmlException - if element or name is null.
public static int getAttributeAsInt(org.w3c.dom.Element e,
java.lang.String name)
throws XmlException
XmlException - if the attribute could not be parsed.
public static long getAttributeAsLong(org.w3c.dom.Element e,
java.lang.String name)
throws XmlException
XmlException - if the attribute could not be parsed.
public static boolean getAttributeAsBoolean(org.w3c.dom.Element e,
java.lang.String name)
throws XmlException
XmlException - if the attribute could not be parsed.
public static float getAttributeAsFloat(org.w3c.dom.Element e,
java.lang.String name)
throws XmlException
XmlException - if the attribute could not be parsed.public static void main(java.lang.String[] args)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||