Class DOMUtils
- java.lang.Object
-
- org.apache.lucene.queryparser.xml.DOMUtils
-
public class DOMUtils extends Object
Helper methods for parsing XML
-
-
Constructor Summary
Constructors Constructor Description DOMUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleangetAttribute(Element element, String attributeName, boolean deflt)static floatgetAttribute(Element element, String attributeName, float deflt)static intgetAttribute(Element element, String attributeName, int deflt)static StringgetAttribute(Element element, String attributeName, String deflt)static StringgetAttributeOrFail(Element e, String name)static StringgetAttributeWithInheritance(Element element, String attributeName)Returns an attribute value from this node, or first parent node with this attribute definedstatic StringgetAttributeWithInheritanceOrFail(Element e, String name)static ElementgetChildByTagName(Element e, String name)static ElementgetChildByTagOrFail(Element e, String name)static StringgetChildTextByTagName(Element e, String tagName)static ElementgetFirstChildElement(Element element)static ElementgetFirstChildOrFail(Element e)static StringgetNonBlankTextOrFail(Element e)static StringgetText(Node e)static ElementinsertChild(Element parent, String tagName, String text)static DocumentloadXML(Reader is)Helper method to parse an XML file into a DOM tree, given a reader.
-
-
-
Method Detail
-
getChildByTagOrFail
public static Element getChildByTagOrFail(Element e, String name) throws ParserException
- Throws:
ParserException
-
getFirstChildOrFail
public static Element getFirstChildOrFail(Element e) throws ParserException
- Throws:
ParserException
-
getAttributeOrFail
public static String getAttributeOrFail(Element e, String name) throws ParserException
- Throws:
ParserException
-
getAttributeWithInheritanceOrFail
public static String getAttributeWithInheritanceOrFail(Element e, String name) throws ParserException
- Throws:
ParserException
-
getNonBlankTextOrFail
public static String getNonBlankTextOrFail(Element e) throws ParserException
- Throws:
ParserException
-
getAttributeWithInheritance
public static String getAttributeWithInheritance(Element element, String attributeName)
Returns an attribute value from this node, or first parent node with this attribute defined- Returns:
- A non-zero-length value if defined, otherwise null
-
getAttribute
public static String getAttribute(Element element, String attributeName, String deflt)
-
getAttribute
public static boolean getAttribute(Element element, String attributeName, boolean deflt)
-
-