Class AbstractHTML5Validator

    • Constructor Detail

      • AbstractHTML5Validator

        public AbstractHTML5Validator()
    • Method Detail

      • setHTML5Document

        public void setHTML5Document​(InputStream document)
        Set document to validate.
        Parameters:
        document - document to validate
      • getHTML5Document

        public org.jsoup.nodes.Document getHTML5Document()
        Returns:
        the parsed html5 document
      • assertFalse

        protected void assertFalse​(ValidationError.Type errorType,
                                   String message,
                                   boolean condition)
        Asserts that a condition is false. If it isn't it puts an error message in the validation results.
        Parameters:
        errorType - type of the error
        message - the message to add
        condition - condition to be checked
      • assertTrue

        protected void assertTrue​(ValidationError.Type errorType,
                                  String message,
                                  boolean condition)
        Asserts that a condition is true. If it isn't it puts an error message in the validation results.
        Parameters:
        errorType - type of the error
        message - the message to add
        condition - condition to be checked
      • containsElement

        public boolean containsElement​(String tagName)
        Check if the html5Document contains the given element.
        Parameters:
        tagName - element to search
        Returns:
        true if the html5Document contains the element, false otherwise
      • getElements

        public org.jsoup.select.Elements getElements​(String tagName)
        Get a list of elements matching a given tag name in the html5Document.
        Parameters:
        tagName - tag name to search for
        Returns:
        the list of matching elements
      • getElements

        public org.jsoup.select.Elements getElements​(Collection<String> tagNames)
        Get all the elements matching one of the given tags.
        Parameters:
        tagNames - tag names to match
        Returns:
        the list of matching tags
      • hasChildElement

        public boolean hasChildElement​(org.jsoup.nodes.Element element,
                                       String tagName)
        Check if an element has an child element with the given tag name.
        Parameters:
        element - element to analyze
        tagName - tag name to search for
        Returns:
        true if the element has an child element with the given tag name
      • getChildren

        public org.jsoup.select.Elements getChildren​(org.jsoup.nodes.Element element,
                                                     String tagName)
        Get children of a given type.
        Parameters:
        element - element to search in
        tagName - name of the tags to match
        Returns:
        a list of matching tags
      • getChildrenTagNames

        public List<String> getChildrenTagNames​(org.jsoup.nodes.Element element)
        Get the names of all the children elements of an element.
        Parameters:
        element - parent element
        Returns:
        the names of all the children elements of an element.
      • hasAttribute

        public static boolean hasAttribute​(org.jsoup.nodes.Element element,
                                           String attributeName)
        Check if an element has the given attribute.
        Parameters:
        element - element to analyze
        attributeName - name of the attribute to search
        Returns:
        true if the element has the given attribute, false otherwise
      • getAttributeNames

        public static List<String> getAttributeNames​(org.jsoup.nodes.Element element)
        Get the names of all the attribute of an element.
        Parameters:
        element - element to analyze
        Returns:
        the names of all the attribute of the given element
      • getAttributeValue

        public static String getAttributeValue​(org.jsoup.nodes.Element element,
                                               String attributeName)
        AbstractDOMValidator Get the value of an element attribute.
        Parameters:
        element - element to analyze
        attributeName - name of the attribute to search
        Returns:
        the value of the given attribute
      • getAttributeValues

        public static List<String> getAttributeValues​(org.jsoup.select.Elements elements,
                                                      String attributeName)
        Retrieve a list of values of an attribute for a list of elements.
        Parameters:
        elements - the list of elements to get the attribute from
        attributeName - name of the attribute to retrieve the value from
        Returns:
        the list of values of the given attribute for all the elements in the given element list
      • getElement

        public org.jsoup.nodes.Element getElement​(String tagName)
        Parameters:
        tagName - name of the tag to match
        Returns:
        The first element found for the given tag name in the XHTML html5Document.