| java.lang.Object com.sun.jbi.framework.XmlUtil
XmlUtil | public class XmlUtil (Code) | | This class provides utility methods for accessing data from XML documents.
author: Sun Microsystems, Inc. |
Method Summary | |
static String | getAttribute(Node node, String attrName) Get a single attribute value from a node. | static Boolean | getBooleanValue(Node node, String tag, boolean isRequired) Get a boolean value from a named element in the specified node.
Parameters: node - - the node to be processed. Parameters: tag - - the element to be processed. Parameters: isRequired - - true if the element is required, false if not. | static Node | getElement(Node node, String tag, boolean isRequired) Get the named element from the specified node. | static NodeList | getElements(Node node, String tag, boolean isRequired) Get the named elements from the specified node. | static String | getStringValue(Node node) Get a String value from the specified node. | static String | getStringValue(Node node, String tag, boolean isRequired) Get a String value from a named element in the specified node.
Parameters: node - - the node to be processed. Parameters: tag - - the element to be processed. Parameters: isRequired - - true if the element is required, false if not. | static String | getStringValue(NodeList nodeList) Get a single String value from a node list. | static List<String> | getStringValueArray(Node node, String tag, boolean isRequired) Get a list of String values from a named element in the specified node.
Parameters: node - - the node to be processed. Parameters: tag - - the element to be processed. Parameters: isRequired - - true if the element is required, false if not. | static List<String> | getStringValueArray(Node node, String tag1, String tag2, boolean isRequired) Get a list of String values from a named element in the specified node.
Parameters: node - - the node to be processed. Parameters: tag1 - - the parent element to be processed. Parameters: tag2 - - the child element to be processed. Parameters: isRequired - - true if the element is required, false if not. | static List<String> | getStringValueArray(NodeList nodeList) Get a list of String values from a node list. |
getAttribute | static String getAttribute(Node node, String attrName)(Code) | | Get a single attribute value from a node. If the attribute is not present
an empty string value is returned.
Parameters: node - the Node to be processed. Parameters: attrName - the name of the attribute to be retrieved. A String representing the value of the attribute. If theattribute is not present, its value is set to an empty string. |
getBooleanValue | static Boolean getBooleanValue(Node node, String tag, boolean isRequired) throws com.sun.jbi.framework.XmlParseException(Code) | | Get a boolean value from a named element in the specified node.
Parameters: node - - the node to be processed. Parameters: tag - - the element to be processed. Parameters: isRequired - - true if the element is required, false if not. A boolean set based on the text value from the specified element:"true" returns true; "false" returns false. If the element is not presentand isRequired is false, returns a null. throws: com.sun.jbi.framework.XmlParseException - if the node list isnull or if any node is missing its text node. |
getElement | static Node getElement(Node node, String tag, boolean isRequired) throws com.sun.jbi.framework.XmlParseException(Code) | | Get the named element from the specified node. If isRequired is true,
there must be exactly one element of the specified type; if no element
is found, an exception is thrown. If isRequired is false, and there
is no element of the specified type, null is returned. In either case,
if multiple elements are found, an exception is thrown.
Parameters: node - - the node to be processed. Parameters: tag - - the type of the element to be returned. Parameters: isRequired - - true if the element is required, false if not. A Node representing the requested element, or null if no elementwas found and isRequired is false. throws: com.sun.jbi.framework.XmlParseException - if a required element isnot found or if a parse error occurs. |
getElements | static NodeList getElements(Node node, String tag, boolean isRequired) throws com.sun.jbi.framework.XmlParseException(Code) | | Get the named elements from the specified node. If isRequired is true,
there must be at least one element of the specified type; if no element
is found, an exception is thrown. If isRequired is false, and there
are no elements of the specified type, an empty NodeList is returned.
Parameters: node - - the node to be processed. Parameters: tag - - the type of the elements to be returned. Parameters: isRequired - - true if the element is required, false if not. A NodeList representing the requested elements, or null if theinput node is null. throws: com.sun.jbi.framework.XmlParseException - if a required element isnot found or if a parse error occurs. |
getStringValue | static String getStringValue(Node node, String tag, boolean isRequired) throws com.sun.jbi.framework.XmlParseException(Code) | | Get a String value from a named element in the specified node.
Parameters: node - - the node to be processed. Parameters: tag - - the element to be processed. Parameters: isRequired - - true if the element is required, false if not. A String containing the text value from the specified element,or null if the element is not present and isRequired is false. throws: com.sun.jbi.framework.XmlParseException - if the node list isnull or if any node is missing its text node. |
getStringValue | static String getStringValue(NodeList nodeList) throws com.sun.jbi.framework.XmlParseException(Code) | | Get a single String value from a node list. The node list is expected
to contain exactly one node, which in turn is expected to contain
exactly one text node. If the node list is null or has multiple elements,
an exception is thrown.
Parameters: nodeList - - the node list to be processed. The String value from the node. throws: com.sun.jbi.framework.XmlParseException - if the node list isnull or has multiple elements, or if the node is missing its textelement. |
getStringValueArray | static List<String> getStringValueArray(Node node, String tag, boolean isRequired) throws com.sun.jbi.framework.XmlParseException(Code) | | Get a list of String values from a named element in the specified node.
Parameters: node - - the node to be processed. Parameters: tag - - the element to be processed. Parameters: isRequired - - true if the element is required, false if not. A list of Strings containing the text values from the specifiedelements. The list is empty if no elements were found and isRequired isfalse. throws: com.sun.jbi.framework.XmlParseException - if the node list isnull or if any node is missing its text node, or if a required elementis not found. |
getStringValueArray | static List<String> getStringValueArray(Node node, String tag1, String tag2, boolean isRequired) throws com.sun.jbi.framework.XmlParseException(Code) | | Get a list of String values from a named element in the specified node.
Parameters: node - - the node to be processed. Parameters: tag1 - - the parent element to be processed. Parameters: tag2 - - the child element to be processed. Parameters: isRequired - - true if the element is required, false if not. A list of Strings containing the text values from the specifiedelements. The list is empty if no elements were found and isRequired isfalse. throws: com.sun.jbi.framework.XmlParseException - if the node list isnull or if any node is missing its text node, or if a required elementis not found. |
getStringValueArray | static List<String> getStringValueArray(NodeList nodeList) throws com.sun.jbi.framework.XmlParseException(Code) | | Get a list of String values from a node list. The node list can have
any number of nodes, each of which must have a single Text node. For
example, given the following XML fragment defined by a node list:
<sharedNamespaceId>shared-namespace-1</sharedNamespaceId>
<sharedNamespaceId>shared-namespace-2</sharedNamespaceId>
<sharedNamespaceId>shared-namespace-3</sharedNamespaceId>
The returned ArrayList for this node list would contain three String
instances with values "shared-namespace-1", "shared-namespace-2", and
"shared-namespace-3".
Parameters: nodeList - - the node list to be processed. An array list containing String values from the Text nodes, ornull if there were none. throws: java.lang.IllegalArgumentException - if the node list is null. throws: com.sun.jbi.framework.XmlParseException - if any node in thelist is missing a text node. |
|
|