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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package Torello.JavaDoc.SyntaxHiLite;

import Torello.Java.ParallelArrayException;
import Torello.HTML.TagNode;

import java.util.Arrays;

public class AbstractHiLiter implements java.io.Serializable
{
    protected static final long serialVersionUID = 1;


    // ********************************************************************************************
    // ********************************************************************************************
    // Instance Fields
    // ********************************************************************************************
    // ********************************************************************************************


    protected final TagNode[] openers;
    protected final TagNode[] closers;
    protected final boolean[] utilize;

    protected final int CONFIG_ARR_LEN;


    // ********************************************************************************************
    // ********************************************************************************************
    // Constructor
    // ********************************************************************************************
    // ********************************************************************************************


    protected AbstractHiLiter(
            final TagNode[] openers,
            final TagNode[] closers,
            final boolean[] utilize
        )
    {
        ParallelArrayException.check(openers, "openers", closers, "closers");
        ParallelArrayException.check(closers, "closers", utilize, "utilize");

        this.openers    = openers;
        this.closers    = closers;
        this.utilize    = utilize;

        this.CONFIG_ARR_LEN = openers.length;
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Retrieval / Getter Methods
    // ********************************************************************************************
    // ********************************************************************************************


    public TagNode getOpeningTag(byte whichOne)
    {
        checkWhichOne(whichOne);
        return openers[whichOne];
    }

    public TagNode getClosingTag(byte whichOne)
    {
        checkWhichOne(whichOne);
        return closers[whichOne];
    }

    public boolean getUtilized(byte whichOne)
    {
        checkWhichOne(whichOne);
        return utilize[whichOne];
    }

    private void checkWhichOne(byte whichOne)
    {
        if ((whichOne < 1) || (whichOne >= this.CONFIG_ARR_LEN))

            throw new IllegalArgumentException(
                "You have passed an invalid value [" + whichOne + "], to parameter 'whichOne'.  " +
                "This must be a valid byte, whose value is between 1 and " +
                (this.CONFIG_ARR_LEN - 1)
            );
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // java.lang.Object
    // ********************************************************************************************
    // ********************************************************************************************


    public boolean equals(Object other)
    {
        if (! (other instanceof AbstractHiLiter)) return false;

        AbstractHiLiter o = (AbstractHiLiter) other;

        return 
                Arrays.equals(this.openers, o.openers)
            &&  Arrays.equals(this.closers, o.closers)
            &&  Arrays.equals(this.utilize, o.utilize);
    }

    public int hashCode()
    { return Arrays.hashCode(this.openers); }
}