Class ElementNode

java.lang.Object
com.nomagic.magicreport.engine.xml.ElementNode
All Implemented Interfaces:
Node, Serializable

@OpenApiAll public class ElementNode extends Object implements Node, Serializable
The Element represents an element in XML document.
Since:
Jun 1, 2009
See Also:
  • Constructor Details

    • ElementNode

      public ElementNode(String name)
      Create an element with out associated attribute.
      Parameters:
      name - an element name.
    • ElementNode

      public ElementNode(String name, Attributes attributes)
      Create an element with associated attributes.
      Parameters:
      name - an element name
      attributes - attributes
  • Method Details

    • getContent

      public StringBuilder getContent()
      Return a content.
      Returns:
      the content
    • hasTextContent

      public boolean hasTextContent(Collection<Node> childNodes)
      Return true when childNodes contains at least one text node.
      Parameters:
      childNodes - collection of child node
      Returns:
      true when childNodes contains at least one text node; otherwise false.
    • appendContent

      public void appendContent(char[] str, int offset, int len)
      Append a content.
      Parameters:
      str - the characters to be appended.
      offset - the index of the first char to append.
      len - the number of chars to append.
    • getName

      public String getName()
      Return a name.
      Returns:
      the name
    • getStartText

      public String getStartText()
      Return a start text.
      Returns:
      the startText
    • getEndText

      public String getEndText()
      Return an end text.
      Returns:
      the endText
    • setAttribute

      public void setAttribute(String uri, String localName, String qName, String type, String value)
      Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter.
      Parameters:
      uri - The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.
      localName - The local name, or the empty string if Namespace processing is not being performed.
      qName - The qualified (prefixed) name, or the empty string if qualified names are not available.
      type - The attribute type as a string.
      value - The attribute value.
      Throws:
      DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
    • getAttribute

      public String getAttribute(String qName)
      Retrieves an attribute value by name.
      Parameters:
      qName - The name of the attribute to retrieve.
      Returns:
      The attribute value as a string, or the empty string.
    • getAttributes

      public Attributes getAttributes()
      Retrieves XML attributes.
      Returns:
      The XML attributes.
    • setAttribute

      public void setAttribute(String attrName, String attrValue) throws DOMException
      Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter.
      Parameters:
      attrName - The name of the attribute to create or alter.
      attrValue - Value to set in string form.
      Throws:
      DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
    • toString

      public String toString()
      Return string represents this object.
      Overrides:
      toString in class Object
      Returns:
      a string represents this object
    • appendChild

      public void appendChild(Node e)
      Adds the node newChild to the end of the list of children of this node.
      Specified by:
      appendChild in interface Node
      Parameters:
      e - a child element
    • removeChild

      public Node removeChild(Node oldChild)
      Removes the child node indicated by oldChild from the list of children, and returns it.
      Specified by:
      removeChild in interface Node
      Parameters:
      oldChild - The node being removed.
      Returns:
      the node removed.
    • insertBefore

      public void insertBefore(Node newChild, int index)
      Inserts the node newChild before the child index.
      Specified by:
      insertBefore in interface Node
      Parameters:
      newChild - the node to insert
      index - the reference child index
    • getChildNodes

      public Collection<Node> getChildNodes()
      Return a child.
      Specified by:
      getChildNodes in interface Node
      Returns:
      the child
    • getLastChild

      public Node getLastChild()
      The last child of this node. If there is no such node, this returns null.
      Returns:
      last child of this node.
    • getFirstChild

      public Node getFirstChild()
      The first child of this node. If there is no such node, this returns null.
      Returns:
      first child of this node.
    • getParentNode

      public Node getParentNode()
      Return the parent of this node.
      Specified by:
      getParentNode in interface Node
      Returns:
      the parent
    • setParentNode

      public void setParentNode(Node e)
      Set a parent of this node.
      Specified by:
      setParentNode in interface Node
      Parameters:
      e - a node.
    • getCustomProperty

      public Map<String,Object> getCustomProperty()
    • setCustomProperty

      public void setCustomProperty(Map<String,Object> customProperty)
    • getACustomProperty

      public Object getACustomProperty(String key)
    • setACustomProperty

      public void setACustomProperty(String key, Object obj)