public class

XmlResourceHelper

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.android.XmlResourceHelper
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

This helper class facilitates access to the data contained in an XML resource. In particular, the readAttributeXxx methods allow easy retrieval of attribute values by tag names, throughout the entire document.

Summary

Fields
protected Document doc
protected Element rootElt
Public Constructors
XmlResourceHelper(IXmlUnit xml)
Create a manifest helper around the provided manifest unit.
XmlResourceHelper(Document doc)
Create a manifest helper around the provided low-level XML document object.
Public Methods
Element getRootElement()
This low-level method offers access to the org.w3c.dom.Element holding the root.
boolean hasAttributeValue(String tagName, String attrName, String wantedAttrValue)
String readAttribute(String tagName, String attrName)
Retrieve the attribute value of the first tag having the provided name.
List<String> readAttributes(String tagName, String attrName)
Retrieve the attribute values for all tags having the provided name.
List<List<String>> readMultiAttributes(String tagName, String... attrNames)
Retrieve several attribute values for all tags having the provided name.
Protected Methods
String buildAttributeName(String name)
List<Element> convertEltlist(NodeList nodelist)
List<Node> convertNodelist(NodeList nodelist)
String getAttr(Element elt, String name)
String getSimpleName(String name)
boolean isFullyQualifiedName(String name)
boolean isSimpleName(String name)
void prepare(Document doc)
The default implementation retrieves sets the doc and rootElt attributes.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected Document doc

protected Element rootElt

Public Constructors

public XmlResourceHelper (IXmlUnit xml)

Create a manifest helper around the provided manifest unit.

public XmlResourceHelper (Document doc)

Create a manifest helper around the provided low-level XML document object.

Public Methods

public Element getRootElement ()

This low-level method offers access to the org.w3c.dom.Element holding the root.

public boolean hasAttributeValue (String tagName, String attrName, String wantedAttrValue)

public String readAttribute (String tagName, String attrName)

Retrieve the attribute value of the first tag having the provided name.

Returns
  • the value (possibly empty if the attribute is not found in the tag), or null (if no element with the provided tag name was found in the document)

public List<String> readAttributes (String tagName, String attrName)

Retrieve the attribute values for all tags having the provided name.

Returns
  • a list of non-null strings

public List<List<String>> readMultiAttributes (String tagName, String... attrNames)

Retrieve several attribute values for all tags having the provided name.

Parameters
attrNames a collection of attributes to be retrieved

Protected Methods

protected String buildAttributeName (String name)

protected List<Element> convertEltlist (NodeList nodelist)

protected List<Node> convertNodelist (NodeList nodelist)

protected String getAttr (Element elt, String name)

protected String getSimpleName (String name)

protected boolean isFullyQualifiedName (String name)

protected boolean isSimpleName (String name)

protected void prepare (Document doc)

The default implementation retrieves sets the doc and rootElt attributes. Overrides must call this implementation first.