Commit 3d82a89ca9c31e8e98809c8972e71c2d9c49c216
1 parent
911a29ad
Exists in
master
and in
1 other branch
Correção da recomendação 1.2.2 e 1.2.3
Showing
1 changed file
with
34 additions
and
12 deletions
Show diff stats
src/main/java/br/com/checker/emag/core/MarkEvaluation.java
... | ... | @@ -17,6 +17,8 @@ import org.apache.commons.lang3.StringUtils; |
17 | 17 | import org.w3c.dom.Document; |
18 | 18 | |
19 | 19 | |
20 | + | |
21 | + | |
20 | 22 | import br.com.checker.emag.Occurrence; |
21 | 23 | import br.com.checker.emag.OccurrenceClassification; |
22 | 24 | import br.com.checker.emag.core.SpecificRecommendation.MarkRecommendation; |
... | ... | @@ -193,7 +195,7 @@ public class MarkEvaluation extends Evaluation { |
193 | 195 | if (avisoCss > 0) |
194 | 196 | { |
195 | 197 | for(;avisoCss > 0; avisoCss--) |
196 | - { | |
198 | + { | |
197 | 199 | occurrences.add(buildOccurrence("1.1", false, url, |
198 | 200 | getDocument().getFirstElement().getFirstElement(), "8"));//"2")); |
199 | 201 | } |
... | ... | @@ -290,7 +292,27 @@ public class MarkEvaluation extends Evaluation { |
290 | 292 | return occurrences; |
291 | 293 | } |
292 | 294 | |
293 | - | |
295 | + private boolean hasContent(Element elementoHTML) { | |
296 | + | |
297 | + boolean temConteudo; | |
298 | + | |
299 | + | |
300 | + temConteudo = StringUtils.isNotBlank(elementoHTML.getContent().getTextExtractor().toString()); | |
301 | + | |
302 | + if(!temConteudo) | |
303 | + { | |
304 | + for (Element elemento : elementoHTML.getAllElements()) { | |
305 | + temConteudo = StringUtils.isNotBlank(elemento.getContent().getTextExtractor().toString()); | |
306 | + | |
307 | + if(temConteudo) | |
308 | + { | |
309 | + break; | |
310 | + } | |
311 | + } | |
312 | + } | |
313 | + return temConteudo; | |
314 | + | |
315 | + } | |
294 | 316 | |
295 | 317 | private List<Occurrence> checkRecommendation2() { |
296 | 318 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
... | ... | @@ -307,7 +329,7 @@ public class MarkEvaluation extends Evaluation { |
307 | 329 | * occurrences.add(this.buildOccurrence("1.2", true, |
308 | 330 | * element.toString(), element, "1")); else |
309 | 331 | */ |
310 | - | |
332 | + | |
311 | 333 | if (element != null) { |
312 | 334 | String endTag = element.getEndTag() == null ? "" : element |
313 | 335 | .getEndTag().toString(); |
... | ... | @@ -328,12 +350,12 @@ public class MarkEvaluation extends Evaluation { |
328 | 350 | } |
329 | 351 | } else { |
330 | 352 | |
331 | - if (element.getContent().toString().isEmpty() | |
332 | - || element.getContent().toString().trim() | |
333 | - .equals("")) { | |
353 | + if (!hasContent(element)) { | |
334 | 354 | occurrences.add(this.buildOccurrence("1.2", true, |
335 | - element.getStartTag().toString() + endTag, | |
355 | + element.toString(), | |
336 | 356 | element, "3"));//"1")); |
357 | + //element.getStartTag().toString() + endTag, | |
358 | + //element, "3"));//"1")); | |
337 | 359 | } |
338 | 360 | } |
339 | 361 | } |
... | ... | @@ -371,12 +393,12 @@ public class MarkEvaluation extends Evaluation { |
371 | 393 | } else { |
372 | 394 | if (!element.getStartTag().toString().replace(" ", "").equalsIgnoreCase("<br>") && !element.getStartTag().toString().replace(" ", "").equalsIgnoreCase("</br>")) { |
373 | 395 | |
374 | - if (element.getContent().toString().isEmpty() | |
375 | - || element.getContent().toString().trim() | |
376 | - .equals("")) { | |
396 | + if (!hasContent(element)) { | |
377 | 397 | occurrences.add(this.buildOccurrence("1.2", |
378 | - false, element.getStartTag().toString() | |
379 | - + endTag, element, "2"));//"1")); | |
398 | + false, element.toString(), element, "2")); | |
399 | + //+ endTag, element, "2"));//"1")); | |
400 | + //element.getStartTag().toString() | |
401 | + //+ endTag, element, "2"));//"1")); | |
380 | 402 | } |
381 | 403 | } |
382 | 404 | } | ... | ... |