From e6d897d3c02274337dfe2b7a7eb7ca27900854c1 Mon Sep 17 00:00:00 2001 From: gibran Date: Fri, 22 Apr 2016 16:21:10 -0300 Subject: [PATCH] criação de função para retornar o título da página avaliada. --- src/main/java/br/com/checker/emag/core/ContentEvaluation.java | 59 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 21 deletions(-) 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 858170b..335acfc 100644 --- a/src/main/java/br/com/checker/emag/core/ContentEvaluation.java +++ b/src/main/java/br/com/checker/emag/core/ContentEvaluation.java @@ -26,7 +26,7 @@ import br.com.checker.emag.core.SpecificRecommendation.ContentRecommendation; public class ContentEvaluation extends Evaluation { - private ContentEvaluation(Source document) { + public ContentEvaluation(Source document) { super(document); } @@ -294,6 +294,21 @@ public class ContentEvaluation extends Evaluation { return occurrences; } + public String retornarTituloSiteAvaliado() { + + Element titulo = getDocument().getFirstElement("title"); + + String titulo_site = ""; + + if (titulo != null) { + titulo_site = titulo.getContent().getTextExtractor().toString(); + } + + return titulo_site; + + + } + private List checkRecommendation19() { List occurrences = new ArrayList(); @@ -410,12 +425,14 @@ public class ContentEvaluation extends Evaluation { && !link.getAttributeValue("href").substring(0, 1).equals("/") && !link.getAttributeValue("href").contains("javascript")) { - /*int[] codErro = { 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, - 410, 411, 412, 414, 415, 416, 417, 418, 422, 423, 424, 425, - 426, 450, 499, 500, 501, 502, 503, 504, 505 };*/ + /* + * int[] codErro = { 400, 401, 402, 403, 404, 405, 406, 407, 408, + * 409, 410, 411, 412, 414, 415, 416, 417, 418, 422, 423, 424, 425, + * 426, 450, 499, 500, 501, 502, 503, 504, 505 }; + */ int codResponse = 0; - - int[] codErro = {404}; + + int[] codErro = { 404 }; String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]+$"; @@ -447,12 +464,11 @@ public class ContentEvaluation extends Evaluation { * if(huc.getResponseCode() != HttpURLConnection.HTTP_OK) * System.out.println(link.toString()); */ - for (int cod : codErro) - { + for (int cod : codErro) { if (codResponse == cod) { return true; } - + } } @@ -820,7 +836,7 @@ public class ContentEvaluation extends Evaluation { occurrences.add(buildOccurrence("3.9", false, table .getStartTag().toString(), table, "1")); } - + if (table.getAllElements("caption").isEmpty() || table.getAllElements("caption") == null) occurrences.add(buildOccurrence("3.9", false, table @@ -839,16 +855,15 @@ public class ContentEvaluation extends Evaluation { * table, "1")); } */ - /*for (Element table : getDocument().getAllElements("table")) { - for (Element caption : table.getAllElements("caption")) { - if (caption == null || caption.isEmpty()) - occurrences.add(buildOccurrence("3.10", true, table - .getStartTag().toString(), table, "1")); - } - }*/ + /* + * for (Element table : getDocument().getAllElements("table")) { for + * (Element caption : table.getAllElements("caption")) { if (caption == + * null || caption.isEmpty()) occurrences.add(buildOccurrence("3.10", + * true, table .getStartTag().toString(), table, "1")); } } + */ for (Element table : getDocument().getAllElements("table")) { - //Attribute summary = table.getAttributes().get("summary"); + // Attribute summary = table.getAttributes().get("summary"); boolean THusaScope = false; boolean THusaId = false; @@ -860,9 +875,11 @@ public class ContentEvaluation extends Evaluation { boolean usaTfoot = false; boolean usaTbody = false; - /*if (summary == null || summary.getValue().equals("")) - occurrences.add(buildOccurrence("3.10", true, table - .getStartTag().toString(), table, "1"));*/ + /* + * if (summary == null || summary.getValue().equals("")) + * occurrences.add(buildOccurrence("3.10", true, table + * .getStartTag().toString(), table, "1")); + */ for (Element thead : table.getAllElements("thead")) { if (thead != null) -- libgit2 0.21.2