Package dev.amp.validator
Class AMPHtmlHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- dev.amp.validator.AMPHtmlHandler
-
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
public class AMPHtmlHandler extends DefaultHandler
Validation handler which accepts callbacks from HTML parser.- Author:
- nhant01, GeorgeLuo
-
-
Constructor Summary
Constructors Constructor Description AMPHtmlHandler(AMPValidatorManager validatorManager, dev.amp.validator.ValidatorProtos.HtmlFormat.Code htmlFormat, ExitCondition condition, int maxNodesAllowed, int docByteSize)Creates an AMPHtmlHandler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcdata(String text)Callback for cdata.voidcharacters(char[] ch, int start, int length)Processing character data inside an element.voidemitMissingExtensionErrors()While parsing the document HEAD, we may accumulate errors which depend on seeing later extension script tags.voidendDocument()Processing the end of the document.voidendElement(String uri, String localName, String qName)Processing the end of an element.voidsetDocumentLocator(Locator locator)Receive a Locator object for document events.voidstartDocument()Processing the beginning of the document.voidstartElement(String uri, String localName, String qName, Attributes attributes)Processing the start of an element.dev.amp.validator.ValidatorProtos.ValidationResult.BuildervalidationResult()Returns the validation result.-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Constructor Detail
-
AMPHtmlHandler
public AMPHtmlHandler(@Nonnull AMPValidatorManager validatorManager, @Nonnull dev.amp.validator.ValidatorProtos.HtmlFormat.Code htmlFormat, @Nonnull ExitCondition condition, int maxNodesAllowed, int docByteSize)Creates an AMPHtmlHandler.- Parameters:
validatorManager- the validator manager instance.htmlFormat- HtmlFormat code.condition- exit condition.maxNodesAllowed- max nodes allowed.docByteSize- length of html document.
-
-
Method Detail
-
startDocument
public void startDocument() throws SAXExceptionProcessing the beginning of the document.- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler- Throws:
SAXException- Any SAX exception.
-
endDocument
public void endDocument() throws SAXExceptionProcessing the end of the document.- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler- Throws:
SAXException- Any SAX exception.
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
Processing the start of an element.- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Parameters:
uri- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.localName- The local name (without prefix), or the empty string if Namespace processing is not being performed.qName- The qualified name (with prefix), or the empty string if qualified names are not available.attributes- The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.- Throws:
SAXException- Any SAX exception
-
endElement
public void endElement(String uri, String localName, String qName)
Processing the end of an element.- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Parameters:
uri- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.localName- The local name (without prefix), or the empty string if Namespace processing is not being performed.qName- The qualified name (with prefix), or the empty string if qualified names are not available.
-
setDocumentLocator
public void setDocumentLocator(@Nonnull Locator locator)Receive a Locator object for document events.- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classDefaultHandler- Parameters:
locator- A locator for all SAX document events.
-
validationResult
public dev.amp.validator.ValidatorProtos.ValidationResult.Builder validationResult()
Returns the validation result.- Returns:
- returns the validation result.
-
emitMissingExtensionErrors
public void emitMissingExtensionErrors()
While parsing the document HEAD, we may accumulate errors which depend on seeing later extension script tags.
-
cdata
public void cdata(@Nonnull String text) throws TagValidationException, CssValidationException, IOExceptionCallback for cdata.- Parameters:
text- the css content to validate- Throws:
TagValidationException- tag validation exception.CssValidationException- css validation exception.IOException- IO exception.
-
characters
public void characters(char[] ch, int start, int length)Processing character data inside an element.- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Parameters:
ch- The characters.start- The start position in the character array.length- The number of characters to use from the character array.
-
-