org.apache.lucene.xmlparser

Class DOMUtils

public class DOMUtils extends Object

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Method Summary
static StringgetAttribute(Element element, String attributeName, String deflt)
static floatgetAttribute(Element element, String attributeName, float deflt)
static intgetAttribute(Element element, String attributeName, int deflt)
static booleangetAttribute(Element element, String attributeName, boolean 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 defined
static 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

getAttribute

public static String getAttribute(Element element, String attributeName, String deflt)

getAttribute

public static float getAttribute(Element element, String attributeName, float deflt)

getAttribute

public static int getAttribute(Element element, String attributeName, int deflt)

getAttribute

public static boolean getAttribute(Element element, String attributeName, boolean deflt)

getAttributeOrFail

public static String getAttributeOrFail(Element e, String name)

getAttributeWithInheritance

public static String getAttributeWithInheritance(Element element, 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

getAttributeWithInheritanceOrFail

public static String getAttributeWithInheritanceOrFail(Element e, String name)

getChildByTagName

public static Element getChildByTagName(Element e, String name)

getChildByTagOrFail

public static Element getChildByTagOrFail(Element e, String name)

getChildTextByTagName

public static String getChildTextByTagName(Element e, String tagName)

getFirstChildElement

public static Element getFirstChildElement(Element element)

getFirstChildOrFail

public static Element getFirstChildOrFail(Element e)

getNonBlankTextOrFail

public static String getNonBlankTextOrFail(Element e)

getText

public static String getText(Node e)

insertChild

public static Element insertChild(Element parent, String tagName, String text)

loadXML

public static Document loadXML(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-2007 Apache Software Foundation. All Rights Reserved.