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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
package Torello.JavaDoc;

import Torello.HTML.*;
import Torello.HTML.NodeSearch.*;

import Torello.Java.StrPrint;
import static Torello.Java.C.*;

import Torello.JDUInternal.GeneralPurpose.Messager;

import java.util.Vector;

/**
 * Encapsulates the HTML placed both the top and the bottom of a JavaDoc Web-Page, including the
 * Navigation-Bar HTML, the Package-Name, Type-Signature and other Banner-Labesl.
 * 
 * <EMBED CLASS='external-html' DATA-FILE-ID=PROG_MOD_HTML>
 * <EMBED CLASS='external-html' DATA-FILE-ID=HEADER_FOOTER>
 */
@JDHeaderBackgroundImg(EmbedTagFileID="REFLECTION_HTML_CLASS")
public class HeaderFooterHTML
{
    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
    protected static final long serialVersionUID = 1;


    // ********************************************************************************************
    // ********************************************************************************************
    // Some Private Constants
    // ********************************************************************************************
    // ********************************************************************************************


    private static final String MARKER_NOT_FOUND_MESSAGE =
        "Could not Find Marker: === START OF CLASS DATA === on a Java Doc Page";

    private static final String PAGE_TOP_STR = "CIET Page Top-Description";


    // ********************************************************************************************
    // ********************************************************************************************
    // Private Replaceable-HTML Fields
    // ********************************************************************************************
    // ********************************************************************************************


    private final SubSection head;
    private final SubSection topNavBar;
    private final SubSection packageInfo;
    private final SubSection title;
    private final SubSection inheritance;
    private final Replaceable defListsAboveSig;
    private final SubSection signature;
    private final Replaceable description;
    private final Replaceable defListsBelowDesc;
    private final SubSection bottomNavBar;


    // ********************************************************************************************
    // ********************************************************************************************
    // Public Accessor Methods
    // ********************************************************************************************
    // ********************************************************************************************


    /**
     * Retrieve the HTML {@code <HEAD>}.
     * 
     * @return An HTML-{@code Vector} containing all elements between the opening-{@code <HEAD>}
     * and closing-{@code </HEAD>} tags.  This method shall never return null, nor will it return
     * an empty-{@code Vector}
     */
    public Vector<HTMLNode> head()
    { return this.head.html; }

    /**
     * Retrieve the Navigation-Bar HTML at the top of a Java Doc Page.
     * 
     * @return An HTML-{@code Vector} containing all elements in the Top Navigation-Bar.  If there
     * is no Navigation-Bar at the top, <I>then this method shall return null.</I>
     */
    public Vector<HTMLNode> topNavBar()
    { return (this.topNavBar != null) ? this.topNavBar.html : null; }

    /**
     * Retrieve the Type's Package-Information, as an HTML-{@code Vector}.
     * 
     * @return An HTML-{@code Vector} containing all elements in the package label at the top of a
     * Java-Doc Page.  This method shall never return null, nor will it return an
     * empty-{@code Vector}
     */
    public Vector<HTMLNode> packageInfo()
    { return this.packageInfo.html; }

    /**
     * Retrieve the title of the page, as an HTML-{@code Vector}
     * 
     * @return An HTML-{@code Vector} containing all elements in the title.  This method shall
     * never return null, nor will it return an empty-{@code Vector}
     */
    public Vector<HTMLNode> title()
    { return this.title.html; }

    /**
     * Get the HTML for the Type's inheritance {@code <UL>'s}-List.
     * 
     * @return An HTML-{@code Vector} containing all elements in the Type Inheritance List.  If
     * the Type is an {@code Interface} that does not have any inheriting-types, or an
     * {@code @Annotation}, <I>then this method shall return null.</I>
     */
    public Vector<HTMLNode> inheritance()
    { return (this.inheritance != null) ? this.inheritance.html : null; }

    /**
     * Get any Definition-Lists that occur above the Type's Signature, which is at the top.
     * 
     * @return An HTML-{@code Vector} containing all elements in the definition {@code <DL>} lists
     * below the Yellow-Box Description.  This method shall <I>never return null</I>.  If there are
     * no such lists, then an empty HTML-{@code Vector} is returned.
     * 
     * <BR /><BR />It is perfectly acceptable to add HTML-Content to an empty-list.  Here, it would
     * place such content directly above the Type-Signature {@code <PRE>} box that is located at
     * the top of the page.
     */
    public Vector<HTMLNode> defListsAboveSig()
    { return this.defListsAboveSig.currentNodes(); }

    /**
     * Retrieve the signature HTML from the top of the page.
     * 
     * @return An HTML-{@code Vector} containing all elements in the Type-Signature {@code <PRE>}
     * Element.  This is located at the top of the class, and is box with a shadow border.  This
     * method shall never return null, nor will it return an empty-{@code Vector}
     */
    public Vector<HTMLNode> signature()
    { return this.signature.html; }

    /**
     * Retrieve the description from the top of the page, as HTML.
     * 
     * @return An HTML-{@code Vector} containing all elements in the description, which is a
     * Yellow box at the top of the page.  This method shall <I>never return null</I>.  If there
     * is no such HTML divider, then an empty HTML-{@code Vector} is returned.
     * 
     * <BR /><BR />It is perfectly acceptable to add HTML-Content to an empty-list.  Here, it would
     * place such content directly below the Yellow-Description box that is located at the top of
     * the page.
     */
    public Vector<HTMLNode> description()
    { return this.description.currentNodes(); }

    /**
     * Get any Definition-Lists that occur below the Yellow-Box Signature.
     * 
     * @return An HTML-{@code Vector} containing all elements in the definition {@code <DL>} lists
     * below the Yellow-Box Description.  This method shall <I>never return null</I>.  If there are
     * no such lists, then an empty HTML-{@code Vector} is returned.
     * 
     * <BR /><BR />It is perfectly acceptable to add HTML-Content to an empty-list.  Here, it would
     * place such content directly below the Yellow-Description box that is located at the top of
     * the page.
     */
    public Vector<HTMLNode> defListsBelowDesc()
    { return this.defListsBelowDesc.currentNodes(); }

    /**
     * Retrieve the Navigation-Bar HTML at the bottom of a Java Doc Page.
     * 
     * @return An HTML-{@code Vector} containing all elements in the Bottom Navigation-Bar.  If
     * there is no Navigation-Bar at the top, <I>then this method shall return null.</I>
     */
    public Vector<HTMLNode> bottomNavBar()
    { return (this.bottomNavBar != null) ? this.bottomNavBar.html : null; }


    // ********************************************************************************************
    // ********************************************************************************************
    // The Constructor (This class version of a Main-Method)
    // ********************************************************************************************
    // ********************************************************************************************


    // MESSAGER
    //  1) INVOKES:     assertFailHTML
    //  2) INVOKED-BY:  JavaDocHTMLFile
    //  3) RETURNS:     NOTHING, this is a constructor
    //  4) THROWS:      JavaDocHTMLParseException (assertFailHTML)

    HeaderFooterHTML(Vector<HTMLNode> page, CIET ciet)
    {
        // Temporary-Variables that are used over and over again.
        int             sPos, ePos, pos;
        DotPair         dp;
        SubSection      ss;
        Vector<DotPair> dps;


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // EPOS (used over and over)  Everything **EXCEPT** bottomNavBar is **BEFORE** EPOS
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        // This is the actual 'ePos' that is used many times.  The temporary ePos is only used
        // once or twice in the code below.  This makes sure not to start searching past the
        // end of the page-header HTML.  The BEGINNING of the <DIV CLASS='summary'> is **EXACTLY**
        // the **END** of the Page-Header HTML.

        final int EPOS = InnerTagFind.first(page, "div", "class", s -> s.equals("summary"));

        // These asserts are kind of important.  If for some odd reason a javadoc version was
        // outputting different HTML, it is better to get an error-message and fail than to start
        // outputting garbage-HTML.

        if (EPOS == -1) Messager.assertFailHTML
            ("There Java Doc Page doesn't have a <DIV CLASS='summary'> Element", PAGE_TOP_STR);


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // HTML <HEAD>...</HEAD>
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        this.head = TagNodePeekInclusive.first(page, "head");

        if (this.head == null) Messager.assertFailHTML(
            "This page does not appear to have a <HEAD>...</HEAD> Element",
            PAGE_TOP_STR
        );


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // The Top Navigation-Bar, There may be pages which do not have a NavBar
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        //
        // NOTE: I just noticed that the Navigation-Bar is a series of <DIV>'s, and there is no
        //       surrounding HTML divider.  We have to find the first open-<DIV>, and the last
        //       closing </DIV>

        sPos = CommentNodeFind.first
            (page, head.location.end, EPOS, s -> s.contains("=== START OF TOP NAVBAR ==="));

        if (sPos == -1) this.topNavBar = null;

        else
        {
            ePos = CommentNodeFind.first
                (page, sPos, EPOS, s -> s.contains("=== END OF TOP NAVBAR ==="));

            sPos = TagNodeFind.first(page, sPos, ePos, TC.OpeningTags, "div");
            ePos = TagNodeFind.last(page, sPos, ePos, TC.ClosingTags, "div");

            dp = new DotPair(sPos, ePos);

            this.topNavBar = new SubSection(dp, Util.cloneRange(page, dp));
        }


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Package-Name Information is the First Item after the Navigation-Bar
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        // It's after the NavBar, if there was no NavBar, skip the first 20 nodes...
        // (a nice round number)

        sPos = (topNavBar != null) ? (this.topNavBar.location.end + 1) : 20;

        sPos = CommentNodeFind.first
            (page, sPos, EPOS, TextComparitor.CN, "=== START OF CLASS DATA ===");

        if (sPos == -1) Messager.assertFailHTML(MARKER_NOT_FOUND_MESSAGE, PAGE_TOP_STR);

        // NOTE: The +4 is skipping past the comment, and some stuff.  
        this.packageInfo = InnerTagPeekInclusive.first
            (page, sPos + 4, EPOS, "div", "class", TextComparitor.C, "subTitle");

        if (this.packageInfo == null) Messager.assertFailHTML(
            "Java-Package Information <DIV CLASS='subTitle'> element, not located on the page",
            PAGE_TOP_STR
        );


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Name of the CIET/Type (The Class-Name, Interface-Name, Enum-Name, Annotation-Name...)
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        sPos = this.packageInfo.location.end + 1;

        this.title = InnerTagPeekInclusive.first
            (page, sPos, EPOS, "h2", "class", TextComparitor.C, "title");

        if (this.title == null) Messager.assertFailHTML(
            "Java CIET-Title <H2 CLASS='title'> element was not located on the page",
            PAGE_TOP_STR
        );


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // The Inheritance-Tree
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        sPos = this.title.location.end + 1;

        if (ciet == CIET.ANNOTATION) this.inheritance = null;

        else
        {
            this.inheritance = InnerTagPeekInclusive.first
                (page, sPos, EPOS, "ul", "class", TextComparitor.C, "inheritance");

            if ((this.inheritance == null) && (ciet != CIET.INTERFACE)) Messager.assertFailHTML(
                "CIET is a(n) " + ciet.toString() + ", but no Inheritance-Tree "+
                "<UL CLASS='inheritance'> element was located on the page", PAGE_TOP_STR
            );
        }


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Defintion-Lists (<DL> <DT>...</DT> <DD>...</DD> </DL>) **ABOVE** the signature
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        //
        // These Include: All Implemented Interfaces, Direct Known Sub-Classes, Type-Parameters,
        // All Known Implementing Classes, Functional-Interface, etc...

        if (this.inheritance != null) sPos = this.inheritance.location.end + 1;

        ePos = TagNodeFind.first(page, sPos, EPOS, TC.OpeningTags, "hr");

        if (ePos == -1) Messager.assertFailHTML
            ("There was not <HR> element in the Page Header", PAGE_TOP_STR);

        dps = TagNodeFindInclusive.all(page, sPos, ePos, "dl");

        if (dps.size() > 0)
        {
            dp = new DotPair(
                dps.elementAt(0).start,
                dps.elementAt(dps.size() - 1).end
            );

            this.defListsAboveSig = new SubSection(dp, Util.cloneRange(page, dp));
        }

        else this.defListsAboveSig = Replaceable.empty((this.inheritance != null)
            ? (this.inheritance.location.end + 1)
            : (this.title.location.end + 1)
        );



        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // The CIET Signature
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        sPos = this.defListsAboveSig.originalLocationEnd() + 1;

        this.signature = TagNodePeekInclusive.first(page, sPos, EPOS, "pre");

        if (this.signature == null) Messager.assertFailHTML
            ("There Signature HTML <PRE> element was not located on the page", PAGE_TOP_STR);


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Description
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        sPos = signature.location.end + 1; // This is white-space

        ss = InnerTagPeekInclusive.first
            (page, sPos, EPOS, "div", "class", TextComparitor.C, "block");

        // The user may wish to add stuff anyway.  Primarily the @JDHeaderBackgroundImg needs an
        // insertion point NO MATTER WHAT...  Therefore this cannot be a null SubSection, it has
        // to be an empty-Replaceable if it was not found...

        this.description = (ss != null) ? ss : Replaceable.empty(sPos);


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Defintion-Lists (<DL> <DT>...</DT> <DD>...</DD> </DL>) **BELOW** the description
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        //
        // These include: See Also, Since , etc...

        sPos = this.description.originalLocationEnd() + 1;
            // This will be the next node after the <PRE> if the description is just an empty
            // Replaceable, but that is ok, because the insertion-point is still after the
            // description's insertion-pont NO MATTER WHAT.

        pos = InnerTagFind.first
            (page, sPos, EPOS, "span", "class", TextComparitor.C_OR, "seeLabel", "simpleTagLabel");

        // In order to insert "HiLitedSrcCode Links", there needs to be an insertion-point
        // This is now implemented as a "Replaceable.empty" if there are no <DL>'s below the
        // description or signature

        if (pos == -1) this.defListsBelowDesc = Replaceable.empty(sPos);

        else
        {
            dp = Surrounding.first(page, pos, "dl");

            if (dp == null) Messager.assertFailHTML(
                "Header <SPAN CLASS=Label> Element Found, but no Surrounding <DL> identified",
                PAGE_TOP_STR
            );

            this.defListsBelowDesc = new SubSection(dp, Util.cloneRange(page, dp));
        }


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // The Bottom Navigation-Bar, There may be pages which do not have a NavBar
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        //
        // Searching through "CommentNode" instances is much faster since the
        // if (HTMLNode.isCommentNode()) is the fastest of the search-specifies...  There aren't
        // many comment's in a javadc page (much fewer than the number of TagNode's & TextNode's)
        //
        // REMEMBER, Here *DO NOT* use 'EPOS', that is the position of the beginning of the 
        // summaries-section.
        //
        // ALSO: as explained in the "Top Navigation-Bar" getter-section (way above this part),
        //       The Bottom and Top Bar's are a series of "sibling" <DIV> Tags, and you have to
        //       get the first opening-<DIV> and the last closing-</DIV>

        sPos = CommentNodeFind.first(page, s -> s.contains("== START OF BOTTOM NAVBAR =="));

        if (sPos == -1) this.bottomNavBar = null;

        else
        {
            ePos = CommentNodeFind.first
                (page, sPos, -1, s -> s.contains("=== END OF BOTTOM NAVBAR ==="));

            if (ePos == -1) Messager.assertFailHTML("BOTTOM NAVBAR End-Marker not found", null);

            sPos = TagNodeFind.first(page, sPos, ePos, TC.OpeningTags, "div");
            ePos = TagNodeFind.last(page, sPos, ePos, TC.ClosingTags, "div");
    
            dp = new DotPair(sPos, ePos);
    
            this.bottomNavBar = new SubSection(dp, Util.cloneRange(page, dp));
        }
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // DEBUG-PRINTING
    // ********************************************************************************************
    // ********************************************************************************************


    private static final String STARS =
        BYELLOW + "\n*****************************************\n" + RESET;

    /**
     * Prints an abbreviated-version of the contents of this instance, to a user-provided
     * {@code Appendable}.  If the HTML requires more than four lines of text, only the first four
     * lines are printed.
     * 
     * @param a This may be any Java Appendable.  If an {@code IOException} is thrown while writing
     * to this {@code Appendable}, it will be caught an wrapped in an
     * {@code IllegalArgumentException}, with the {@code IOException} set as the {@code cause}.
     * 
     * @throws IllegalArgumentException If {@code 'a'} throws an {@code IOException}
     * @see StrPrint#firstNLines(String, int)
     * @see Util#pageToString(Vector)
     */
    public void debugPrint(Appendable a)
    {
        try 
        {
            a.append(
                STARS + BCYAN + "this.head" + RESET + ':' + STARS +
                StrPrint.firstNLines(Util.pageToString(head.html), 4) +
                '\n'
            );

            if (topNavBar != null) a.append(
                STARS + BCYAN + "this.topNavBar" + RESET + ':' + STARS +
                StrPrint.firstNLines(Util.pageToString(topNavBar.html), 4) +
                '\n'
            );
            else a.append(STARS + BRED + "this.topNavBar is null" + RESET + STARS);

            a.append(
                STARS + BCYAN + "this.packageInfo" + RESET + ':' + STARS +
                StrPrint.firstNLines(Util.pageToString(packageInfo.html), 4) +
                '\n'
            );

            a.append(
                STARS + BCYAN + "this.title" + RESET + ':' + STARS +
                StrPrint.firstNLines(Util.pageToString(title.html), 4) +
                '\n'
            );

            if (inheritance != null) a.append(
                STARS + BCYAN + "this.inheritance" + RESET + ':' + STARS +
                StrPrint.firstNLines(Util.pageToString(inheritance.html), 4) +
                '\n'
            );
            else a.append(STARS + BRED + "this.inheritance is null" + RESET + STARS);

            if (defListsAboveSig.currentSize() > 0) a.append(
                STARS + BCYAN + "this.defListsAboveSig" + RESET + ':' + STARS +
                StrPrint.firstNLines(Util.pageToString(defListsAboveSig.currentNodes()), 4) +
                '\n'
            );
            else a.append(STARS + BRED + "this.defListsAboveSig is empty" + RESET + STARS);

            a.append(
                STARS + BCYAN + "this.signature" + RESET + ':' + STARS +
                StrPrint.firstNLines(Util.pageToString(signature.html), 4) +
                '\n'
            );

            if (description.currentSize() > 0) a.append(
                STARS + BCYAN + "this.description" + RESET + ':' + STARS +
                StrPrint.firstNLines(Util.pageToString(description.currentNodes()), 4) +
                '\n'
            );
            else a.append(STARS + BRED + "this.description is empty" + RESET + STARS);

            if (defListsBelowDesc.currentSize() > 0) a.append(
                STARS + BCYAN + "this.defListsBelowDesc" + RESET + ':' + STARS +
                StrPrint.firstNLines(Util.pageToString(defListsBelowDesc.currentNodes()), 4) +
                '\n'
            );
            else a.append(STARS + BRED + "this.defListsBelowDesc is empty" + RESET + STARS);

            if (bottomNavBar != null) a.append(
                STARS + BCYAN + "this.bottomNavBar" + RESET + ':' + STARS +
                StrPrint.firstNLines(Util.pageToString(bottomNavBar.html), 4) +
                '\n'
            );
            else a.append(STARS + BRED + "this.bottomNavBar is null" + RESET + STARS);
        }
        catch (java.io.IOException ioe)
        {
            throw new IllegalArgumentException(
                "Your Appendable instance has caused an IOException to throw.  See getCause() " +
                "for details", ioe
            );
        }
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // At the end of the processing of a JavaDoc Web-Page, this gets all the changes that were made
    // ********************************************************************************************
    // ********************************************************************************************


    Vector<Replaceable> allReplaceables()
    {
        Vector<Replaceable> ret = new Vector<>();

        ret.add(head);              // Required, always present

        if (topNavBar != null) ret.add(topNavBar);

        ret.add(packageInfo);       // Required, always present
        ret.add(title);             // Required, always present

        if (inheritance != null) ret.add(inheritance);

        ret.add(defListsAboveSig);  // A "Replaceable" is never null.
        ret.add(signature);         // Required, always present
        ret.add(description);       // A "Replaceable" is never null.
        ret.add(defListsBelowDesc); // A "Replaceable" is never null.

        if (bottomNavBar != null) ret.add(bottomNavBar);

        return ret;
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // THE NEW-THING: Garbage-Collector Helper?
    // ********************************************************************************************
    // ********************************************************************************************
    // 
    // Does this help?  Is this "good" for the Garbage-Collect?  Is this going to speed it up,
    // or slow it down?  This is just a "C-Styled" FREE or DESTORY method...
    // It isn't publicly visible anyway...

    void clear()
    {
        // private final SubSection head;
        // Guaranteed: Never Null, or Messager.assertFailHTML

        head.html.clear();
        head.html = null;

        // private final SubSection topNavBar;
        // Maybe they don't have one

        if (topNavBar != null)
        {
            topNavBar.html.clear();
            topNavBar.html = null;
        }

        // private final SubSection packageInfo;
        // Guaranteed: Never Null, or Messager.assertFailHTML
        // NOTE: This may one day change...

        if (packageInfo != null)
        {
            packageInfo.html.clear();
            packageInfo.html = null;
        }

        // private final SubSection title;
        // Guaranteed: Never Null, or Messager.assertFailHTML

        title.html.clear();
        title.html = null;

        // private final SubSection inheritance;
        // Maybe they don't have one

        if (inheritance != null)
        {
            inheritance.html.clear();
            inheritance.html = null;
        }

        // private final Replaceable defListsAboveSig;
        // THIS IS A REPLACEABLE: It won't be null, but it may be empty

        if (SubSection.class.isAssignableFrom(defListsAboveSig.getClass()))
        {
            ((SubSection) defListsAboveSig).html.clear();
            ((SubSection) defListsAboveSig).html = null;
        }
        else if (defListsAboveSig.currentSize() > 0) defListsAboveSig.clearHTML();

        // private final SubSection signature;
        // Guaranteed: Never Null, or Messager.assertFailHTML

        signature.html.clear();
        signature.html = null;

        // private final Replaceable description;
        // THIS IS A REPLACEABLE: It won't be null, but it may be empty

        if (SubSection.class.isAssignableFrom(description.getClass()))
        {
            ((SubSection) description).html.clear();
            ((SubSection) description).html = null;
        }
        else if (description.currentSize() > 0) description.clearHTML();

        // private final Replaceable defListsBelowDesc;
        // THIS IS A REPLACEABLE: It won't be null, but it may be empty

        if (SubSection.class.isAssignableFrom(defListsBelowDesc.getClass()))
        {
            ((SubSection) defListsBelowDesc).html.clear();
            ((SubSection) defListsBelowDesc).html = null;
        }
        else if (defListsBelowDesc.currentSize() > 0) defListsBelowDesc.clearHTML();

        // private final SubSection bottomNavBar;
        // Maybe they don't have one

        if (bottomNavBar != null)
        {
            bottomNavBar.html.clear();
            bottomNavBar.html = null;
        }
    }
}