Class XmlResourceHelper

java.lang.Object
com.pnfsoftware.jeb.core.units.code.android.XmlResourceHelper
Direct Known Subclasses:
ApkXmlResourceHelper

public class XmlResourceHelper extends Object
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.
  • Field Details

  • Constructor Details

    • XmlResourceHelper

      public XmlResourceHelper(IXmlUnit xml)
      Create a manifest helper around the provided manifest unit.
      Parameters:
      xml -
    • XmlResourceHelper

      public XmlResourceHelper(Document doc)
      Create a manifest helper around the provided low-level XML document object.
      Parameters:
      doc -
  • Method Details

    • prepare

      protected void prepare(Document doc)
      The default implementation retrieves sets the doc and rootElt attributes. Overrides must call this implementation first.
    • getRootElement

      public Element getRootElement()
      This low-level method offers access to the org.w3c.dom.Element holding the root.
      Returns:
    • buildAttributeName

      protected String buildAttributeName(String name)
    • convertNodelist

      protected List<Node> convertNodelist(NodeList nodelist)
    • convertEltlist

      protected List<Element> convertEltlist(NodeList nodelist)
    • readAttribute

      public String readAttribute(String tagName, String attrName)
      Retrieve the attribute value of the first tag having the provided name.
      Parameters:
      tagName -
      attrName -
      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)
    • readAttributes

      public List<String> readAttributes(String tagName, String attrName)
      Retrieve the attribute values for all tags having the provided name.
      Parameters:
      tagName -
      attrName -
      Returns:
      a list of non-null strings
    • hasAttributeValue

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

      public List<List<String>> readMultiAttributes(String tagName, String... attrNames)
      Retrieve several attribute values for all tags having the provided name.
      Parameters:
      tagName -
      attrNames - a collection of attributes to be retrieved
      Returns:
    • getAttr

      protected String getAttr(Element elt, String name)
    • isFullyQualifiedName

      protected boolean isFullyQualifiedName(String name)
    • isSimpleName

      protected boolean isSimpleName(String name)
    • getSimpleName

      protected String getSimpleName(String name)