org.apache.lucene.xmlparser
Class DOMUtils

java.lang.Object
  extended by org.apache.lucene.xmlparser.DOMUtils

public class DOMUtils
extends java.lang.Object


Constructor Summary
DOMUtils()
           
 
Method Summary
static boolean getAttribute(org.w3c.dom.Element element, java.lang.String attributeName, boolean deflt)
           
static float getAttribute(org.w3c.dom.Element element, java.lang.String attributeName, float deflt)
           
static int getAttribute(org.w3c.dom.Element element, java.lang.String attributeName, int deflt)
           
static java.lang.String getAttribute(org.w3c.dom.Element element, java.lang.String attributeName, java.lang.String deflt)
           
static java.lang.String getAttributeOrFail(org.w3c.dom.Element e, java.lang.String name)
           
static java.lang.String getAttributeWithInheritance(org.w3c.dom.Element element, java.lang.String attributeName)
          Returns an attribute value from this node, or first parent node with this attribute defined
static java.lang.String getAttributeWithInheritanceOrFail(org.w3c.dom.Element e, java.lang.String name)
           
static org.w3c.dom.Element getChildByTagName(org.w3c.dom.Element e, java.lang.String name)
           
static org.w3c.dom.Element getChildByTagOrFail(org.w3c.dom.Element e, java.lang.String name)
           
static java.lang.String getChildTextByTagName(org.w3c.dom.Element e, java.lang.String tagName)
           
static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Element element)
           
static org.w3c.dom.Element getFirstChildOrFail(org.w3c.dom.Element e)
           
static java.lang.String getNonBlankTextOrFail(org.w3c.dom.Element e)
           
static java.lang.String getText(org.w3c.dom.Node e)
           
static org.w3c.dom.Element insertChild(org.w3c.dom.Element parent, java.lang.String tagName, java.lang.String text)
           
static org.w3c.dom.Document loadXML(java.io.Reader is)
          Helper method to parse an XML file into a DOM tree, given a reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMUtils

public DOMUtils()
Method Detail

getChildByTagOrFail

public static org.w3c.dom.Element getChildByTagOrFail(org.w3c.dom.Element e,
                                                      java.lang.String name)
                                               throws ParserException
Throws:
ParserException

getFirstChildOrFail

public static org.w3c.dom.Element getFirstChildOrFail(org.w3c.dom.Element e)
                                               throws ParserException
Throws:
ParserException

getAttributeOrFail

public static java.lang.String getAttributeOrFail(org.w3c.dom.Element e,
                                                  java.lang.String name)
                                           throws ParserException
Throws:
ParserException

getAttributeWithInheritanceOrFail

public static java.lang.String getAttributeWithInheritanceOrFail(org.w3c.dom.Element e,
                                                                 java.lang.String name)
                                                          throws ParserException
Throws:
ParserException

getNonBlankTextOrFail

public static java.lang.String getNonBlankTextOrFail(org.w3c.dom.Element e)
                                              throws ParserException
Throws:
ParserException

getChildByTagName

public static org.w3c.dom.Element getChildByTagName(org.w3c.dom.Element e,
                                                    java.lang.String name)

getAttributeWithInheritance

public static java.lang.String getAttributeWithInheritance(org.w3c.dom.Element element,
                                                           java.lang.String attributeName)
Returns an attribute value from this node, or first parent node with this attribute defined

Parameters:
element -
attributeName -
Returns:
A non-zero-length value if defined, otherwise null

getChildTextByTagName

public static java.lang.String getChildTextByTagName(org.w3c.dom.Element e,
                                                     java.lang.String tagName)

insertChild

public static org.w3c.dom.Element insertChild(org.w3c.dom.Element parent,
                                              java.lang.String tagName,
                                              java.lang.String text)

getAttribute

public static java.lang.String getAttribute(org.w3c.dom.Element element,
                                            java.lang.String attributeName,
                                            java.lang.String deflt)

getAttribute

public static float getAttribute(org.w3c.dom.Element element,
                                 java.lang.String attributeName,
                                 float deflt)

getAttribute

public static int getAttribute(org.w3c.dom.Element element,
                               java.lang.String attributeName,
                               int deflt)

getAttribute

public static boolean getAttribute(org.w3c.dom.Element element,
                                   java.lang.String attributeName,
                                   boolean deflt)

getText

public static java.lang.String getText(org.w3c.dom.Node e)

getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Element element)

loadXML

public static org.w3c.dom.Document loadXML(java.io.Reader is)
Helper method to parse an XML file into a DOM tree, given a reader.

Parameters:
is - reader of the XML file to be parsed
Returns:
an org.w3c.dom.Document object


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.