Search in sources :

Example 1 with TextLengthChecker

use of org.asqatasun.rules.elementchecker.text.TextLengthChecker in project Asqatasun by Asqatasun.

the class SeoRule01013 method check.

@Override
protected void check(final SSPHandler sspHandler, final TestSolutionHandler testSolutionHandler) {
    if (elementHandler.isEmpty() || elementHandler.get().size() > 1) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    ElementChecker checker = new TextLengthChecker(new TextAttributeOfElementBuilder(AttributeStore.CONTENT_ATTR), MAX_META_DESC_LENGTH, META_DESC_EXCEEDS_LIMIT_MSG, // evidence elements
    AttributeStore.CONTENT_ATTR);
    checker.check(sspHandler, elementHandler, testSolutionHandler);
}
Also used : TextLengthChecker(org.asqatasun.rules.elementchecker.text.TextLengthChecker) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 2 with TextLengthChecker

use of org.asqatasun.rules.elementchecker.text.TextLengthChecker in project Asqatasun by Asqatasun.

the class SeoRule06031 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (elementHandler.isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    // in case of more than one title, keep the first. 
    if (elementHandler.get().size() > 1) {
        Element element = elementHandler.get().iterator().next();
        elementHandler.clean().add(element);
    }
    ElementChecker checker = new TextLengthChecker(new SimpleTextElementBuilder(), TITLE_MAX_LENGTH, TITLE_EXCEEDS_LIMIT_MSG, // evidence elements
    HtmlElementStore.TEXT_ELEMENT2);
    checker.check(sspHandler, elementHandler, testSolutionHandler);
}
Also used : TextLengthChecker(org.asqatasun.rules.elementchecker.text.TextLengthChecker) SimpleTextElementBuilder(org.asqatasun.rules.textbuilder.SimpleTextElementBuilder) Element(org.jsoup.nodes.Element) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Aggregations

ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)2 TextLengthChecker (org.asqatasun.rules.elementchecker.text.TextLengthChecker)2 SimpleTextElementBuilder (org.asqatasun.rules.textbuilder.SimpleTextElementBuilder)1 TextAttributeOfElementBuilder (org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)1 Element (org.jsoup.nodes.Element)1