Package dev.amp.validator
Class ParsedTagSpec
- java.lang.Object
-
- dev.amp.validator.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 Summary
Constructors Constructor Description ParsedTagSpec(ParsedAttrSpecs parsedAttrSpecs, RecordValidated shouldRecordTagsValidated, dev.amp.validator.ValidatorProtos.TagSpec tagSpec, int id)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanattrsCanSatisfyExtension()CdataMatchercdataMatcher(Locator lineCol)If tag has a cdata spec, returns a CdataMatcher, else null.ChildTagMatcherchildTagMatcher()If tag has a child_tag spec, returns a ChildTagMatcher, else null.voidcleanup()Clean up reference, improve gc performance.booleancontainsUrl()Returns true if this tagSpec contains a value_url field.List<String>excludes()A TagSpec may specify that another tag is excluded.List<String>getAlsoRequiresTagWarning()A TagSpec may specify other tags to be required as well, when that tag is used.Map<String,dev.amp.validator.ValidatorProtos.AttrSpec>getAttrsByName()Returns the map of attrs by name.intgetId()Return the parsed tag id.List<dev.amp.validator.ValidatorProtos.AttrSpec>getImplicitAttrspecs()Returns the implicit attr specs.Set<String>getMandatoryAnyofs()Returns the set of mandatoryAnyofs.Set<dev.amp.validator.ValidatorProtos.AttrSpec>getMandatoryAttrIds()Returns the set of mandatoryAttrs.Set<String>getMandatoryOneofs()Returns the set of mandatoryOneofs.ParsedReferencePointsgetReferencePoints()dev.amp.validator.ValidatorProtos.TagSpecgetSpec()Getting the TagSpec.booleanhasAttrWithName(String name)Returns if attrsByName contains the mapping keyed name.booleanhasReferencePoints()Return true if reference points not empty.intid()Returns the parsed tag spec id.booleanisReferencePoint()Returns a boolean whether the this tagSpec has reference point.booleanisTypeJson()Returns true if this tagSpec contains an attribute of name "type" and value "application/json".booleanisUsedForTypeIdentifiers(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.ReferencePointMatcherreferencePointMatcher(ParsedValidatorRules rules, Locator lineCol)If tag has a reference_point spec, returns a ReferencePointMatcher, else null.List<String>requires()A TagSpec may specify generic conditions which are required if the tag is present.RecordValidatedshouldRecordTagspecValidated()Whether or not the tag should be recorded via Context.recordTagspecValidated_ if it was validated successfully.
-
-
-
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.
-
childTagMatcher
public ChildTagMatcher childTagMatcher() throws TagValidationException
If tag has a child_tag spec, returns a ChildTagMatcher, else null.- Returns:
- ChildTagMatcher returns the ChildTagMatcher.
- Throws:
TagValidationException- the TagValidationException.
-
referencePointMatcher
public ReferencePointMatcher referencePointMatcher(@Nonnull ParsedValidatorRules rules, @Nonnull Locator lineCol) throws TagValidationException
If tag has a reference_point spec, returns a ReferencePointMatcher, else null.- Parameters:
rules- the ParsedValidatorRules object.lineCol- the pair of line/col.- Returns:
- returns the ReferencePointMatcher object.
- Throws:
TagValidationException- the TagValidationException.
-
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.
-
requires
public List<String> requires()
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.
-
excludes
public List<String> excludes()
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.
-
-