TagName.java

1
package com.renomad.minum.htmlparsing;
2
3
4
import java.util.*;
5
6
/**
7
 * Possible tag names per the W3C HTML spec.
8
 * Pulled from <a href="https://www.w3.org/TR/2012/WD-html-markup-20121025/elements.html">The W3C spec</a>
9
 */
10
public enum TagName {
11
    A(false), ABBR(false), ADDRESS(false), AREA(true), ARTICLE(false),
12
    ASIDE(false), AUDIO(false), B(false), BASE(true), BDI(false),
13
    BDO(false), BLOCKQUOTE(false), BODY(false), BR(true), BUTTON(false), CANVAS(false),
14
    CAPTION(false), CITE(false), CODE(false), COL(true), COLGROUP(false),
15
    COMMAND(true), DATALIST(false), DD(false), DEL(false), DETAILS(false),
16
    DFN(false), DIV(false), DL(false), DT(false), EM(false), EMBED(true),
17
    FIELDSET(false), FIGCAPTION(false), FIGURE(false), FOOTER(false),
18
    FORM(false), H1(false), H2(false), H3(false), H4(false), H5(false),
19
    H6(false), HEAD(false), HEADER(false), HGROUP(false), HR(true),
20
    HTML(false), I(false), IFRAME(false), IMG(true), INPUT(true),
21
    INS(false), KBD(false), KEYGEN(true), LABEL(false), LEGEND(false),
22
    LI(false), LINK(true), MAP(false), MARK(false), MENU(false),
23
    META(true), METER(false), NAV(false), NOSCRIPT(false), OBJECT(false),
24
    OL(false), OPTGROUP(false), OPTION(false), OUTPUT(false), P(false),
25
    PARAM(true), PRE(false), PROGRESS(false), Q(false), RP(false),
26
    RT(false), RUBY(false), S(false), SAMP(false), SCRIPT(false),
27
    SECTION(false), SELECT(false), SMALL(false), SOURCE(true),
28
    SPAN(false), STRONG(false), STYLE(false), SUB(false), SUMMARY(false),
29
    SUP(false), TABLE(false), TBODY(false), TD(false), TEMPLATE(false), TEXTAREA(false),
30
    TFOOT(false), TH(false), THEAD(false), TIME(false), TITLE(false),
31
    TR(false), TRACK(true), U(false), UL(false), VAR(false), VIDEO(false),
32
    WBR(true),SVG(false),MATH(false),
33
34
    /**
35
     * In HTML, the doctype is the required preamble found at the top of
36
     * all documents. Its sole purpose is to prevent a browser from
37
     * switching into so-called "quirks mode" when rendering a document;
38
     * that is, it ensures that the browser makes a best-effort attempt at
39
     * following the relevant specifications, rather than using a
40
     * different rendering mode that is incompatible with some specifications.
41
     */
42
     DOCTYPE(true),
43
44
45
    /**
46
     * A special tag, meant for cases where we are scanning through unfamiliar
47
     * namespaces, like svg or math.
48
     */
49
    UNRECOGNIZED(false),
50
51
    /**
52
     * Used to indicate no tag
53
     */
54
    NULL(false)
55
    ;
56
57
    /**
58
     * Void elements are disallowed to have closing tags
59
     */
60
    public final boolean isVoidElement;
61
62
    /**
63
     * If this is a void element, then it is disallowed to have
64
     * a closing tag.  (see <a href="https://www.w3.org/TR/2011/WD-html-markup-20110113/syntax.html#void-element">void elements</a>)
65
     */
66
    TagName(boolean isVoidElement) {
67
        this.isVoidElement = isVoidElement;
68
    }
69
70
    public static TagName findMatchingTagname(String tagNameString) {
71
        String capitalizedTagNameString = tagNameString.toUpperCase(Locale.ROOT);
72 2 1. lambda$findMatchingTagname$0 : replaced boolean return with false for com/renomad/minum/htmlparsing/TagName::lambda$findMatchingTagname$0 → KILLED
2. lambda$findMatchingTagname$0 : replaced boolean return with true for com/renomad/minum/htmlparsing/TagName::lambda$findMatchingTagname$0 → KILLED
        Optional<TagName> first = Arrays.stream(TagName.values()).filter(x -> x.toString().equals(capitalizedTagNameString)).findFirst();
73 1 1. findMatchingTagname : negated conditional → KILLED
        if (first.isEmpty()) {
74 1 1. findMatchingTagname : replaced return value with null for com/renomad/minum/htmlparsing/TagName::findMatchingTagname → KILLED
            return UNRECOGNIZED;
75
        } else {
76 1 1. findMatchingTagname : replaced return value with null for com/renomad/minum/htmlparsing/TagName::findMatchingTagname → KILLED
            return first.get();
77
        }
78
    }
79
}

Mutations

72

1.1
Location : lambda$findMatchingTagname$0
Killed by : com.renomad.minum.htmlparsing.HtmlParseNodeTests
replaced boolean return with false for com/renomad/minum/htmlparsing/TagName::lambda$findMatchingTagname$0 → KILLED

2.2
Location : lambda$findMatchingTagname$0
Killed by : com.renomad.minum.htmlparsing.HtmlParseNodeTests
replaced boolean return with true for com/renomad/minum/htmlparsing/TagName::lambda$findMatchingTagname$0 → KILLED

73

1.1
Location : findMatchingTagname
Killed by : com.renomad.minum.htmlparsing.HtmlParseNodeTests
negated conditional → KILLED

74

1.1
Location : findMatchingTagname
Killed by : com.renomad.minum.htmlparsing.HtmlParserTests
replaced return value with null for com/renomad/minum/htmlparsing/TagName::findMatchingTagname → KILLED

76

1.1
Location : findMatchingTagname
Killed by : com.renomad.minum.htmlparsing.HtmlParseNodeTests
replaced return value with null for com/renomad/minum/htmlparsing/TagName::findMatchingTagname → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0