Chromium Code Reviews| Index: java/org/chromium/distiller/webdocument/WebTag.java |
| diff --git a/java/org/chromium/distiller/webdocument/WebTag.java b/java/org/chromium/distiller/webdocument/WebTag.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7ea05df7701b64467da08f72fe2878ea237dbf38 |
| --- /dev/null |
| +++ b/java/org/chromium/distiller/webdocument/WebTag.java |
| @@ -0,0 +1,44 @@ |
| +package org.chromium.distiller.webdocument; |
| + |
| +import java.util.Arrays; |
| +import java.util.List; |
| + |
| +/** |
| + * This class represents HTML tags that need to be preserved over the |
| + * distillation process. |
| + */ |
| +public class WebTag extends WebElement { |
| + private String tagName; |
| + private TagType tagType; |
| + |
| + public enum TagType { |
| + START, END |
| + } |
| + |
| + 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
|
| + |
| + public WebTag(String tagName, TagType tagType) { |
| + this.tagName = tagName; |
| + this.tagType = tagType; |
| + } |
| + |
| + public boolean isStartTag() { |
| + return tagType == TagType.START; |
| + } |
| + |
| + public String getTagName() { |
| + return tagName; |
| + } |
| + |
| + @Override |
| + public String generateOutput(boolean textOnly) { |
| + if (textOnly) { |
| + return ""; |
| + } |
| + return "<" + (isStartTag() ? "" : "/") + tagName + ">"; |
| + } |
| + |
| + public static boolean canBeNested(String tagName) { |
| + return canBeNestedTags.contains(tagName); |
| + } |
| +} |