Package de.undercouch.citeproc.helper
Class NodeHelper
- java.lang.Object
-
- de.undercouch.citeproc.helper.NodeHelper
-
-
Constructor Summary
Constructors Constructor Description NodeHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NodefindDirectChild(Node node, String name)Iterate through the direct children of the given parent node and find the child with the given namestatic StringgetAttrValue(Node node, String attrName)Gets an attribute value from a nodestatic booleangetAttrValueBool(Node node, String attrName, boolean defaultValue)Gets an attribute value from a node and parses it to a booleanstatic IntegergetAttrValueInt(Node node, String attrName, Integer defaultValue)Gets an attribute value from a node and parses it to an integer
-
-
-
Method Detail
-
getAttrValue
public static String getAttrValue(Node node, String attrName)
Gets an attribute value from a node- Parameters:
node- the nodeattrName- the name of the attribute- Returns:
- the attribute or
nullif the attribute does not exist
-
getAttrValueInt
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- the nodeattrName- the name of the attributedefaultValue- an optional default value to return if the attribute does not exist- Returns:
- the attribute's value or the default value
- Throws:
NumberFormatException
-
getAttrValueBool
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- the nodeattrName- the name of the attributedefaultValue- an optional default value to return if the attribute does not exist- Returns:
- the attribute's value or the default value
-
findDirectChild
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- the parent nodename- the child's name- Returns:
- the child or
nullif there is no child with the given name
-
-