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.
      • putOneIfPresent

        protected void putOneIfPresent​(Map<String,​Object> attributesMap,
                                       String propertyKey,
                                       String attributeKey)
        Puts 1 if the key is found within element's attributes
        Parameters:
        attributesMap - map of BI properties to update BI context
        propertyKey - BI's property key to put in the given map BiFields
        attributeKey - the attribute key of the element
      • putStringIfPresent

        protected void putStringIfPresent​(Map<String,​Object> attributesMap,
                                          String propertyKey,
                                          String attributeKey)
        Gets the key's value from element's attributes and put it in the given map as a String
        Parameters:
        attributesMap - map of BI properties to update BI context
        propertyKey - BI's property key to put in the given map BiFields
        attributeKey - the attribute key of the element
      • putIntegerIfPresent

        protected void putIntegerIfPresent​(Map<String,​Object> attributesMap,
                                           String propertyKey,
                                           String attributeKey)
        Gets the key's value from element's attributes and put it in the given map as an Integer
        Parameters:
        attributesMap - map of BI properties to update BI context
        propertyKey - BI's property key to put in the given map BiFields
        attributeKey - the attribute key of the element
      • asText

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

        public Integer countChildrenOfType​(Class<? extends Element> type)
        This method applies a breadth-first traversal of a tree of elements counting the number of elements found which belong to the class type passed as input
      • 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)