|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.doolin.util.xml.DOMUtils
public class DOMUtils
Methods for exploring a DOM tree. This class, for performances reasons, does not use any XPath expression.
| Method Summary | ||
|---|---|---|
static String |
getAttribute(Element eNode,
String attName,
boolean mandatory,
String defaultValue)
Get the text of an attribute. |
|
static String |
getAttribute(Element eNode,
String attName,
String defaultValue)
Get the text of an attribute. |
|
static boolean |
getBoolean(Element eParent,
String childName,
boolean mandatory,
boolean defaultValue)
Get the text of a child element as a boolean. |
|
static boolean |
getBooleanAttribute(Element eNode,
String attName,
boolean mandatory,
boolean defaultValue)
Get the text of an attribute as a boolean. |
|
static
|
getClassAttribute(Element eNode,
String attName,
Class<T> defaultClass)
Get a type attribute from an element. |
|
static Element |
getElement(Element eParent,
String childName)
Get a child element. |
|
static Element |
getElement(Element eParent,
String namespaceURI,
String childName)
Get a child element. |
|
static List<Element> |
getElements(Element eParent)
List of all child elements |
|
static List<Element> |
getElements(Element eParent,
String name)
List of childrens with a given tag name and namespace |
|
static List<Element> |
getElements(Element eParent,
String namespaceURI,
String name)
List of childrens with a given tag name. |
|
static Element |
getFirstChildElement(Element eParent)
Get the first element child of an element. |
|
static int |
getInt(Element eParent,
String childName,
boolean mandatory,
int defaultValue)
Get the text of a child element as an integer. |
|
static int |
getIntAttribute(Element eNode,
String attName,
boolean mandatory,
int defaultValue)
Get the text of an attribute as an integer. |
|
static String |
getText(Element eNode)
Get the text contained by an element. |
|
static String |
getText(Element eParent,
String childName)
Get the text from an child under an element. |
|
static String |
getText(Element eParent,
String namespaceURI,
String childName)
Get the text from an child under an element. |
|
static String |
getText(Node eNode)
Get the text contained by an element. |
|
static String |
getXPath(Node node)
Gets the XPath for a node |
|
static boolean |
isNameEqual(Element e,
String name)
This method compares the name (either local name or tag name) of an element |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String getAttribute(Element eNode,
String attName,
boolean mandatory,
String defaultValue)
eNode - Parent elementattName - Attribute namemandatory - true if the value is requireddefaultValue - Default value to use when the value is not defined
public static String getAttribute(Element eNode,
String attName,
String defaultValue)
eNode - Parent elementattName - Attribute namedefaultValue - Default value to use when the value is not defined
public static boolean getBoolean(Element eParent,
String childName,
boolean mandatory,
boolean defaultValue)
eParent - Parent elementchildName - Child element namemandatory - true if the value is requireddefaultValue - Default value to use when the value is not defined (and not
mandatory).
public static boolean getBooleanAttribute(Element eNode,
String attName,
boolean mandatory,
boolean defaultValue)
eNode - Parent elementattName - Attribute namemandatory - true if the value is requireddefaultValue - Default value to use when the value is not defined (and not
mandatory).
public static <T> Class<T> getClassAttribute(Element eNode,
String attName,
Class<T> defaultClass)
T - Expected type of the classeNode - Element to get the attribute fromattName - Name of the attribute to getdefaultClass - Default class to return if the attribute is not defined
public static Element getElement(Element eParent,
String childName)
eParent - Parent elementchildName - Name of the child element to get (may be qualified)
null if not found.
public static Element getElement(Element eParent,
String namespaceURI,
String childName)
eParent - Parent elementnamespaceURI - Namespace URI for the child namechildName - Name of the child element to get (may be qualified)
null if not found.public static List<Element> getElements(Element eParent)
eParent - Parent element
null but can be empty)
public static List<Element> getElements(Element eParent,
String name)
eParent - Parent elementname - Name of the children to collect
null but can be empty)
public static List<Element> getElements(Element eParent,
String namespaceURI,
String name)
eParent - Parent elementnamespaceURI - Namespace URI for the child namename - Name of the children to collect
null but can be empty)public static Element getFirstChildElement(Element eParent)
eParent - Parent element
null if there is no child element.
public static int getInt(Element eParent,
String childName,
boolean mandatory,
int defaultValue)
eParent - Parent elementchildName - Child element namemandatory - true if the value is requireddefaultValue - Default value to use when the value is not defined (and not
mandatory).
public static int getIntAttribute(Element eNode,
String attName,
boolean mandatory,
int defaultValue)
eNode - Parent elementattName - Attribute namemandatory - true if the value is requireddefaultValue - Default value to use when the value is not defined (and not
mandatory).
public static String getText(Element eNode)
eNode - Element to get the text from.
null if no text has been found.
public static String getText(Element eParent,
String childName)
eParent - Parent elementchildName - Name of the child element (may be qualified)
null if the child
element does not exist or if it doesn't contain any text.
public static String getText(Element eParent,
String namespaceURI,
String childName)
eParent - Parent elementnamespaceURI - Namespace URI for the child namechildName - Name of the child element (not qualified)
null if the child
element does not exist or if it doesn't contain any text.public static String getText(Node eNode)
eNode - Element to get the text from.
null if no text has been found.public static String getXPath(Node node)
node - Node to get the XPath to.
public static boolean isNameEqual(Element e,
String name)
e - Elementname - Name compared to
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||