diff --git a/.classpath b/.classpath
index c783261..9bed3d4 100644
--- a/.classpath
+++ b/.classpath
@@ -1,27 +1,27 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
index e69de29..90f0431 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+target/**
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 0c68a61..45a6e0e 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.8
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
index f4bf050..7799a4f 100644
--- a/.settings/org.eclipse.wst.common.project.facet.core.xml
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -1,5 +1,5 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/lombok.jar b/lombok.jar
deleted file mode 100644
index 23cc160..0000000
Binary files a/lombok.jar and /dev/null differ
diff --git a/pom.xml b/pom.xml
index f67e447..272e8bd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,11 +31,11 @@
3.0
-
- org.projectlombok
- lombok
- 1.16.12
- provided
+
+ org.projectlombok
+ lombok
+ 0.12.0
+ provided
diff --git a/src/main/java/br/com/checker/emag/core/BehaviorEvaluation.java b/src/main/java/br/com/checker/emag/core/BehaviorEvaluation.java
index 7945914..b205b1b 100644
--- a/src/main/java/br/com/checker/emag/core/BehaviorEvaluation.java
+++ b/src/main/java/br/com/checker/emag/core/BehaviorEvaluation.java
@@ -117,7 +117,10 @@ public class BehaviorEvaluation extends Evaluation {
private List checkRecommendation10() {
- List occurrences = new ArrayList();
+
+ List occurrences = new ArrayList();
+
+ try {
for (Element element : getDocument().getAllElements()) {
@@ -197,7 +200,9 @@ public class BehaviorEvaluation extends Evaluation {
}
}
}
-
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return occurrences;
}
@@ -205,7 +210,7 @@ public class BehaviorEvaluation extends Evaluation {
private List checkRecommendation11() {
List occurrences = new ArrayList();
-
+try {
// boolean script = false;
// boolean contAlter = false;
@@ -283,13 +288,16 @@ public class BehaviorEvaluation extends Evaluation {
*
* }
*/
-
+} catch (Exception e) {
+ e.printStackTrace();
+}
return occurrences;
}
private List checkRecommendation12() {
List occurrences = new ArrayList();
+ try {
boolean temMetaRefresh = false;
for (Element element : getDocument().getAllElements("meta")) {
Attribute httpEquiv = element.getAttributes().get("http-equiv");
@@ -304,13 +312,16 @@ public class BehaviorEvaluation extends Evaluation {
* if(!temMetaRefresh) occurrences.add(new Occurrence("2.3", false,
* this.getDocument().getFirstElement().toString(),OccurrenceClassification.BEHAVIOR));
*/
-
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return occurrences;
}
private List checkRecommendation13() {
List occurrences = new ArrayList();
+ try {
for (Element element : getDocument().getAllElements("meta")) {
Attribute content = element.getAttributes().get("content");
Attribute httpEquiv = element.getAttributes().get("http-equiv");
@@ -323,12 +334,18 @@ public class BehaviorEvaluation extends Evaluation {
&& url == true)
occurrences.add(this.buildOccurrence("2.4", true, element.toString(), element, "1"));
}
-
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return occurrences;
}
private List checkRecommendation14() {
List occurrences = new ArrayList();
+
+ try {
+
+
boolean hasBlink = false;
boolean hasMarquee = false;
for (Element blink : getDocument().getAllElements("blink")) {
@@ -345,14 +362,17 @@ public class BehaviorEvaluation extends Evaluation {
occurrences.add(new Occurrence("2.5", false, getDocument().getFirstElement().toString(),
OccurrenceClassification.BEHAVIOR, "1"));
}
-
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return occurrences;
}
private List checkRecommendation15() {
List occurrences = new ArrayList();
-
+try {
for (Element blink : getDocument().getAllElements("blink")) {
occurrences.add(this.buildOccurrence("2.6", true, blink.toString(), blink, "1"));
}
@@ -377,12 +397,14 @@ public class BehaviorEvaluation extends Evaluation {
occurrences.add(this.buildOccurrence("2.6", false, img.toString(), img, "3"));
}
}
-
+} catch (Exception e) {
+ e.printStackTrace();
+}
return occurrences;
}
private boolean isTagForm(Element element) {
-
+try {
List tagsForm = new ArrayList();
tagsForm.add("form");
tagsForm.add("input");
@@ -399,15 +421,24 @@ public class BehaviorEvaluation extends Evaluation {
if (element != null)
return tagsForm.contains(element.getName());
-
+
+} catch (Exception e) {
+ e.printStackTrace();
+}
return false;
}
private List checkRecommendation16() {
List occurrences = new ArrayList();
+
+ try {
+
occurrences.add(new Occurrence("2.7", false, getDocument().getFirstElement().toString(),
OccurrenceClassification.BEHAVIOR));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return occurrences;
}
diff --git a/src/main/java/br/com/checker/emag/core/ContentEvaluation.java b/src/main/java/br/com/checker/emag/core/ContentEvaluation.java
index 69d7110..8048b06 100644
--- a/src/main/java/br/com/checker/emag/core/ContentEvaluation.java
+++ b/src/main/java/br/com/checker/emag/core/ContentEvaluation.java
@@ -11,9 +11,14 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.validation.constraints.Max;
+
import net.htmlparser.jericho.Attribute;
import net.htmlparser.jericho.Element;
import net.htmlparser.jericho.Source;
@@ -34,6 +39,9 @@ import br.com.checker.emag.util.UrlSemArquiNoFinal;
public class ContentEvaluation extends Evaluation {
+ private List occurrencesLinks;
+ private Element linkThread;
+
public ContentEvaluation(Source document) {
super(document);
}
@@ -198,6 +206,7 @@ public class ContentEvaluation extends Evaluation {
private List checkRecommendation17() {
List occurrences = new ArrayList();
+ try {
Element html = getDocument().getFirstElement("html");
if (html != null) {
@@ -224,7 +233,7 @@ public class ContentEvaluation extends Evaluation {
// Caso seja diferente de html5
if (!doctype.equalsIgnoreCase("")) {
- if (xmlLang == null || lang == null) {
+ if (xmlLang == null && lang == null) {
occurrences.add(this.buildOccurrence("3.1", true, tagHtml, html, "1"));
}
} else {
@@ -251,13 +260,17 @@ public class ContentEvaluation extends Evaluation {
* false, html.toString(), html, "2")); }
*/
}
-
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return occurrences;
}
private List checkRecommendation18() {
List occurrences = new ArrayList();
+ try {
+
for (Element element : getDocument().getAllElements()) {
if (!element.getName().equals("html")) {
@@ -269,7 +282,9 @@ public class ContentEvaluation extends Evaluation {
occurrences.add(this.buildOccurrence("3.2", false, element.toString(), element, "1"));
}
}
-
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return occurrences;
}
@@ -277,19 +292,24 @@ public class ContentEvaluation extends Evaluation {
Element titulo = getDocument().getFirstElement("title");
+
String titulo_site = "";
-
+try {
if (titulo != null) {
titulo_site = titulo.getContent().getTextExtractor().toString();
}
-
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return titulo_site;
}
private List checkRecommendation19() {
List occurrences = new ArrayList();
+ try {
+
// Element head = getDocument().getFirstElement("head");
// if(head == null) {
@@ -312,6 +332,10 @@ public class ContentEvaluation extends Evaluation {
occurrences.add(buildOccurrence("3.3", true, title.toString(), title, "1"));
}
// }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return occurrences;
}
@@ -323,83 +347,130 @@ public class ContentEvaluation extends Evaluation {
return occurrences;
}
- private List checkRecommendation21() {
- List occurrences = new ArrayList();
- UrlSemArquiNoFinal objetoUrlSemArquiNoFinal = new UrlSemArquiNoFinal();
-
- String urlSemArquiNoFinal = objetoUrlSemArquiNoFinal.urlSemArquivoNoFinal(getUrl());
-
- Element LinkComImg;
-
+
+
+
+ private List checkRecommendation21() {
+ occurrencesLinks = new ArrayList();
+
+ try {
+ ExecutorService executor = Executors.newFixedThreadPool(30);
for (Element link : getDocument().getAllElements("a")) {
- String href = link.getAttributeValue("href");
- String title = link.getAttributeValue("title");
- String content = link.getContent().toString();
-
- if (hasEqualsContentHref(link) && isRegistroBr(content))
- occurrences.add(this.buildOccurrence("3.5", false, link.toString(), link, "2"));
+
+ try {
+ if(link.getAttributeValue("href").startsWith("http") || link.getAttributeValue("href").startsWith("www"))
+ {
+ try {
+
+
+ Runnable worker = new WorkerThread(link);
+ executor.execute(worker);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
- LinkComImg = link.getFirstElement("img");
-
- if (LinkComImg == null) {
- if (!hasContent(link)) {
- occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "3"));// "2"));
}
- } else {
- if (hasLinkComImgWithoutAlt(link)) {
- occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "3"));// "2"));
- }
- }
-
- if (LinkComImg == null) {
- // if(hasTitle(link) && isNotAlt(link))
- if (hasTitle(link) && !hasContent(link))
- occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "4"));// "3"));
- } else {
- // if(hasTitle(link) && isNotAlt(link))
- if (hasTitle(link) && !hasContent(link) && hasLinkComImgWithoutAlt(link))
- occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "4"));// "3"));
- }
-
- /*
- * if(!hasTitle(link) && !hasContent(link) && hasImgWithoutAlt(link))
- * occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link,"4"));
- */
-
- if (hasImgWithoutAlt(link))
- occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "5"));// "4"));
-
- if (hasLeiaMaisDescription(link))
- occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "6"));// "5"));
-
- if (hasDiferenteContentSameLink(link))
- occurrences.add(this.buildOccurrence("3.5", false, link.toString(), link, "10"));// "6"));
-
- if (isTitleEqualsContent(link))
- occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "12"));// "8"));
-
- if (hasSameContentDiferentLink(link))
- occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "11"));// "7"));
-
- if (link != null && hasLongContent(link))
- occurrences.add(this.buildOccurrence("3.5", false, link.toString(), link, "13"));// "9"));
-
- String retorno = "";
- if (link != null)
- retorno = isLinkUnavailable(link, urlSemArquiNoFinal);
- if (retorno.equalsIgnoreCase("erro")) {
- occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "14"));// "10"));
- } else if (retorno.equalsIgnoreCase("aviso")) {
- occurrences.add(this.buildOccurrence("3.5", false, link.toString(), link, "15"));// "10"));
- }
-
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+
+ executor.shutdown();
+
+ executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
}
- return occurrences;
- }
-
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ //while (!executor.isTerminated()) {
+ // }
+ return occurrencesLinks;
+ }
+
+ private void checkRecomendationComThread(Element link)
+ {
+ try {
+
+
+ UrlSemArquiNoFinal objetoUrlSemArquiNoFinal = new UrlSemArquiNoFinal();
+
+ String urlSemArquiNoFinal = objetoUrlSemArquiNoFinal.urlSemArquivoNoFinal(getUrl());
+
+
+
+ Element LinkComImg;
+ String href = link.getAttributeValue("href");
+ String title = link.getAttributeValue("title");
+ String content = link.getContent().toString();
+
+
+
+
+ if (hasEqualsContentHref(link) && isRegistroBr(content))
+ occurrencesLinks.add(this.buildOccurrence("3.5", false, link.toString(), link, "2"));
+
+ LinkComImg = link.getFirstElement("img");
+
+ if (LinkComImg == null) {
+ if (!hasContent(link)) {
+ occurrencesLinks.add(this.buildOccurrence("3.5", true, link.toString(), link, "3"));// "2"));
+ }
+ } else {
+ if (hasLinkComImgWithoutAlt(link)) {
+ occurrencesLinks.add(this.buildOccurrence("3.5", true, link.toString(), link, "3"));// "2"));
+ }
+ }
+
+ if (LinkComImg == null) {
+ // if(hasTitle(link) && isNotAlt(link))
+ if (hasTitle(link) && !hasContent(link))
+ occurrencesLinks.add(this.buildOccurrence("3.5", true, link.toString(), link, "4"));// "3"));
+ } else {
+ // if(hasTitle(link) && isNotAlt(link))
+ if (hasTitle(link) && !hasContent(link) && hasLinkComImgWithoutAlt(link))
+ occurrencesLinks.add(this.buildOccurrence("3.5", true, link.toString(), link, "4"));// "3"));
+ }
+
+ /*
+ * if(!hasTitle(link) && !hasContent(link) && hasImgWithoutAlt(link))
+ * occurrencesLinks.add(this.buildOccurrence("3.5", true, link.toString(), link,"4"));
+ */
+
+ if (hasImgWithoutAlt(link))
+ occurrencesLinks.add(this.buildOccurrence("3.5", true, link.toString(), link, "5"));// "4"));
+
+ if (hasLeiaMaisDescription(link))
+ occurrencesLinks.add(this.buildOccurrence("3.5", true, link.toString(), link, "6"));// "5"));
+
+ if (hasDiferenteContentSameLink(link))
+ occurrencesLinks.add(this.buildOccurrence("3.5", false, link.toString(), link, "10"));// "6"));
+
+ if (isTitleEqualsContent(link))
+ occurrencesLinks.add(this.buildOccurrence("3.5", true, link.toString(), link, "12"));// "8"));
+
+ if (hasSameContentDiferentLink(link))
+ occurrencesLinks.add(this.buildOccurrence("3.5", true, link.toString(), link, "11"));// "7"));
+
+ if (link != null && hasLongContent(link))
+ occurrencesLinks.add(this.buildOccurrence("3.5", false, link.toString(), link, "13"));// "9"));
+
+ String retorno = "";
+ if (link != null)
+ retorno = isLinkUnavailable(link, urlSemArquiNoFinal);
+ if (retorno.equalsIgnoreCase("erro")) {
+ occurrencesLinks.add(this.buildOccurrence("3.5", true, link.toString(), link, "14"));// "10"));
+ } else if (retorno.equalsIgnoreCase("aviso")) {
+ occurrencesLinks.add(this.buildOccurrence("3.5", false, link.toString(), link, "15"));// "10"));
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
private String isLinkUnavailable(Element link, String url) {
-
+try {
String href = link.getAttributeValue("href");
if (href != null && href.startsWith("www")) {
@@ -434,7 +505,6 @@ public class ContentEvaluation extends Evaluation {
HttpMethod metodoRequisicaoGET = null;
HttpClient clienteHTTPJakartaCommons;
URL UrlConvertida;
-
codResponse = verificarConexao(href, "http.agent", "Jakarta Commons-HttpClient/3.1");
if (codResponse != 200) {
@@ -454,6 +524,9 @@ public class ContentEvaluation extends Evaluation {
}
}
+} catch (Exception e) {
+ e.printStackTrace();
+}
return "false";
}
@@ -484,8 +557,7 @@ public class ContentEvaluation extends Evaluation {
new DefaultHttpMethodRetryHandler(3, false));
clienteHTTPJakartaCommons.getParams().setParameter("http.protocol.allow-circular-redirects",
true);
- clienteHTTPJakartaCommons.getParams().setParameter(HttpConnectionParams.CONNECTION_TIMEOUT,
- new Integer(2000));
+ clienteHTTPJakartaCommons.getParams().setParameter(HttpConnectionParams.CONNECTION_TIMEOUT, new Integer(2000));
metodoRequisicao = new HeadMethod(UrlConvertida.toExternalForm());// GetMethod(UrlConvertida.toExternalForm());// URLEncoder.encode(UrlConvertida.toExternalForm(),
@@ -550,6 +622,7 @@ public class ContentEvaluation extends Evaluation {
temConteudo = StringUtils.isNotBlank(link.getContent().getTextExtractor().toString());
+ try {
if (!temConteudo) {
for (Element elemento : link.getAllElements()) {
temConteudo = StringUtils.isNotBlank(elemento.getContent().getTextExtractor().toString());
@@ -559,6 +632,11 @@ public class ContentEvaluation extends Evaluation {
}
}
}
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
return temConteudo;
/*
@@ -581,6 +659,8 @@ public class ContentEvaluation extends Evaluation {
boolean temImgSemAlt = false;
String alt;
+
+ try {
for (Element elementoImagem : link.getAllElements("img")) {
@@ -590,7 +670,9 @@ public class ContentEvaluation extends Evaluation {
break;
}
}
-
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return temImgSemAlt;
}
@@ -609,6 +691,7 @@ public class ContentEvaluation extends Evaluation {
link.getFirstElement("img") != null ? link.getFirstElement("img").getAttributeValue("alt")
: "";
+ try {
for (String leiaMais : this.leiaMais) {
if (title != null)
@@ -633,7 +716,9 @@ public class ContentEvaluation extends Evaluation {
*
* if(altImg!=null) if(pattern.matcher(altImg.toLowerCase()).find()) return true; }
*/
-
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return false;
}
@@ -738,6 +823,9 @@ public class ContentEvaluation extends Evaluation {
}
private List checkRecommendation22() {
+
+ occurrencesLinks = null;
+
List occurrences = new ArrayList();
String[] parts = null;
@@ -1047,4 +1135,33 @@ public class ContentEvaluation extends Evaluation {
return occurrences;
}
+
+ public class WorkerThread implements Runnable {
+
+ private Element linkThead;
+
+ public WorkerThread(Element link){
+ this.linkThead= link;
+ }
+
+ public void run() {
+ processCommand();
+ }
+
+ private void processCommand() {
+ try {
+ Thread.sleep(1000);
+
+ checkRecomendationComThread(this.linkThead);
+
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ }
}
+
+
+
diff --git a/src/main/java/br/com/checker/emag/core/FormEvaluation.java b/src/main/java/br/com/checker/emag/core/FormEvaluation.java
index 68238da..d208083 100644
--- a/src/main/java/br/com/checker/emag/core/FormEvaluation.java
+++ b/src/main/java/br/com/checker/emag/core/FormEvaluation.java
@@ -93,6 +93,7 @@ public class FormEvaluation extends Evaluation{
private List checkRecommendation38() {
List occurrences = new ArrayList();
+ try {
for (Element input : this.getDocument().getAllElements("input")) {
Attribute type = input.getAttributes().get("type");
if (type != null) {
@@ -126,12 +127,17 @@ public class FormEvaluation extends Evaluation{
}
}
}
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return occurrences;
}
private List checkRecommendation39() {
List occurrences = new ArrayList();
+try {
+
for (Element form : this.getDocument().getAllElements("form")) {
/*for (Element label : form.getAllElements("label")) {
Attribute attrFor = label.getAttributes().get("for");
@@ -228,6 +234,9 @@ public class FormEvaluation extends Evaluation{
}
+} catch (Exception e) {
+ e.printStackTrace();
+}
return occurrences;
}
@@ -245,6 +254,9 @@ public class FormEvaluation extends Evaluation{
private List checkRecommendation41() {
List occurrences = new ArrayList();
+
+ try {
+
String[] eventos1 = {"onchange", "onblur","onfocus", "onformchange",
"onforminput","oninput","oninvalid","onreset",
"onselect","onsubmit","onkeydown","onkeypress",
@@ -294,7 +306,9 @@ public class FormEvaluation extends Evaluation{
}
this.oder(occurrences);
-
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return occurrences;
}
@@ -331,6 +345,8 @@ public class FormEvaluation extends Evaluation{
private List checkRecommendation44() {
List occurrences = new ArrayList();
+ try {
+
for (Element form : this.getDocument().getAllElements("form")) {
//String tagForm = form.getStartTag()+"";
@@ -362,6 +378,10 @@ public class FormEvaluation extends Evaluation{
}
}
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
return occurrences;
}
@@ -377,7 +397,14 @@ public class FormEvaluation extends Evaluation{
private List checkRecommendation45() {
List occurrences = new ArrayList();
+
+ try {
+
+
occurrences.add(new Occurrence("6.8", false, getDocument().getFirstElement().toString(),OccurrenceClassification.FORM));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return occurrences;
}
diff --git a/src/main/java/br/com/checker/emag/core/MarkEvaluation.java b/src/main/java/br/com/checker/emag/core/MarkEvaluation.java
index 3e333b2..bc62316 100644
--- a/src/main/java/br/com/checker/emag/core/MarkEvaluation.java
+++ b/src/main/java/br/com/checker/emag/core/MarkEvaluation.java
@@ -1,6 +1,5 @@
package br.com.checker.emag.core;
-
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
@@ -27,1141 +26,1127 @@ import com.google.gson.GsonBuilder;
public class MarkEvaluation extends Evaluation {
- // private static String CSS_VALIDATOR_URL =
- // "http://www.css-validator.org/validator?uri=#{url}&warning=0&output=soap12";
- private static String CSS_VALIDATOR_URL = "http://jigsaw.w3.org/css-validator/validator?uri=#{url}&warning=0&output=soap12";
- private static String HTML_VALIDATOR_URL = "https://validator.w3.org/check?uri=#{url}&output=json";
-
- private MarkEvaluation(Source document) {
- super(document);
- }
-
- private MarkEvaluation(Source document, String url) {
-
- super(document, url);
- }
-
- public static class MarkEvaluationBuilder extends EvaluationBuilder {
-
- @Override
- protected MarkEvaluation with(Source document) {
- return new MarkEvaluation(document);
- }
-
- @Override
- protected MarkEvaluation with(Source document, String url) {
- return new MarkEvaluation(document, url);
- }
-
- public SpecificRecommendation recommendation1() {
- return new EvaluationRecommendation1();
- }
-
- public SpecificRecommendation recommendation2() {
- return new EvaluationRecommendation2();
- }
-
- public SpecificRecommendation recommendation3() {
- return new EvaluationRecommendation3();
- }
-
- public SpecificRecommendation recommendation4() {
- return new EvaluationRecommendation4();
- }
-
- public SpecificRecommendation recommendation5() {
- return new EvaluationRecommendation5();
- }
-
- public SpecificRecommendation recommendation6() {
- return new EvaluationRecommendation6();
- }
-
- public SpecificRecommendation recommendation7() {
- return new EvaluationRecommendation7();
- }
-
- public SpecificRecommendation recommendation8() {
- return new EvaluationRecommendation8();
- }
-
- public SpecificRecommendation recommendation9() {
- return new EvaluationRecommendation9();
- }
- }
-
- protected static class EvaluationRecommendation1 extends MarkRecommendation {
- protected List check() {
- return getEvaluation().checkRecommendation1();
- }
- }
-
- protected static class EvaluationRecommendation2 extends MarkRecommendation {
- protected List check() {
- return getEvaluation().checkRecommendation2();
- }
- }
-
- protected static class EvaluationRecommendation3 extends MarkRecommendation {
- protected List check() {
- return getEvaluation().checkRecommendation3();
- }
- }
-
- protected static class EvaluationRecommendation4 extends MarkRecommendation {
- protected List check() {
- return getEvaluation().checkRecommendation4();
- }
- }
-
- protected static class EvaluationRecommendation5 extends MarkRecommendation {
- protected List check() {
- return getEvaluation().checkRecommendation5();
- }
- }
-
- protected static class EvaluationRecommendation6 extends MarkRecommendation {
- protected List check() {
- return getEvaluation().checkRecommendation6();
- }
- }
-
- protected static class EvaluationRecommendation7 extends MarkRecommendation {
- protected List check() {
- return getEvaluation().checkRecommendation7();
- }
- }
-
- protected static class EvaluationRecommendation8 extends MarkRecommendation {
- protected List check() {
- return getEvaluation().checkRecommendation8();
- }
- }
-
- protected static class EvaluationRecommendation9 extends MarkRecommendation {
- protected List check() {
- return getEvaluation().checkRecommendation9();
- }
- }
-
- public List check() {
- getOccurrences().addAll(checkRecommendation1());
- getOccurrences().addAll(checkRecommendation2());
- getOccurrences().addAll(checkRecommendation3());
- getOccurrences().addAll(checkRecommendation4());
- getOccurrences().addAll(checkRecommendation5());
- getOccurrences().addAll(checkRecommendation6());
- getOccurrences().addAll(checkRecommendation7());
- getOccurrences().addAll(checkRecommendation8());
- getOccurrences().addAll(checkRecommendation9());
-
- return getOccurrences();
- }
-
- private List checkRecommendation1() {
- List occurrences = new ArrayList();
-
- String url = getUrl();
- if (url != null) {
-
- int[] errosWarningsCss = getErrorCount(true, url);
- int[] errosWarningsHtml = getErrorCount(false, url);
- int avisoHtml = 0;
- int errosHtml = 0;
- int avisoCss = 0;
- int errosCss = 0;
-
-
- avisoHtml = errosWarningsHtml[1];
-
- if (avisoHtml > 0)
- {
- for(;avisoHtml > 0; avisoHtml--)
- {
- occurrences.add(buildOccurrence("1.1", false, url,
- getDocument().getFirstElement(), "7"));//"1"));
- }
- }
-
- /*if (errosWarningsHtml[1] > 0)
- System.out.println(errosWarningsHtml[1]);
-
- occurrences.add(buildOccurrence("1.1", false, url,
- getDocument().getFirstElement(), "1"));*/
-
- avisoCss = errosWarningsCss[1];
-
- if (avisoCss > 0)
- {
- for(;avisoCss > 0; avisoCss--)
- {
- occurrences.add(buildOccurrence("1.1", false, url,
- getDocument().getFirstElement().getFirstElement(), "8"));//"2"));
- }
- }
- /*if (errosWarningsCss[1] > 0)
- System.out.println(errosWarningsCss[1]);
- occurrences
- .add(buildOccurrence("1.1", false, url, getDocument()
- .getFirstElement().getFirstElement(), "2"));*/
-
- errosHtml = errosWarningsHtml[0];
-
- if (errosHtml > 0)
- {
- for(;errosHtml > 0; errosHtml--)
- {
- occurrences.add(buildOccurrence("1.1", true, url, getDocument()
- .getFirstElement(), "1"));
- }
- }
- /*if (errosWarningsHtml[0] > 0)
- System.out.println(errosWarningsHtml[0]);
- occurrences.add(buildOccurrence("1.1", true, url, getDocument()
- .getFirstElement(), "1"));*/
-
- errosCss = errosWarningsCss[0];
-
- if (errosCss > 0)
- {
- for(;errosCss > 0; errosCss--)
- {
- occurrences.add(buildOccurrence("1.1", true, url, getDocument()
- .getFirstElement().getFirstElement(), "2"));
- }
- }
- /*if (errosWarningsCss[0] > 0)
- System.out.println(errosWarningsCss[0]);
- occurrences.add(buildOccurrence("1.1", true, url, getDocument()
- .getFirstElement().getFirstElement(), "2"));*/
- }
-
- for (Element element : getDocument().getAllElements()) {
- String value = element.getAttributeValue("style");
-
- if (value != null)
- occurrences.add(this.buildOccurrence("1.1", false,
- element.toString(), element, "3"));
- }
-
- for (Element element : getDocument().getAllElements("style")) {
-
- if (element != null)
- occurrences.add(this.buildOccurrence("1.1", false,
- element.toString(), element, "4"));
- }
-
- List eventos = new ArrayList(Arrays.asList("onclick",
- "ondblclick"));
-
- for (Element element : getDocument().getAllElements()) {
- if (element.getAttributes() != null) {
- // String script =
- // element.getAttributes().getTextExtractor().toString();
- for (Attribute attribute : element.getAttributes()) {
- if (eventos.contains(attribute.getName()))
- occurrences.add(this.buildOccurrence("1.1", false,
- element.toString(), element, "5"));
- }
-
- /*
- * if(script.contains("javascript")){
- * occurrences.add(this.buildOccurrence("1.1", false,
- * element.toString(), element, "5")); }
- */
- }
- }
-
- for (Element element : getDocument().getAllElements("script")) {
-
- if (element != null) {
-
- if (!element.getContent().getTextExtractor().toString().trim()
- .equalsIgnoreCase("")) {
- occurrences.add(this.buildOccurrence("1.1", false,
- element.toString(), element, "6"));
-
- }
-
- }
- }
-
- this.oder(occurrences);
-
- return occurrences;
- }
-
- private boolean hasContent(Element elementoHTML) {
-
- boolean temConteudo;
-
-
- temConteudo = StringUtils.isNotBlank(elementoHTML.getContent().getTextExtractor().toString());
-
- if(!temConteudo)
- {
- for (Element elemento : elementoHTML.getAllElements()) {
- temConteudo = StringUtils.isNotBlank(elemento.getContent().getTextExtractor().toString());
-
- if(temConteudo)
- {
- break;
- }
- }
- }
- return temConteudo;
-
- }
-
- private List checkRecommendation2() {
- List occurrences = new ArrayList();
-
- List tags = Arrays.asList("h1", "h2", "h3", "h4", "h5", "h6",
- "a", "p","label");
- List linhasImg = new ArrayList();
-
- for (String tag : tags) {
- for (Element element : getDocument().getAllElements(tag)) {
-
- /*
- * if(element.getAttributes().getCount()==0)
- * occurrences.add(this.buildOccurrence("1.2", true,
- * element.toString(), element, "1")); else
- */
-
- if (element != null) {
- String endTag = element.getEndTag() == null ? "" : element
- .getEndTag().toString();
-
- Element img = element.getFirstElement("img");
-
- if (img != null) {
- if (img.getAttributes().get("alt") != null
- && img.getAttributes().get("alt").getValue()
- .isEmpty()) {
-
- if (!linhasImg.contains(this.getRow(img))) {
- occurrences.add(this.buildOccurrence("1.2",
- true, img.getStartTag().toString(),
- img, "3"));//"1"));
- }
- linhasImg.add(this.getRow(img));
- }
- } else {
-
- if (!hasContent(element)) {
- occurrences.add(this.buildOccurrence("1.2", true,
- element.toString(),
- element, "3"));//"1"));
- //element.getStartTag().toString() + endTag,
- //element, "3"));//"1"));
- }
- }
- }
- }
- }
-
- linhasImg = new ArrayList();
-
- tags = Arrays.asList("!doctype", "script", "meta", "style", "head",
- "link", "h1", "h2", "h3", "h4", "h5", "h6", "a", "p", "input");
-
- for (Element element : getDocument().getAllElements()) {
- if (!tags.contains(element.getName())) {
-
- if (element != null && !(element.getName().equals("!--"))) {
-
- String endTag = element.getEndTag() == null ? "" : element
- .getEndTag().toString();
-
- Element img = element.getFirstElement("img");
-
- if (img != null) {
- if (img.getAttributes().get("alt") != null
- && img.getAttributes().get("alt").getValue()
- .isEmpty()) {
-
- if (!linhasImg.contains(this.getRow(img))) {
- occurrences.add(this.buildOccurrence("1.2",
- false, img.toString(), img, "2")); //"1"));
- }
-
- linhasImg.add(this.getRow(img));
- }
-
- } else {
- if (!element.getStartTag().toString().replace(" ", "").equalsIgnoreCase("
") && !element.getStartTag().toString().replace(" ", "").equalsIgnoreCase("")) {
-
- if (!hasContent(element)) {
- occurrences.add(this.buildOccurrence("1.2",
- false, element.toString(), element, "2"));
- //+ endTag, element, "2"));//"1"));
- //element.getStartTag().toString()
- //+ endTag, element, "2"));//"1"));
- }
- }
- }
- }
- }
- }
-
- this.oder(occurrences);
-
- /*
- * boolean isError = false; for (Element element :
- * getDocument().getAllElements()) { Attributes attribute =
- * element.getAttributes();
- *
- * isError = tags.contains(element.getName());
- *
- *
- * if(element.isEmpty()) occurrences.add(this.buildOccurrence("1.2",
- * isError, element.toString(), element, "1")); else
- * if(attribute.getCount()==0)
- * occurrences.add(this.buildOccurrence("1.2", isError,
- * element.toString(), element, "1")); }
- */
-
- return occurrences;
- }
-
- private List checkRecommendation3() {
-
- // CRITERIO 4
- List occurrences = new ArrayList();
-
- int count = getDocument().getAllElements("h1").size();
-
- if (count > 1) {
- for (Element element : getDocument().getAllElements("h1")) {
-
- occurrences.add(this.buildOccurrence("1.3", true,
- element.toString(), element, "6"));//"4"));
- }
- }
-
- /*
- * if(count>0) occurrences.add(this.buildOccurrence("1.3",
- * true,getDocument().getFirstElement("h1").toString(),
- * getDocument().getFirstElement("h1"), "4"));
- */
-
- // CRITERIO 3
- boolean hasOtherH = false;
- for (Element element : getDocument().getAllElements()) {
- if (element.getName().matches("h[2-6]")) {
- hasOtherH = true;
- break;
- }
- }
-
- if (count > 0 && !hasOtherH)
- occurrences.add(this.buildOccurrence("1.3", false, getDocument()
- .getFirstElement("h1").toString(), getDocument()
- .getFirstElement("h1"), "4"));//"3"));
-
- // CRITERIO 2
-
- /*
- * String[] tags = {"h6","h5","h4","h3","h2","h1"}; //String[] tags =
- * {"h1","h2","h3","h4","h5","h6"};
- *
- *
- * for(int index = 0 ; index< tags.length ; index++){
- *
- * for(Element h : getDocument().getAllElements(tags[index])) {
- * if(!hasCorrectHierarchy(index, tags))
- * occurrences.add(this.buildOccurrence("1.3", true,h.toString(), h,
- * "2")); } }
- */
-
- List elementsObj = getDocument().getAllElements();
-
- int anterior = 0;
- for (Element htmlElement : elementsObj) {
- if (htmlElement.getName().matches("h[1-6]")) {
- int tagId = Integer.parseInt(htmlElement.getName().substring(1));
- if (!(tagId <= anterior)) {
- if (!(tagId -1 == anterior))
- {
- occurrences.add(this.buildOccurrence("1.3", true,
- htmlElement.toString(), htmlElement, "2"));
- }
-
- }
- anterior = tagId;
-
-
- }
- }
-
-
-
- if (!hasH())
- occurrences.add(this.buildOccurrence("1.3", true, "Observação - Sem fonte (os níveis de título não foram utilizados)",
- getDocument().getFirstElement(), "1"));
-
- // Sorting
- Collections.sort(occurrences, new Comparator() {
- public int compare(Occurrence occurrence1, Occurrence occurrence2) {
- return occurrence1.getLine().compareTo(occurrence2.getLine());
- }
- });
-
- return occurrences;
- }
-
- private int verificarNiveis(Integer posicao, List tags) {
- for (int i = 0; i < posicao; i++) {
- if (Integer.parseInt(tags.get(i).substring(1)) == Integer
- .parseInt(tags.get(posicao).substring(1)) - 1) {
- return Integer.parseInt(tags.get(i).substring(1));
- }
- }
- return -1;
- }
-
- private boolean hasCorrectHierarchy(int index, String[] tags) {
-
- for (int i = index + 1; i < tags.length; i++) {
- if (getDocument().getFirstElement(tags[i]) == null)
- return false;
- }
- return true;
- }
-
- private boolean hasH() {
-
- String[] tags = { "h6", "h5", "h4", "h3", "h2", "h1" };
- for (String h : tags) {
- if (getDocument().getFirstElement(h) != null)
- return true;
- }
-
- return false;
- }
-
- /* No documento NÃO PERMITE VERIFICAÇÃO AUTOMATIZADA */
- private List checkRecommendation4() {
- List occurrences = new ArrayList();
-
- for (Element link : this.getDocument().getAllElements("a")) {
- Attribute tabIndex = link.getAttributes().get("tabindex");
- if (tabIndex != null) {
- occurrences.add(this.buildOccurrence("1.4", false,
- link.toString(), link, "3"));//"2"));
-
- if (rangeIncorretoTabeIndex(tabIndex))
- occurrences.add(this.buildOccurrence("1.4", false,
- link.toString(), link, "6"));//"3"));
- }
- }
-
- for (Element input : this.getDocument().getAllElements("input")) {
-
- Attribute tabIndex = input.getAttributes().get("tabindex");
- if (tabIndex != null)
- occurrences.add(this.buildOccurrence("1.4", false,
- input.toString(), input, "3"));//"2"));
-
- if (rangeIncorretoTabeIndex(tabIndex))
- occurrences.add(this.buildOccurrence("1.4", false,
- input.toString(), input, "6"));//"3"));
- }
-
- for (Element select : this.getDocument().getAllElements("select")) {
-
- Attribute tabIndex = select.getAttributes().get("tabindex");
- if (tabIndex != null)
- occurrences.add(this.buildOccurrence("1.4", false,
- select.toString(), select, "3"));//"2"));
-
- if (rangeIncorretoTabeIndex(tabIndex))
- occurrences.add(this.buildOccurrence("1.4", false,
- select.toString(), select, "6"));//"3"));
- }
-
- for (Element textarea : this.getDocument().getAllElements("textarea")) {
-
- Attribute tabIndex = textarea.getAttributes().get("tabindex");
- if (tabIndex != null)
- occurrences.add(this.buildOccurrence("1.4", false,
- textarea.toString(), textarea, "3"));//"2"));
-
- if (rangeIncorretoTabeIndex(tabIndex))
- occurrences.add(this.buildOccurrence("1.4", false,
- textarea.toString(), textarea, "6"));//"3"));
- }
-
- /*
- * Element section = this.getDocument().getFirstElement("section");
- *
- * if(section !=null){
- *
- * int firstSectionRow = this.getRow(section); for(Element nav :
- * this.getDocument().getAllElements("nav")){ if(this.getRow(nav) <
- * firstSectionRow) occurrences.add(this.buildOccurrence("1.4",
- * false,nav.toString(), nav, "1")); } }
- */
-
- List verificadsos = new ArrayList();
- for (Element nav : this.getDocument().getAllElements("nav")) {
- if (nav != null) {
- int firstNavRow = this.getRow(nav);
-
- for (Element section : this.getDocument().getAllElements(
- "section")) {
-
- if (firstNavRow < this.getRow(section)) {
- if (!verificadsos.contains(this.getRow(section))) {
- occurrences.add(this.buildOccurrence("1.4", false,
- section.getStartTag().toString(), section,
- "1"));
- verificadsos.add(this.getRow(section));
- }
-
- }
- }
- }
- }
-
- return occurrences;
- }
-
- private boolean rangeIncorretoTabeIndex(Attribute tabIndex) {
- try {
- Integer value = Integer.valueOf(tabIndex.getValue());
- if (value < 0 || value > 32767)
- return true;
- } catch (Exception e) {
- return false;
- }
- return false;
- }
-
- private List checkRecommendation5() {
- List occurrences = new ArrayList();
-
- /*
- * Element firstLink = getDocument().getFirstElement("href",
- * Pattern.compile("#.*"));
- *
- * if(firstLink != null) occurrences.add(this.buildOccurrence("1.5",
- * false, firstLink.toString(), firstLink, "4"));
- */
-
- for (Element link : getDocument().getAllElements("a")) {
- String contLink = link.getAttributeValue("href");
- if (contLink != null && contLink.length() > 1
- && !contLink.substring(0, 1).equals("#")) {
- occurrences.add(this.buildOccurrence("1.5", true,
- link.toString(), link, "9"));//"4"));
- }
-
- break;
- }
-
- /*
- * if(firstLink == null){ occurrences.add(this.buildOccurrence("1.5",
- * false, getDocument().getFirstElement().toString(),
- * getDocument().getFirstElement(), "4")); } else
- * if(firstLink.getAttributeValue("href") == null ||
- * !firstLink.getAttributeValue("href").contains("#")){
- * occurrences.add(this.buildOccurrence("1.5", false,
- * firstLink.toString(), firstLink, "4")); }
- */
-
- boolean existAcessKey = false;
-
- for (Element area : getDocument().getAllElements("area")) {
- if (hasAcessKey(area))
- existAcessKey = true;
- /*
- * if(!hasAcessKey(area))
- * occurrences.add(this.buildOccurrence("1.5", true,
- * area.toString(), area, "3"));
- */
- }
-
- if (!existAcessKey)
- for (Element button : getDocument().getAllElements("button")) {
- if (hasAcessKey(button))
- existAcessKey = true;
- /*
- * if(!hasAcessKey(button))
- * occurrences.add(this.buildOccurrence("1.5", true,
- * button.toString(), button, "3"));
- */
- }
-
- if (!existAcessKey)
- for (Element input : getDocument().getAllElements("input")) {
- if (hasAcessKey(input))
- existAcessKey = true;
- /*
- * if(!hasAcessKey(input))
- * occurrences.add(this.buildOccurrence("1.5", true,
- * input.toString(), input, "3"));
- */
- }
-
- if (!existAcessKey)
- for (Element label : getDocument().getAllElements("label")) {
- if (hasAcessKey(label))
- existAcessKey = true;
- /*
- * if(!hasAcessKey(label))
- * occurrences.add(this.buildOccurrence("1.5", true,
- * label.toString(), label, "3"));
- */
- }
-
- if (!existAcessKey)
- for (Element legend : getDocument().getAllElements("legend")) {
- if (hasAcessKey(legend))
- existAcessKey = true;
- /*
- * if(!hasAcessKey(legend))
- * occurrences.add(this.buildOccurrence("1.5", true,
- * legend.toString(), legend, "3"));
- */
- }
-
- if (!existAcessKey)
- for (Element textarea : getDocument().getAllElements("textarea")) {
- if (hasAcessKey(textarea))
- existAcessKey = true;
- /*
- * if(!hasAcessKey(textarea))
- * occurrences.add(this.buildOccurrence("1.5", true,
- * textarea.toString(), textarea, "3"));
- */
- }
-
- String href;
- boolean existAnchor = false;
-
- for (Element link : getDocument().getAllElements("a")) {
- href = link.getAttributeValue("href");
-
- /*
- * if(href != null && (href.length() > 1 &&
- * !href.substring(0,2).equals("?#"))){
- * ///occurrences.add(this.buildOccurrence("1.5", true,
- * link.toString(), link, "2")); if(!(href.length()==1 &&
- * href.substring(1).equals("#"))) if(href.substring(1).equals("#")
- * && !this.hasLinkSemAncora(href))
- * occurrences.add(this.buildOccurrence("1.5", true,
- * link.toString(), link, "2")); }
- */
-
- if (href != null && href.length() > 1
- && !href.substring(0, 2).equals("?#")) {
- if (href.substring(0, 1).equals("#"))
- if (!this.hasLinkRefAncora(link))
- occurrences.add(this.buildOccurrence("1.5", true,
- link.toString(), link, "2"));
- }
-
- /*
- * if(href != null && href.contains("#"))
- * if(!hasAnchor(href.substring(1)))
- * occurrences.add(this.buildOccurrence("1.5", true,
- * link.toString(), link, "2"));
- */
- /*
- * }else{ occurrences.add(this.buildOccurrence("1.5", true,
- * link.toString(), link, "1")); }
- */
-
- // if(href != null && href.contains("#"))
-
- /*
- * if(href != null && href.length() == 1 &&
- * href.toString().equals("#")) existAnchor = true;
- */
- if (href != null && href.contains("#"))
- existAnchor = true;
-
- if (hasAcessKey(link))
- existAcessKey = true;
-
- /*
- * if(!hasAcessKey(link))
- * occurrences.add(this.buildOccurrence("1.5", true,
- * link.toString(), link, "3"));
- */
- }
-
- if (!existAnchor)
- occurrences
- .add(this
- .buildOccurrence(
- "1.5",
- true,
- "Observação - Sem fonte (não foram encontrados âncoras que permitam saltar pelas diferentes seções da página)",
- getDocument().getFirstElement(), "1"));
-
- if (!existAcessKey)
- occurrences
- .add(this
- .buildOccurrence(
- "1.5",
- true,
- "Observação - Sem fonte ( não existe(m) accesskey(s) na página)",
- getDocument().getFirstElement(), "4"));//"3"));
-
- for (Element elemento : getDocument().getAllElements("accesskey",
- Pattern.compile(".*"))) {
- if (duplicatedAcessKey(elemento))
- occurrences.add(this.buildOccurrence("1.5", false,
- elemento.toString(), elemento, "11"));//"5"));
- }
-
- this.oder(occurrences);
-
- return occurrences;
- }
-
- private boolean hasLinkRefAncora(Element link) {
- boolean existeAncora = false;
- String href = link.getAttributeValue("href");
- String ancora = href.substring(1, href.length());
-
- for (Element a : getDocument().getAllElements()) {
- if (a.getAttributeValue("id") != null
- && a.getAttributeValue("id").equals(ancora)) {
- existeAncora = true;
- }
- if (a.getAttributeValue("name") != null
- && a.getAttributeValue("name").equals(ancora)) {
- existeAncora = true;
- }
- }
-
- return existeAncora;
- }
-
- private boolean hasAcessKey(Element element) {
- String acessKey = element.getAttributeValue("accesskey");
-
- return StringUtils.isNotBlank(acessKey);
- }
-
- private boolean hasAnchor(String href) {
-
- String id, name;
-
- for (Element element : getDocument().getAllElements()) {
- id = element.getAttributeValue("id");
- name = element.getAttributeValue("name");
-
- if (href.equals(id) || href.equals(name))
- return true;
- }
-
- return false;
- }
-
- private boolean duplicatedAcessKey(Element element) {
- String value = element.getAttributeValue("accesskey");
-
- for (Element elementToCompare : getDocument().getAllElements(
- "accesskey", Pattern.compile(".*"))) {
- String acessKey = elementToCompare.getAttributeValue("accesskey");
- if (acessKey.equals(value)
- && elementToCompare.getBegin() != element.getBegin())
- return true;
-
- }
-
- return false;
- }
-
- public List checkRecommendation6() {
- List occurrences = new ArrayList();
-
- for (Element table : getDocument().getAllElements("table"))
- occurrences.add(this.buildOccurrence("1.6", false, table
- .getStartTag().toString(), table, "1"));
-
- int firstFormRow = 0;
-
- List linhasOcorrForm = new ArrayList();
-
- for (Element table : getDocument().getAllElements("table")) {
- // Element tagsForm = table.getFirstElement("form");
-
- Element form = table.getContent().getFirstElement("form");
-
- if (form != null) {
- firstFormRow = this.getRow(form);
- if (!linhasOcorrForm.contains(firstFormRow)) {
- occurrences.add(this.buildOccurrence("1.6", true, form
- .getStartTag().toString(), form, "2"));
- linhasOcorrForm.add(firstFormRow);
- }
- }
-
- }
-
- return occurrences;
- }
-
- public List checkRecommendation7() {
- List occurrences = new ArrayList();
- List element = getDocument().getAllElements();
-
- int pos = 1;
- int end = 0;
- int begin = 0;
- Element firstElement = null;
- Element secondElement = null;
- for (int i = 0; i < element.size() - 1; i++) {
- firstElement = element.get(i);
- secondElement = element.get(pos);
- if (firstElement.getEndTag() != null
- && firstElement.getName().equals("a"))
- end = firstElement.getEndTag().getEnd();
- begin = secondElement.getStartTag().getBegin();
- if (element.get(i).getName().equals(element.get(pos).getName())
- && (end == begin)) {
- occurrences.add(this.buildOccurrence("1.7", true, element
- .get(i).toString() + " " + element.get(pos).toString(),
- element.get(i), "1"));
- }
- pos++;
- }
-
- return occurrences;
- }
-
-
- public List checkRecommendation8() {
- List occurrences = new ArrayList();
- Element firstElement = this.getDocument().getFirstElement();
-
- if (firstElement.toString().replace(" ", "").equalsIgnoreCase("")) {
-
- Element header = getDocument().getFirstElement("header");
- Element nav = getDocument().getFirstElement("nav");
- Element section = getDocument().getFirstElement("section");
- Element footer = getDocument().getFirstElement("footer");
-
- if (header == null)
- occurrences.add(this.buildOccurrence("1.8",false,"Observação - Sem fonte (Não existe tag )",
- getDocument().getFirstElement(), "3"));//"1"));
-
- if (nav == null)
- occurrences.add(this.buildOccurrence("1.8",false,"Observação - Sem fonte (Não existe tag