Top Description Constructors Methods
org.hibernate.jpa.internal.util

public final Class XmlHelper

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Iterator, .Locale, org.w3c.dom.Element, .Node, .NodeList

A utility class to cover up the rough bits of xml parsing
Author
Chris Kimpton

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Iterator<E>

Returns:

An iterator of children or null if element is null.
getChildrenByTagName
(Element
The parent element
element
,
String
The name of the desired child
tagName
)

Returns an iterator over the children of the given element with the given tag name.

public static String

Returns:

The content of the element or null.
getElementContent
(final Element
The element to get the content for.
element
)

Get the content of the given element.

public static String

Returns:

The content of the element or the default.
getElementContent
(Element
The element to get the content for.
element
,
String
The default to return when there is no content.
defaultStr
)

Get the content of the given element.

public static Element

Returns:

either the named child or null
getOptionalChild
(Element
the parent element
element
,
String
the name of the desired child
tagName
)

Gets the child of the specified element having the specified name.

public static Element

Returns:

either the named child or the supplied default
getOptionalChild
(Element
the parent element
element
,
String
the name of the desired child
tagName
,
Element
the element to return if the child doesn't exist
defaultElement
)

Gets the child of the specified element having the specified name.

public static boolean
public static String

Returns:

The element content or null.
getOptionalChildContent
(Element
The parent element.
element
,
String
The name of the desired child.
tagName
)

Macro to get the content of an optional child element.

public static Element

Returns:

The named child.
getUniqueChild
(Element
The parent element
element
,
String
The name of the desired child
tagName
)

Gets the child of the specified element having the specified unique name.

public static String

Returns:

The element content or null.
getUniqueChildContent
(Element
The parent element.
element
,
String
The name of the desired child.
tagName
)

Macro to get the content of a unique child element.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

XmlHelperback to summary
private XmlHelper()

Method Detail

getChildrenByTagNameback to summary
public static Iterator<E> getChildrenByTagName(Element element, String tagName)

Returns an iterator over the children of the given element with the given tag name.

Parameters
element:Element

The parent element

tagName:String

The name of the desired child

Returns:Iterator<E>

An iterator of children or null if element is null.

getElementContentback to summary
public static String getElementContent(final Element element) throws Exception

Get the content of the given element.

Parameters
element:Element

The element to get the content for.

Returns:String

The content of the element or null.

getElementContentback to summary
public static String getElementContent(Element element, String defaultStr) throws Exception

Get the content of the given element.

Parameters
element:Element

The element to get the content for.

defaultStr:String

The default to return when there is no content.

Returns:String

The content of the element or the default.

getOptionalChildback to summary
public static Element getOptionalChild(Element element, String tagName) throws Exception

Gets the child of the specified element having the specified name. If the child with this name doesn't exist then null is returned instead.

Parameters
element:Element

the parent element

tagName:String

the name of the desired child

Returns:Element

either the named child or null

getOptionalChildback to summary
public static Element getOptionalChild(Element element, String tagName, Element defaultElement) throws Exception

Gets the child of the specified element having the specified name. If the child with this name doesn't exist then the supplied default element is returned instead.

Parameters
element:Element

the parent element

tagName:String

the name of the desired child

defaultElement:Element

the element to return if the child doesn't exist

Returns:Element

either the named child or the supplied default

getOptionalChildBooleanContentback to summary
public static boolean getOptionalChildBooleanContent(Element element, String name) throws Exception
getOptionalChildContentback to summary
public static String getOptionalChildContent(Element element, String tagName) throws Exception

Macro to get the content of an optional child element.

Parameters
element:Element

The parent element.

tagName:String

The name of the desired child.

Returns:String

The element content or null.

getUniqueChildback to summary
public static Element getUniqueChild(Element element, String tagName) throws Exception

Gets the child of the specified element having the specified unique name. If there are more than one children elements with the same name and exception is thrown.

Parameters
element:Element

The parent element

tagName:String

The name of the desired child

Returns:Element

The named child.

Exceptions
Exception:
Child was not found or was not unique.
getUniqueChildContentback to summary
public static String getUniqueChildContent(Element element, String tagName) throws Exception

Macro to get the content of a unique child element.

Parameters
element:Element

The parent element.

tagName:String

The name of the desired child.

Returns:String

The element content or null.