Top Description Constructors Methods
de.undercouch.citeproc.helper

public Class NodeHelper

extends Object
Class Inheritance
Imports
org.w3c.dom.NamedNodeMap, .Node, .NodeList

Helper methods related to XML Nodes
Author
Michel Kraemer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Node

Returns:

the child or null if there is no child with the given name
findDirectChild
(Node
the parent node
node
,
String
the child's name
name
)

Iterate through the direct children of the given parent node and find the child with the given name

public static String

Returns:

the attribute or null if the attribute does not exist
getAttrValue
(Node
the node
node
,
String
the name of the attribute
attrName
)

Gets an attribute value from a node

public static boolean

Returns:

the attribute's value or the default value
getAttrValueBool
(Node
the node
node
,
String
the name of the attribute
attrName
,
boolean
an optional default value to return if the attribute does not exist
defaultValue
)

Gets an attribute value from a node and parses it to a boolean

public static Integer

Returns:

the attribute's value or the default value
getAttrValueInt
(Node
the node
node
,
String
the name of the attribute
attrName
,
Integer
an optional default value to return if the attribute does not exist
defaultValue
)

Gets an attribute value from a node and parses it to an integer

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NodeHelperback to summary
public NodeHelper()

Method Detail

findDirectChildback to summary
public static Node findDirectChild(Node node, String name)

Iterate through the direct children of the given parent node and find the child with the given name

Parameters
node:Node

the parent node

name:String

the child's name

Returns:Node

the child or null if there is no child with the given name

getAttrValueback to summary
public static String getAttrValue(Node node, String attrName)

Gets an attribute value from a node

Parameters
node:Node

the node

attrName:String

the name of the attribute

Returns:String

the attribute or null if the attribute does not exist

getAttrValueBoolback to summary
public static boolean getAttrValueBool(Node node, String attrName, boolean defaultValue)

Gets an attribute value from a node and parses it to a boolean

Parameters
node:Node

the node

attrName:String

the name of the attribute

defaultValue:boolean

an optional default value to return if the attribute does not exist

Returns:boolean

the attribute's value or the default value

getAttrValueIntback to summary
public static Integer getAttrValueInt(Node node, String attrName, Integer defaultValue) throws NumberFormatException

Gets an attribute value from a node and parses it to an integer

Parameters
node:Node

the node

attrName:String

the name of the attribute

defaultValue:Integer

an optional default value to return if the attribute does not exist

Returns:Integer

the attribute's value or the default value