1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package Torello.HTML;

class IsTag
{
    static boolean isTag(
            final TagNode   tn,
            final TC        tagCriteria, 
            final String... possibleTags
        )
    {
        // Requested an "OpeningTag" but this is a "ClosingTag"
        if ((tagCriteria == TC.OpeningTags) && tn.isClosing) return false;

        // Requested a "ClosingTag" but this is an "OpeningTag"
        if ((tagCriteria == TC.ClosingTags) && ! tn.isClosing) return false;

        for (int i=0; i < possibleTags.length; i++)

            if (tn.tok.equalsIgnoreCase(possibleTags[i]))
            
                // Found a TOKEN match, return TRUE immediately
                return true;

        // None of the elements in 'possibleTags' equalled tn.tok
        return false;
    }

    static boolean isTagExcept(
            final TagNode   tn,
            final TC        tagCriteria,
            final String... possibleTags
        )
    {
        // Requested an "OpeningTag" but this is a "ClosingTag"
        if ((tagCriteria == TC.OpeningTags) && tn.isClosing) return false;

        // Requested a "ClosingTag" but this is an "OpeningTag"
        if ((tagCriteria == TC.ClosingTags) && ! tn.isClosing) return false;

        for (int i=0; i < possibleTags.length; i++)

            if (tn.tok.equalsIgnoreCase(possibleTags[i]))


                // The Token of the input node was a match with one of the 'possibleTags'
                // Since this is "Except" - we must return 'false'

                return false;


        // None of the elements in 'possibleTags' equalled tn.tok
        // since this is "Except" - return 'true'

        return true;
    }

}