Package dev.amp.validator
Class CdataMatcher
- java.lang.Object
-
- dev.amp.validator.CdataMatcher
-
public class CdataMatcher extends Object
CdataMatcher maintains a constraint to check which an opening tag introduces: a tag's cdata matches constraints set by it's cdata spec. Unfortunately we need to defer such checking and can't handle it while the opening tag is being processed.- Author:
- nhant01, GeorgeLuo
-
-
Constructor Summary
Constructors Constructor Description CdataMatcher(ParsedTagSpec parsedTagSpec, Locator lineCol)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LocatorgetLineCol()dev.amp.validator.ValidatorProtos.TagSpecgetTagSpec()voidmatch(String cdata, Context context, dev.amp.validator.ValidatorProtos.ValidationResult.Builder validationResult)Matches the provided cdata against what this CdataMatcher expects.intmatchCss(String cdata, dev.amp.validator.ValidatorProtos.CssSpec cssSpec, Context context, dev.amp.validator.ValidatorProtos.ValidationResult.Builder validationResult)Matches the provided cdata against a CSS specification.
-
-
-
Constructor Detail
-
CdataMatcher
public CdataMatcher(@Nonnull ParsedTagSpec parsedTagSpec, @Nonnull Locator lineCol)Constructor.- Parameters:
parsedTagSpec- the ParsedTagSpec.lineCol- a line / column pair.
-
-
Method Detail
-
match
public void match(@Nonnull String cdata, @Nonnull Context context, @Nonnull dev.amp.validator.ValidatorProtos.ValidationResult.Builder validationResult) throws TagValidationException, CssValidationException, IOExceptionMatches the provided cdata against what this CdataMatcher expects.- Parameters:
cdata- the cdata.context- the context object.validationResult- validation result object.- Throws:
TagValidationException- the TagValidationException.CssValidationException- css validation exception.IOException- IO exception.
-
matchCss
public int matchCss(@Nonnull String cdata, @Nonnull dev.amp.validator.ValidatorProtos.CssSpec cssSpec, @Nonnull Context context, @Nonnull dev.amp.validator.ValidatorProtos.ValidationResult.Builder validationResult) throws CssValidationException, IOExceptionMatches the provided cdata against a CSS specification. Helper routine for match (see above). The return value is the number of bytes in the CSS string which were measured as URLs. In some validation types, these bytes are not counted against byte limits.- Parameters:
cdata- the cdata.cssSpec- CSS specification.context- the context object.validationResult- validation result.- Returns:
- returns 1 if css matches against a CSS spec.
- Throws:
CssValidationException- css validation exception.IOException- IO validation exception.
-
getLineCol
public Locator getLineCol()
- Returns:
- lineCol of CdataMatcher
-
getTagSpec
public dev.amp.validator.ValidatorProtos.TagSpec getTagSpec()
- Returns:
- tagspec of the CdataMatcher
-
-