Here you can find the source of getNodeAttributeOrFail( Node node, String name, T e)
Parameter | Description |
---|---|
T | the exception type to throw |
node | The Node to fetch the value from. |
name | The attribute name. |
e | an Exception instance |
Parameter | Description |
---|---|
T | an exception |
public static <T extends Exception> String getNodeAttributeOrFail( Node node, String name, T e) throws T
//package com.java2s; //License from project: Open Source License import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { /** Retrieves the value for a xml Node attribute or fails if not found. * //from w ww . j a v a2s .c o m * @param <T> the exception type to throw * @param node The Node to fetch the value from. * @param name The attribute name. * @param e an Exception instance * @return the attribute value * @throws T */ public static <T extends Exception> String getNodeAttributeOrFail( Node node, String name, T e) throws T { NamedNodeMap attributes = node.getAttributes(); Node valueNode = attributes.getNamedItem(name); if (valueNode == null) throw e; return valueNode.getNodeValue(); } }