Class ParsedHtmlTag


  • public class ParsedHtmlTag
    extends Object
    The AMP HTML ParsedHtmlTag class.
    Author:
    nhant01, GeorgeLuo
    • Constructor Detail

      • ParsedHtmlTag

        public ParsedHtmlTag​(@Nonnull
                             String tagName,
                             @Nonnull
                             Attributes attributes)
        Constructor.
        Parameters:
        tagName - the name of the underlying tag in html document.
        attributes - the attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
    • Method Detail

      • lowerName

        public String lowerName()
        Lower-case tag name.
        Returns:
        returns a lower case tag name.
      • attrs

        public Attributes attrs()
        Returns an array of attributes. Each attribute has two fields: name and value. Name is always lower-case, value is the case from the original document. Values are unescaped.
        Returns:
        returns the attributes.
      • attrsByKey

        public HashMap<String,​String> attrsByKey()
        Returns an object mapping attribute name to attribute value. This is populated lazily, as it's not used for most tags.
        Returns:
        a HashMap of attribute name to attribute value
      • hasDuplicateAttrs

        public String hasDuplicateAttrs()
        Returns a duplicate attribute name if the tag contains two attributes named the same, but with different attribute values. Same attribute name AND value is OK. Returns null if there are no such duplicate attributes.
        Returns:
        returns a duplicate attribute name if the tag contains two attributes named the same.
      • getValue

        public String getValue​(@Nonnull
                               String attrName,
                               int index)
        Need to replace the value with an empty string if attr name is equal to the value.
        Parameters:
        attrName - attr name.
        index - index to the Attributes.
        Returns:
        returns the value.
      • cleanup

        public void cleanup()
        Method to nullify object values.
      • upperName

        public String upperName()
        Upper-case tag name.
        Returns:
        returns a upper case tag name.
      • isEmpty

        public boolean isEmpty()
        Returns true if tag name length is zero.
        Returns:
        returns true if tag name length is zero.