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 boolean
getAttribute(Element element, String attributeName, boolean deflt)
static float
getAttribute(Element element, String attributeName, float deflt)
static int
getAttribute(Element element, String attributeName, int deflt)
static String
getAttribute(Element element, String attributeName, String deflt)
static String
getAttributeOrFail(Element e, String name)
static String
getAttributeWithInheritance(Element element, String attributeName)
Returns an attribute value from this node, or first parent node with this attribute definedstatic String
getAttributeWithInheritanceOrFail(Element e, String name)
static Element
getChildByTagName(Element e, String name)
static Element
getChildByTagOrFail(Element e, String name)
static String
getChildTextByTagName(Element e, String tagName)
static Element
getFirstChildElement(Element element)
static Element
getFirstChildOrFail(Element e)
static String
getNonBlankTextOrFail(Element e)
static String
getText(Node e)
static Element
insertChild(Element parent, String tagName, String text)
static Document
loadXML(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)
-
-