Class Element

    • Method Detail

      • hasIdAttribute

        public Boolean hasIdAttribute()
        Informs if the element has an "id" attribute. The parser that builds all elements keeps track of all ids from the elements that have it, in order to ensure unique values.
        Returns:
      • asText

        public String asText()
        Return a text representation of the element, descending into its children.
      • getStringAttribute

        public String getStringAttribute​(Node attribute)
        Get a DOM attribute as a String value.
      • hasExactNumberOfChildren

        public boolean hasExactNumberOfChildren​(int childrenNumber)
      • getMessageMLTag

        public final String getMessageMLTag()
        Return the element's MessageML tag.
      • getPresentationMLTag

        public String getPresentationMLTag()
        Return the element's PresentationML tag. By default is equals to MessageML tag, override when needed
      • areNestedElementsAllowed

        public boolean areNestedElementsAllowed()
        Return true if nested elements are allowed By default true, override to false for elements that dont support nested elements
      • getAttributes

        public Map<String,​String> getAttributes()
        Return a map of the element's attributes.
      • getAttribute

        public String getAttribute​(String attr)
        Return the value of the element's attribute "attr".
      • getChildren

        public List<Element> getChildren()
        Return a list of the element's children.
      • getChild

        public Element getChild​(int n)
        Return the nth child of the element.
      • addChild

        public void addChild​(Element child)
        Append a child to the element.
      • size

        public int size()
        Return the number of children of the element.
      • getParent

        public Element getParent()
        Return the parent of the element.
      • getFormat

        public FormatEnum getFormat()
        Return the format (MessageML or PresentationML) of the element.
      • findElements

        public List<Element> findElements​(Class<?> type)
        Search the MessageML tree (depth-first) for elements of a given type.
        Parameters:
        type - the class of elements to find
        Returns:
        found elements
      • findElements

        public List<Element> findElements​(String tag)
        Search the MessageML tree (depth-first) for elements with a given MessageML tag.
        Parameters:
        tag - the MessageML tag of elements to find
        Returns:
        found elements
      • findElements

        public List<Element> findElements​(String attribute,
                                          String value)
        Search the MessageML tree (depth-first) for elements with a given attribute-value pair.
        Parameters:
        attribute - the attribute name match
        value - the attribute value to match
        Returns:
        found elements
      • countNonTextNodesInNodeList

        public Integer countNonTextNodesInNodeList​(NodeList nodeList)