Class AXmlNode

java.lang.Object
soot.jimple.infoflow.android.axml.AXmlElement
soot.jimple.infoflow.android.axml.AXmlNode

public class AXmlNode extends AXmlElement
Represents a node of an Android XML document.
Author:
Stefan Haas, Mario Schlipf
  • Field Details

    • tag

      protected String tag
      The node's tag.
    • text

      protected String text
      The textual contents of the node
    • parent

      protected AXmlNode parent
      The parent node.
  • Constructor Details

    • AXmlNode

      public AXmlNode(String tag, String ns, AXmlNode parent)
      Creates a new AXmlNode object with the given tag, namespace and parent.
      Keep in mind that this node will automatically be added as child to the given parent node with parent.addChild(this). If you want to create a root node you can set parent to null.
      The addded flag is defaulted to true (see AXmlElement.added).
      Parameters:
      tag - the node's tag.
      ns - the node's namespace.
      parent - the node's parent node.
    • AXmlNode

      public AXmlNode(String tag, String ns, AXmlNode parent, String text)
      Creates a new AXmlNode object with the given tag, namespace and parent.
      Keep in mind that this node will automatically be added as child to the given parent node with parent.addChild(this). If you want to create a root node you can set parent to null.
      The addded flag is defaulted to true (see AXmlElement.added).
      Parameters:
      tag - the node's tag.
      ns - the node's namespace.
      parent - the node's parent node.
      text - The textual contents of the node
    • AXmlNode

      public AXmlNode(String tag, String ns, AXmlNode parent, boolean added, String text)
      Creates a new AXmlNode object with the given tag, namespace and parent. Keep in mind that this node will automatically be added as child to the given parent node with parent.addChild(this).
      Parameters:
      tag - the node's tag.
      ns - the node's namespace.
      parent - the node's parent node.
      added - wheter this node was part of a parsed xml file or added afterwards.
      text - The textual contents of the node
  • Method Details

    • getTag

      public String getTag()
      Returns the tag of this node.
      Returns:
      the node's tag
    • addSiblingBefore

      public boolean addSiblingBefore(AXmlNode sibling)
      Adds the given node as sibling before this node and returns true.
      If this node has no parent the sibling cannot be added and false will be returned instead.
      Parameters:
      sibling -
      Returns:
      false if this node has no parent, otherwise true
    • addSiblingAfter

      public boolean addSiblingAfter(AXmlNode sibling)
      Adds the given node as sibling after this node and returns true.
      If this node has no parent the sibling cannot be added and false will be returned instead.
      Parameters:
      sibling -
      Returns:
      false if this node has no parent, otherwise true
    • addChild

      public AXmlNode addChild(AXmlNode child)
      Adds the given node as child.
      Parameters:
      child - a new child for this node
      Returns:
      this node itself for method chaining
    • addChild

      public AXmlNode addChild(AXmlNode child, int index)
      Adds the given node as child at position index.
      Parameters:
      child - a new child for this node
      Returns:
      this node itself for method chaining
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index < 0 || index > children.size())
    • getChildren

      public List<AXmlNode> getChildren()
      List containing all children of this node.
      Returns:
      list with all children
    • getChildrenWithTag

      public List<AXmlNode> getChildrenWithTag(String tag)
      List containing all children of this node which have the given tag.
      Parameters:
      tag - the children's tag
      Returns:
      list with all children with tag
    • removeAttribute

      public AXmlAttribute<?> removeAttribute(String key)
      Removes an element from the attributes.
      Parameters:
      key - the key
      Returns:
      the previously associated value or null
    • getAttributes

      public Map<String,AXmlAttribute<?>> getAttributes()
      Returns a map which contains all attributes. The keys match the attributes' names.
      Returns:
      map with all attributes belonging to this node
    • hasAttribute

      public boolean hasAttribute(String name)
      Returns whether this node has an attribute with the given name.
      Parameters:
      name - the attribute's name
      Returns:
      if this node has an attribute with name
    • getAttribute

      public AXmlAttribute<?> getAttribute(String name)
      Returns the attribute with the given name.
      Parameters:
      name - the attribute's name.
      Returns:
      attribute with name.
    • addAttribute

      public void addAttribute(AXmlAttribute<?> attr)
      Adds the given attribute to this node. Attributes have unique names. An attribute with the same name will be overwritten.
      Parameters:
      attr - the attribute to be added.
    • addAttribute

      public void addAttribute(String key, String ns, String value)
      Adds the given attribute to this node. Attributes have unique names. An attribute with the same name will be overwritten.
      Parameters:
      key - The name of the new attribute
      ns - The namespace of the new attribute
      value - The value of the new attribute
    • getParent

      public AXmlNode getParent()
      Returns the parent node.
      If this node is part of a valid XML document, consider that only the root node's parent can be and has to be null.
      Returns:
      parent node
    • setParent

      public void setParent(AXmlNode parent)
      Sets the parent of this node.
      Parameters:
      parent - this node's new parent
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • removeChild

      public void removeChild(AXmlNode child)
      Remove child 'child' of this node
      Parameters:
      child -
    • getText

      public String getText()
      Gets the textual contents of this node
      Returns:
      The textual contents of this node
    • setText

      public void setText(String text)
      Sets the textual contents of this node
      Parameters:
      text - The textual contents of this node