OLD | NEW |
---|---|
(Empty) | |
1 package org.chromium.distiller.webdocument; | |
2 | |
3 import java.util.Arrays; | |
4 import java.util.List; | |
5 | |
6 /** | |
7 * This class represents HTML tags that need to be preserved over the | |
8 * distillation process. | |
9 */ | |
10 public class WebTag extends WebElement { | |
11 private String tagName; | |
12 private TagType tagType; | |
13 | |
14 public enum TagType { | |
15 START, END | |
16 } | |
17 | |
18 private static List<String> canBeNestedTags = Arrays.asList("UL", "OL", "LI" ); | |
mdjones
2015/08/06 15:26:20
Why not Set/HashSet? The TableClassifier and Embed
| |
19 | |
20 public WebTag(String tagName, TagType tagType) { | |
21 this.tagName = tagName; | |
22 this.tagType = tagType; | |
23 } | |
24 | |
25 public boolean isStartTag() { | |
26 return tagType == TagType.START; | |
27 } | |
28 | |
29 public String getTagName() { | |
30 return tagName; | |
31 } | |
32 | |
33 @Override | |
34 public String generateOutput(boolean textOnly) { | |
35 if (textOnly) { | |
36 return ""; | |
37 } | |
38 return "<" + (isStartTag() ? "" : "/") + tagName + ">"; | |
39 } | |
40 | |
41 public static boolean canBeNested(String tagName) { | |
42 return canBeNestedTags.contains(tagName); | |
43 } | |
44 } | |
OLD | NEW |