Package dev.amp.validator
Class ParsedHtmlTag
- java.lang.Object
-
- dev.amp.validator.ParsedHtmlTag
-
public class ParsedHtmlTag extends Object
The AMP HTML ParsedHtmlTag class.- Author:
- nhant01, GeorgeLuo
-
-
Constructor Summary
Constructors Constructor Description ParsedHtmlTag(String tagName, Attributes attributes)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Attributesattrs()Returns an array of attributes.HashMap<String,String>attrsByKey()Returns an object mapping attribute name to attribute value.voidcleanup()Method to nullify object values.StringgetValue(String attrName, int index)Need to replace the value with an empty string if attr name is equal to the value.StringhasDuplicateAttrs()Returns a duplicate attribute name if the tag contains two attributes named the same, but with different attribute values.booleanisAmpRuntimeScript()Tests if this is the AMP runtime script tag.booleanisEmpty()Returns true if tag name length is zero.booleanisExtensionScript()Tests if this is an extension script tag.booleanisLtsScriptTag()Tests if this is the LTS version script tag.booleanisModuleLtsScriptTag()Tests if this is the module LTS version script tag.booleanisModuleScriptTag()Tests if this is the module version script tag.booleanisNomoduleLtsScriptTag()Tests if this is the nomodule LTS version script tag.booleanisNomoduleScriptTag()Tests if this is the nomodule version script tag.StringlowerName()Lower-case tag name.StringupperName()Upper-case tag name.
-
-
-
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.
-
isExtensionScript
public boolean isExtensionScript()
Tests if this is an extension script tag.- Returns:
- if is extension script
-
isAmpRuntimeScript
public boolean isAmpRuntimeScript()
Tests if this is the AMP runtime script tag.- Returns:
- true iff is AMP runtime script tag
-
isModuleLtsScriptTag
public boolean isModuleLtsScriptTag()
Tests if this is the module LTS version script tag.- Returns:
- true iff this is module LTS version script tag
-
isNomoduleLtsScriptTag
public boolean isNomoduleLtsScriptTag()
Tests if this is the nomodule LTS version script tag.- Returns:
- true iff this is nomodule LTS version script tag
-
isModuleScriptTag
public boolean isModuleScriptTag()
Tests if this is the module version script tag.- Returns:
- true iff module version script tag
-
isNomoduleScriptTag
public boolean isNomoduleScriptTag()
Tests if this is the nomodule version script tag.- Returns:
- true iff nomodule version script tag
-
isLtsScriptTag
public boolean isLtsScriptTag()
Tests if this is the LTS version script tag.- Returns:
- true iff lts script tag
-
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.
-
-