use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.
the class Rgaa32016Rule060303 method testLink.
/**
*
* @param sspHandler
* @param el
* @return
*/
private TestSolution testLink(SSPHandler sspHandler, Element el) {
ElementHandler<Element> elHandler = new ElementHandlerImpl(el);
TestSolutionHandler tsHandler = new TestSolutionHandlerImpl();
// reset the service for each tested element. We use the collection
// handled by the service to feed the local collection of remarks
prs.resetService();
// check the pertinence of the link
getDecidableElementsChecker().check(sspHandler, elHandler, tsHandler);
// get the processRemark for eventually override it with the result
// returned by the title pertinence checker
ProcessRemark remark = prs.getRemarkList().iterator().next();
// to nmi but the inverse is impossible.
if (tsHandler.getTestSolution().equals(TestSolution.FAILED)) {
// check the pertinence of the title of the link
String linkText = getDecidableElementsChecker().getTextElementBuilder().buildTextFromElement(el);
if (testTitleAttributeLink(sspHandler, el, linkText).equals(TestSolution.NEED_MORE_INFO)) {
//override result (evidence element have already been collected
remark.setIssue(TestSolution.NEED_MORE_INFO);
remark.setMessageCode(CHECK_LINK_PERTINENCE_MSG);
remarks.add(remark);
return TestSolution.NEED_MORE_INFO;
}
}
remarks.add(remark);
return tsHandler.getTestSolution();
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.
the class Rgaa32016Rule060303 method testTitleAttributeLink.
/**
*
* @param sspHandler
* @param el
* @param linkText
* @return
*/
private TestSolution testTitleAttributeLink(SSPHandler sspHandler, Element el, String linkText) {
// content identical to the link text, returns not applicable.
if (!el.hasAttr(TITLE_ATTR)) {
return TestSolution.NOT_APPLICABLE;
}
String attrValue = el.attr(TITLE_ATTR);
if (StringUtils.isBlank(attrValue)) {
return TestSolution.NOT_APPLICABLE;
}
if (StringUtils.equalsIgnoreCase(attrValue, linkText)) {
return TestSolution.NOT_APPLICABLE;
}
ElementHandler<Element> elHandler = new ElementHandlerImpl(el);
TestSolutionHandler tsHandler = new TestSolutionHandlerImpl();
titlePertinenceElementChecker.check(sspHandler, elHandler, tsHandler);
return tsHandler.getTestSolution();
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.
the class Rgaa32016Rule080301 method removeElementWithParentWithLangAttr.
/**
* Remove elements from the current elementHandler when an element has a
* parent with a lang attribute
*
* @param elementHandler
*/
private void removeElementWithParentWithLangAttr() {
if (elementWithLang.isEmpty()) {
return;
}
ElementHandler<Element> elementWithParentWithLang = new ElementHandlerImpl();
for (Element el : elementWithoutLang.get()) {
if (isElementHasParentWithLang(el)) {
elementWithParentWithLang.add(el);
}
}
elementWithoutLang.removeAll(elementWithParentWithLang);
elementWithLang.addAll(elementWithParentWithLang.get());
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.
the class Rgaa32016Rule060301 method testTitleAttributeLink.
/**
*
* @param sspHandler
* @param el
* @param linkText
* @return
*/
private TestSolution testTitleAttributeLink(SSPHandler sspHandler, Element el, String linkText) {
// content identical to the link text, returns not applicable.
if (!el.hasAttr(TITLE_ATTR)) {
return TestSolution.NOT_APPLICABLE;
}
String attrValue = el.attr(TITLE_ATTR);
if (StringUtils.isBlank(attrValue)) {
return TestSolution.NOT_APPLICABLE;
}
if (StringUtils.equalsIgnoreCase(attrValue, linkText)) {
return TestSolution.NOT_APPLICABLE;
}
ElementHandler<Element> elHandler = new ElementHandlerImpl(el);
TestSolutionHandler tsHandler = new TestSolutionHandlerImpl();
titlePertinenceElementChecker.check(sspHandler, elHandler, tsHandler);
return tsHandler.getTestSolution();
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.
the class Rgaa32016Rule060301 method testLink.
/**
*
* @param sspHandler
* @param el
* @return
*/
private TestSolution testLink(SSPHandler sspHandler, Element el) {
ElementHandler<Element> elHandler = new ElementHandlerImpl(el);
TestSolutionHandler tsHandler = new TestSolutionHandlerImpl();
// reset the service for each tested element. We use the collection
// handled by the service to feed the local collection of remarks
prs.resetService();
// check the pertinence of the link
getDecidableElementsChecker().check(sspHandler, elHandler, tsHandler);
// get the processRemark for eventually override it with the result
// returned by the title pertinence checker
ProcessRemark remark = prs.getRemarkList().iterator().next();
// to nmi but the inverse is impossible.
if (tsHandler.getTestSolution().equals(TestSolution.FAILED)) {
// check the pertinence of the title of the link
String linkText = getDecidableElementsChecker().getTextElementBuilder().buildTextFromElement(el);
if (testTitleAttributeLink(sspHandler, el, linkText).equals(TestSolution.NEED_MORE_INFO)) {
//override result (evidence element have already been collected
remark.setIssue(TestSolution.NEED_MORE_INFO);
remark.setMessageCode(CHECK_LINK_PERTINENCE_MSG);
remarks.add(remark);
return TestSolution.NEED_MORE_INFO;
}
}
remarks.add(remark);
return tsHandler.getTestSolution();
}
Aggregations