Class Element

  • All Implemented Interfaces:
    Serializable

    @Immutable
    public class Element
    extends Object
    implements Serializable
    This class represents an element. It is built from the node name and node text contents.
    See Also:
    Serialized Form
    • Field Detail

      • node

        private final transient Node node
      • tag

        private final String tag
      • text

        private final String text
      • attributes

        private final com.google.common.collect.ImmutableMap<String,​String> attributes
    • Constructor Detail

      • Element

        public Element​(Node node)
        Create a new Element.
        Parameters:
        node - the node used to retrieve the name and the text content from. All Node keys are saved as lowercase.
      • Element

        public Element​(String tag,
                       String text,
                       com.google.common.collect.ImmutableMap<String,​String> attributes)
    • Method Detail

      • equalAttributes

        public boolean equalAttributes​(Element otherElement)
        Are all the attributes the same?
        Parameters:
        otherElement - the other element to compare
        Returns:
        true if the other attributes are equal to this one.
      • equalId

        public boolean equalId​(Element otherElement)
        Are both Id's the same?
        Parameters:
        otherElement - the other element to compare
        Returns:
        true if id == otherElement.id
      • equalText

        public boolean equalText​(Element otherElement)
        Are both the text equal?
        Parameters:
        otherElement - the other element to compare
        Returns:
        true if the text of both elements is the same
      • getElementId

        public String getElementId()
        Search for the attribute "id" and return the value.
        Returns:
        the id of this element or null when not found
      • getTag

        public String getTag()
        Returns:
        the tag
      • getText

        public String getText()
        Returns:
        the text
      • getAttributeOrNull

        public String getAttributeOrNull​(String attribute)
        Parameters:
        attribute - the attribute name.
        Returns:
        the attribute by its name or null if the attribute cannot be found.
      • getNode

        public Node getNode()
        Returns:
        The node.
      • getAttributes

        public com.google.common.collect.ImmutableMap<String,​String> getAttributes()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object