Class AMPValidatorManager


  • public class AMPValidatorManager
    extends Object
    This class manages the rules.
    Author:
    nhant01, GeorgeLuo
    • Constructor Detail

      • AMPValidatorManager

        public AMPValidatorManager()
        Constructor of AMP validator manager class.
    • Method Detail

      • loadRule

        public void loadRule​(String filePath)
                      throws IOException,
                             URISyntaxException
        Loading AMP validator main and extensions rules.
        Parameters:
        filePath - file path.
        Throws:
        IOException - if I/O errors occur.
        URISyntaxException - if this URL is not formatted strictly according to to RFC2396 and cannot be converted to a URI.
      • hasTagSpec

        public boolean hasTagSpec​(@Nonnull
                                  dev.amp.validator.ValidatorProtos.HtmlFormat.Code htmlFormat,
                                  @Nonnull
                                  String name)
        Return true if tag spec name exists.
        Parameters:
        htmlFormat - the HtmlFormat.
        name - tag spec name.
        Returns:
        returns true if tag spec name exists.
      • getTagSpec

        public List<dev.amp.validator.ValidatorProtos.TagSpec> getTagSpec​(@Nonnull
                                                                          dev.amp.validator.ValidatorProtos.HtmlFormat.Code htmlFormat,
                                                                          @Nonnull
                                                                          String name)
        Return a list of TagSpec given a tag name.
        Parameters:
        htmlFormat - the HtmlFormat.
        name - tag spec name.
        Returns:
        returns a list of TagSpect given a tag name.
      • getAttrList

        public dev.amp.validator.ValidatorProtos.AttrList getAttrList​(@Nonnull
                                                                      String name)
        Return a list of AttrList given an attribute list name.
        Parameters:
        name - attribute list name.
        Returns:
        returns a list of AttrList given an attribute spec name.
      • getListTagSpecByName

        public List<dev.amp.validator.ValidatorProtos.TagSpec> getListTagSpecByName​(@Nonnull
                                                                                    dev.amp.validator.ValidatorProtos.HtmlFormat.Code htmlFormat,
                                                                                    @Nonnull
                                                                                    String tagName)
        Return a list of TagSpec given a tag name.
        Parameters:
        htmlFormat - the HtmlFormat.
        tagName - a tag name.
        Returns:
        returns a list of TagSpec given a tag name.
      • getRules

        public dev.amp.validator.ValidatorProtos.ValidatorRules.Builder getRules()
        Returns the validation rules.
        Returns:
        returns the validation rules.
      • getGlobalAttrs

        public List<dev.amp.validator.ValidatorProtos.AttrSpec> getGlobalAttrs()
        Returns the $GLOBAL_ATTRS attr spec list.
        Returns:
        returns the $GLOBAL_ATTRS attr spec list.
      • getAmpLayoutAttrs

        public List<dev.amp.validator.ValidatorProtos.AttrSpec> getAmpLayoutAttrs()
        Returns the $AMP_LAYOUT_ATTRS attr spec list.
        Returns:
        returns the $AMP_LAYOUT_ATTRS attr spec list.
      • getDescendantTagLists

        public List<dev.amp.validator.ValidatorProtos.DescendantTagList> getDescendantTagLists()
        Returns the descendant tag lists.
        Returns:
        returns the descendant tag lists.
      • getDispatchKeyByTagSpecId

        public String getDispatchKeyByTagSpecId​(int tagSpecId)
        Returns dispatch key given tag spec id.
        Parameters:
        tagSpecId - tag spec id.
        Returns:
        returns dispatch key.
      • getTagSpecIdByReferencePointTagSpecName

        public int getTagSpecIdByReferencePointTagSpecName​(@Nonnull
                                                           String specName)
                                                    throws TagValidationException
        Returns the specId for given the tag spec name of the reference point.
        Parameters:
        specName - the spec name.
        Returns:
        returns specId.
        Throws:
        TagValidationException - the TagValidationException.
      • getStylesSpecUrl

        public String getStylesSpecUrl()
        Returns the styles spec url.
        Returns:
        returns the styles spec url.
      • getScriptSpecUrl

        public String getScriptSpecUrl()
        Returns the script spec url.
        Returns:
        returns the script spec url.
      • getAttrListMap

        public Map<String,​dev.amp.validator.ValidatorProtos.AttrList> getAttrListMap()
        Returns the attr list map.
        Returns:
        returns the attr list map.
      • getCombinedDisallowedCdataRegex

        public String getCombinedDisallowedCdataRegex​(int tagSpecId)
        Returns a combined disallowed listed regex.
        Parameters:
        tagSpecId - tag spec id.
        Returns:
        returns a combined disallowed listed regex.