Class ParsedTagSpec


  • public class ParsedTagSpec
    extends Object
    This class provides access to a TagSpec and a tag id which is unique within its context, the ParsedValidatorRules.
    Author:
    nhant01, GeorgeLuo
    • Constructor Detail

      • ParsedTagSpec

        public ParsedTagSpec​(@Nonnull
                             ParsedAttrSpecs parsedAttrSpecs,
                             @Nonnull
                             RecordValidated shouldRecordTagsValidated,
                             @Nonnull
                             dev.amp.validator.ValidatorProtos.TagSpec tagSpec,
                             int id)
        Constructor.
        Parameters:
        parsedAttrSpecs - the ParsedAttrSpecs instance.
        shouldRecordTagsValidated - a record validated value to determine if record tag should validate.
        tagSpec - the TagSpec.
        id - the id.
    • Method Detail

      • getSpec

        public dev.amp.validator.ValidatorProtos.TagSpec getSpec()
        Getting the TagSpec.
        Returns:
        returns the TagSpec.
      • cdataMatcher

        public CdataMatcher cdataMatcher​(@Nonnull
                                         Locator lineCol)
        If tag has a cdata spec, returns a CdataMatcher, else null.
        Parameters:
        lineCol - the pair of line/col.
        Returns:
        CdataMatcher returns CdataMatcher object.
      • isTypeJson

        public boolean isTypeJson()
        Returns true if this tagSpec contains an attribute of name "type" and value "application/json".
        Returns:
        returns true if this tagSpec contains an attribute of name "type" and value "application/json.".
      • getId

        public int getId()
        Return the parsed tag id.
        Returns:
        returns the parsed tag id.
      • isUsedForTypeIdentifiers

        public boolean isUsedForTypeIdentifiers​(@Nonnull
                                                List<String> typeIdentifiers)
        Returns true if this TagSpec should be used for the given type identifiers based on the TagSpec's disabled_by or enabled_by fields.
        Parameters:
        typeIdentifiers - the list of identifiers.
        Returns:
        returns true if this tagSpec should be used for the given type identifiers.
      • getAlsoRequiresTagWarning

        public List<String> getAlsoRequiresTagWarning()
        A TagSpec may specify other tags to be required as well, when that tag is used. This accessor returns the IDs for the tagspecs that are also required if |this| tag occurs in the document, but where such requirement is currently only a warning.
        Returns:
        returns a list of requires tag warning list.
      • requiresCondition

        public List<String> requiresCondition()
        A TagSpec may specify generic conditions which are required if the tag is present. This accessor returns the list of those conditions.
        Returns:
        returns requires list.
      • excludesCondition

        public List<String> excludesCondition()
        A TagSpec may specify that another tag is excluded. This accessor returns the list of those tags.
        Returns:
        returns excludes list.
      • containsUrl

        public boolean containsUrl()
        Returns true if this tagSpec contains a value_url field.
        Returns:
        returns true if this tagSpec contains a value_url field.
      • shouldRecordTagspecValidated

        public RecordValidated shouldRecordTagspecValidated()
        Whether or not the tag should be recorded via Context.recordTagspecValidated_ if it was validated successfully. For performance, this is only done for tags that are mandatory, unique, or possibly required by some other tag.
        Returns:
        returns a record validated enumeration whether or not the tag should be recorded.
      • isReferencePoint

        public boolean isReferencePoint()
        Returns a boolean whether the this tagSpec has reference point.
        Returns:
        returns a boolean whether the this tagSpec has reference point.
      • hasReferencePoints

        public boolean hasReferencePoints()
        Return true if reference points not empty. Else return false.
        Returns:
        Returns true if reference points not empty. Else return false.
      • getReferencePoints

        public ParsedReferencePoints getReferencePoints()
        Returns:
        returns ParsedReferencePoints object.
      • attrsCanSatisfyExtension

        public boolean attrsCanSatisfyExtension()
        Returns:
        returns if this tagSpec can satisfy extension.
      • hasAttrWithName

        public boolean hasAttrWithName​(@Nonnull
                                       String name)
        Returns if attrsByName contains the mapping keyed name.
        Parameters:
        name - attribute name.
        Returns:
        returns if attrsByName contains the mapping keyed name.
      • getImplicitAttrspecs

        public List<dev.amp.validator.ValidatorProtos.AttrSpec> getImplicitAttrspecs()
        Returns the implicit attr specs.
        Returns:
        returns the implicit attr specs.
      • getAttrsByName

        public Map<String,​dev.amp.validator.ValidatorProtos.AttrSpec> getAttrsByName()
        Returns the map of attrs by name.
        Returns:
        returns the map of attrs by name.
      • getMandatoryOneofs

        public Set<String> getMandatoryOneofs()
        Returns the set of mandatoryOneofs.
        Returns:
        returns the set of mandatoryOneofs.
      • getMandatoryAnyofs

        public Set<String> getMandatoryAnyofs()
        Returns the set of mandatoryAnyofs.
        Returns:
        returns the set of mandatoryAnyofs.
      • getMandatoryAttrIds

        public Set<dev.amp.validator.ValidatorProtos.AttrSpec> getMandatoryAttrIds()
        Returns the set of mandatoryAttrs.
        Returns:
        returns the set of mandatoryAttrs.
      • id

        public int id()
        Returns the parsed tag spec id.
        Returns:
        tag spec id.
      • cleanup

        public void cleanup()
        Clean up reference, improve gc performance.
      • getDispatchKeys

        public List<String> getDispatchKeys()
        Returns an array (typically empty) of all unique dispatch keys for this tagspec. A dispatch key is a combination of attribute name, attribute value, and / or tag parent. If multiple TagSpecs have the same dispatch key, then the Tagwith the first instance of that dispatch key is used. When an encounttag matches this dispatch key, it is validated first against that first TagSpec in order to improve validation performance and error message selection. Not all TagSpecs have a dispatch key. If the attribute value is used (either value or value_casei), uses the first value from the protoascii.
        Returns:
        dispatchKeys