Commit e6d897d3c02274337dfe2b7a7eb7ca27900854c1

Authored by gibran
1 parent 3001fef4

criação de função para retornar o título da página avaliada.

src/main/java/br/com/checker/emag/core/ContentEvaluation.java
... ... @@ -26,7 +26,7 @@ import br.com.checker.emag.core.SpecificRecommendation.ContentRecommendation;
26 26  
27 27 public class ContentEvaluation extends Evaluation {
28 28  
29   - private ContentEvaluation(Source document) {
  29 + public ContentEvaluation(Source document) {
30 30 super(document);
31 31 }
32 32  
... ... @@ -294,6 +294,21 @@ public class ContentEvaluation extends Evaluation {
294 294 return occurrences;
295 295 }
296 296  
  297 + public String retornarTituloSiteAvaliado() {
  298 +
  299 + Element titulo = getDocument().getFirstElement("title");
  300 +
  301 + String titulo_site = "";
  302 +
  303 + if (titulo != null) {
  304 + titulo_site = titulo.getContent().getTextExtractor().toString();
  305 + }
  306 +
  307 + return titulo_site;
  308 +
  309 +
  310 + }
  311 +
297 312 private List<Occurrence> checkRecommendation19() {
298 313 List<Occurrence> occurrences = new ArrayList<Occurrence>();
299 314  
... ... @@ -410,12 +425,14 @@ public class ContentEvaluation extends Evaluation {
410 425 && !link.getAttributeValue("href").substring(0, 1).equals("/")
411 426 && !link.getAttributeValue("href").contains("javascript")) {
412 427  
413   - /*int[] codErro = { 400, 401, 402, 403, 404, 405, 406, 407, 408, 409,
414   - 410, 411, 412, 414, 415, 416, 417, 418, 422, 423, 424, 425,
415   - 426, 450, 499, 500, 501, 502, 503, 504, 505 };*/
  428 + /*
  429 + * int[] codErro = { 400, 401, 402, 403, 404, 405, 406, 407, 408,
  430 + * 409, 410, 411, 412, 414, 415, 416, 417, 418, 422, 423, 424, 425,
  431 + * 426, 450, 499, 500, 501, 502, 503, 504, 505 };
  432 + */
416 433 int codResponse = 0;
417   -
418   - int[] codErro = {404};
  434 +
  435 + int[] codErro = { 404 };
419 436  
420 437 String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]+$";
421 438  
... ... @@ -447,12 +464,11 @@ public class ContentEvaluation extends Evaluation {
447 464 * if(huc.getResponseCode() != HttpURLConnection.HTTP_OK)
448 465 * System.out.println(link.toString());
449 466 */
450   - for (int cod : codErro)
451   - {
  467 + for (int cod : codErro) {
452 468 if (codResponse == cod) {
453 469 return true;
454 470 }
455   -
  471 +
456 472 }
457 473 }
458 474  
... ... @@ -820,7 +836,7 @@ public class ContentEvaluation extends Evaluation {
820 836 occurrences.add(buildOccurrence("3.9", false, table
821 837 .getStartTag().toString(), table, "1"));
822 838 }
823   -
  839 +
824 840 if (table.getAllElements("caption").isEmpty()
825 841 || table.getAllElements("caption") == null)
826 842 occurrences.add(buildOccurrence("3.9", false, table
... ... @@ -839,16 +855,15 @@ public class ContentEvaluation extends Evaluation {
839 855 * table, "1")); }
840 856 */
841 857  
842   - /*for (Element table : getDocument().getAllElements("table")) {
843   - for (Element caption : table.getAllElements("caption")) {
844   - if (caption == null || caption.isEmpty())
845   - occurrences.add(buildOccurrence("3.10", true, table
846   - .getStartTag().toString(), table, "1"));
847   - }
848   - }*/
  858 + /*
  859 + * for (Element table : getDocument().getAllElements("table")) { for
  860 + * (Element caption : table.getAllElements("caption")) { if (caption ==
  861 + * null || caption.isEmpty()) occurrences.add(buildOccurrence("3.10",
  862 + * true, table .getStartTag().toString(), table, "1")); } }
  863 + */
849 864  
850 865 for (Element table : getDocument().getAllElements("table")) {
851   - //Attribute summary = table.getAttributes().get("summary");
  866 + // Attribute summary = table.getAttributes().get("summary");
852 867  
853 868 boolean THusaScope = false;
854 869 boolean THusaId = false;
... ... @@ -860,9 +875,11 @@ public class ContentEvaluation extends Evaluation {
860 875 boolean usaTfoot = false;
861 876 boolean usaTbody = false;
862 877  
863   - /*if (summary == null || summary.getValue().equals(""))
864   - occurrences.add(buildOccurrence("3.10", true, table
865   - .getStartTag().toString(), table, "1"));*/
  878 + /*
  879 + * if (summary == null || summary.getValue().equals(""))
  880 + * occurrences.add(buildOccurrence("3.10", true, table
  881 + * .getStartTag().toString(), table, "1"));
  882 + */
866 883  
867 884 for (Element thead : table.getAllElements("thead")) {
868 885 if (thead != null)
... ...