001package Torello.JavaDoc;
002
003import static Torello.Java.C.*;
004
005import Torello.HTML.HTMLNode;
006import Torello.HTML.TagNode;
007import Torello.HTML.TextNode;
008import Torello.HTML.SubSection;
009import Torello.HTML.Replaceable;
010import Torello.HTML.TagNodeIndex;
011import Torello.HTML.DotPair;
012import Torello.HTML.HTMLTags;
013import Torello.HTML.TC;
014
015import Torello.Java.ReadOnly.ReadOnlyList;
016
017import java.util.Vector;
018import java.util.TreeMap;
019import java.util.TreeSet;
020import java.util.Collections;
021
022import java.io.Serializable;
023
024import Torello.JDUInternal.Messager.Where.JDUUserAPI;
025import Torello.JDUInternal.Messager.Messager;
026import Torello.JDUInternal.Messager.Where.Where_Am_I;
027
028import Torello.JDUInternal.Parse.HTML.TheREFL.D1_PrimaryRefl;
029import Torello.JDUInternal.Parse.HTML.TheREFL.D2_ReflDLs;
030import Torello.JDUInternal.Parse.HTML.TheREFL.ReflMapKeys;
031
032
033/**
034 * This class stores the HTML Detail-Descriptions retrieved from a Java Doc web-page 'Details
035 * Section', and simultaneously, holds the reflection-data extracted from the
036 * <CODE>'&#46;java'</CODE> corresponding source-code files - facilitating all changes to a Java
037 * Doc Page deemed necessary.
038 * 
039 * <EMBED CLASS='external-html' DATA-FILE-ID=PROG_MOD_HTML>
040 * <EMBED CLASS='external-html' DATA-FILE-ID=REFLHTML>
041 * 
042 * @param <ENTITY> This will take one of five type's: {@link Method}, {@link Constructor},
043 * {@link Field}, {@link EnumConstant}, or {@link AnnotationElem}.   The HTML contained by an
044 * instance of this class corresponds directly to the HTML contained by a detail section of one of
045 * one of these five Members / Entities.
046 */
047@JDHeaderBackgroundImg(EmbedTagFileID="REFLECTION_HTML_CLASS")
048@SuppressWarnings("rawtypes")
049public class ReflHTML<ENTITY extends Declaration>
050    implements java.io.Serializable, java.lang.Comparable<ReflHTML>
051{
052    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
053    protected static final long serialVersionUID = 1;
054
055    // When the Messager Reports its errors, this class passes this reference to the Messager
056    // to facilitate the printing of that information (What class encountered an error or warning
057    // that needs to be printed by the Messager).
058
059    private static final Where_Am_I WHERE_AM_I = JDUUserAPI.ReflectionHTML;
060
061
062    // ********************************************************************************************
063    // ********************************************************************************************
064    // Constructor
065    // ********************************************************************************************
066    // ********************************************************************************************
067
068
069    // Primary Constructor for this class.  Note that all of the work for this constructor has
070    // since been moved to the Data-Record classes located inside package:
071    // 
072    // Torello.JDUInternal.Parse.HTML.TheREFL
073    // 
074    // This constructor, now, does absolutely nothing but copy the computed fields from the
075    // aforementioned Data-Records
076    // 
077    // Keeping HTML-Parsing code in a separate, internal, package allows me to "localize" the
078    // complicated parsing code into a single location - far away from the end user.  This code
079    // is dependent upon which of the Java-Doc Versions is being used.
080    // 
081    // Since October of 2024, HTML-Parsing Code has been moved to a single, JDUInternal,
082    // suite of directories that are much easier to manage.  This constructor, for instance, just
083    // block copies the fields from one of those JDUInternal Data-Record Classes.
084
085    public ReflHTML(
086            final D1_PrimaryRefl<ENTITY>    primaryDataRec,
087            final D2_ReflDLs<ENTITY>        defListsRec,
088            final String                    htmlID
089        )
090    {
091        // This is stuff that was passed directly t TheREFL.D1_PrimaryRefl
092        // These were saved into public-final fields in that class to make it "slightly faster"
093        // to copy them into this class public-final fields
094
095        this.entity         = primaryDataRec.entity;
096        this.location       = primaryDataRec.location;
097        this.entityAsEnum   = primaryDataRec.entityAsEnum;
098        this.subSections    = primaryDataRec.subSections;
099
100
101        // This was computed directly before this constructor was called, and then passed as a
102        // parameter to this method
103
104        this.htmlID = htmlID;
105
106
107        // When debugging, this tends to make life a lot easier...
108        // These two were added in February of 2025.  It is a million times easier to print up 
109        // information about "The REFL" when the name of the Detail-Entity and the Class/Type to
110        // which that detail belongs are easy-to-print java.lang.String's.
111        // 
112        // nameAsStr:  Entity-Name - Method, Field, Ctor, Enum-Constant or Annotation-Elem *NAME*
113        // fullNameNoGenerics: Type-Name (CIET) Class, Interface, Enum, Annotation or Record *NAME*
114
115        this.nameAsStr          = primaryDataRec.nameAsStr;         
116        this.fullNameNoGenerics = primaryDataRec.fullNameNoGenerics;
117
118
119        // Stuff Computed in Torello.JDUInternal.Parse.HTML.TheREFL.D1_PrimaryRefl
120        // This stuff was not "passed" to the "D1_PrimaryRefl" Data-Record, it was computed there,
121        // and now it is simply copied and saved into this class public-final fields.
122
123        this.endingLI                   = primaryDataRec.endingLI;
124        this.openingUL                  = primaryDataRec.openingUL;
125        this.hiLitedCodeTNI             = primaryDataRec.hiLitedCodeTNI;
126        this.name                       = primaryDataRec.name;
127        this.signature                  = primaryDataRec.signature;
128        this.secondDescFromTypeLabel    = primaryDataRec.secondDescFromTypeLabel;
129
130        this.needToAddOpenCloseDLsForHiLitedDetails =
131            primaryDataRec.needToAddOpenCloseDLsForHiLitedDetails;
132
133
134        // The "Definition Lists <DL>" Data-Record fills up one TreeMap of SubSections, and
135        // one ReadOnlyList of this stuff.
136
137        this.miscSimpleTagLabels = defListsRec.miscSimpleTagLabels;
138    }
139
140
141    // ********************************************************************************************
142    // ********************************************************************************************
143    // HTML Processor's Special Access Stuff
144    // ********************************************************************************************
145    // ********************************************************************************************
146
147
148    /**
149     * This points to the opening {@code <UL>} tag for the detail.  It's contents may be modified
150     * to include CSS classes or id's.
151     */
152    public final TagNodeIndex openingUL;
153
154    private static final TagNode OPEN_DL    = HTMLTags.hasTag("dl", TC.OpeningTags);
155    private static final TagNode CLOSE_DL   = HTMLTags.hasTag("dl", TC.ClosingTags);
156
157    private final Replaceable hiLitedCodeTNI;
158
159    private final boolean needToAddOpenCloseDLsForHiLitedDetails;
160
161    private boolean alreadyInvoked = false;
162
163    public void insertHiLitedDetail(Vector<HTMLNode> hiLitedDetail)
164    {
165        if (alreadyInvoked) throw new Error("Major Problem"); else alreadyInvoked = true;
166
167        if (this.needToAddOpenCloseDLsForHiLitedDetails)
168        {
169            hiLitedDetail.insertElementAt(OPEN_DL, 0);
170            hiLitedDetail.add(CLOSE_DL);
171        }
172
173        this.hiLitedCodeTNI.currentNodes().addAll(0, hiLitedDetail);
174    }
175
176    public void xxhlcPrintItNow()
177    {
178        System.out.println(
179            '\n' +
180            BRED + "ReflHTML.printItNow():\n" + RESET +
181            BCYAN + "Entity-Name" + RESET + ": " + this.nameAsStr + ", " +
182            BCYAN + "CIET" + RESET + ": " + this.fullNameNoGenerics + '\n' +
183            this.hiLitedCodeTNI.summarize(true)
184        );
185
186        Torello.Java.Q.BP();
187    }
188
189
190    // ********************************************************************************************
191    // ********************************************************************************************
192    // Main Fields
193    // ********************************************************************************************
194    // ********************************************************************************************
195
196
197    /**
198     * This is the actual type-reflection (type-mirror) of the {@code Entity} extracted from the
199     * Java Doc {@code '.html'} web-page file, <I><B>and</B> from the </I> {@code '.java'} Source
200     * Code File.
201     * 
202     * <BR /><BR />Since the type-parameter {@code ENTITY} must extend {@link Declaration}, this
203     * field will hold all of the information that was parsed &amp; extracted by Java Parser.
204     * Depending on what type of instance of {@code Declaration} this represents, this will field
205     * will contain all of the parameter-names, parameter-types, modifiers, and exceptions that
206     * are associated with the entity.
207     * 
208     * <BR /><BR />This will take one of five type's: {@link Method}, {@link Constructor},
209     * {@link Field}, {@link EnumConstant}, {@link AnnotationElem}.  This allows you to retrieve
210     * all reflected information, quickly and easily, associated with the Java Doc HTML "Detail
211     * Section" for a particular method, field, constructor etc...
212     */
213    public final ENTITY entity;
214
215    /**
216     * This is used as a 'faster-way' to retrieve what type of Entity this "Reference-HTML" 
217     * detail-section is being represented here.  This makes the code more readable than using
218     * Java's {@code 'getClass()'} reflection to identify whether this 'Detail Section HTML' holds
219     * the HTML for a Method, Field, Constructor, Enumeration, etc...
220     * 
221     * <BR /><BR />The value in {@code 'entityAsEnum'} shall always be identical to the type of
222     * the {@link #entity}.  So for instance, if {@link #entity} contained a {@link Field} instance,
223     * this field would be equal to {@link Entity#FIELD}.  If this entity represented a
224     * {@link Method} HTML Detail-Section element, then this field would hold
225     * {@link Entity#METHOD}.
226     */
227    public final Entity entityAsEnum;
228
229    // The location in the parsed Java Doc '.html' web-page from whence this HTML was retrieved.
230    // This field is declared final.  The many sections, parts, and segments of a Java Doc
231    // generated page can have their contents added, abbreviated, and extended, but they cannot be
232    // moved to different places on the page.
233
234    private final DotPair location;
235
236
237    // This is used to insert two "wrapper dividers" - the HTML <DIV> Elements that "wrap" around
238    // the contents of a ReflHTML.  These wrapper DIV's (of which there are two) are need for the 
239    // maximize, minimize & partialize buttons.  Both of the two DIV's have **BOTH** a CSS-ID
240    // **AND** a CSS-CLASS that are used by two-line Java-Script methods that set the CSS "display"
241    // property to "block" and "none" (for hiding and showing these Refl's at the click of a
242    // button)
243    // 
244    // Essentially - two extra sets of <DIV> ... </DIV> are added
245
246    private final TagNodeIndex endingLI;
247
248
249    // ********************************************************************************************
250    // ********************************************************************************************
251    // More Main Fields
252    // ********************************************************************************************
253    // ********************************************************************************************
254
255
256    /**
257     * Each Deteail Entity on a JavaDoc Page has a <I>small and empty</I> Anchor-Link, <I>with an
258     * ID Attribute</I> that allows the browser to redirect to the detail on a JavaDoc page using
259     * a relative URL to redirect to the details location on the web-page.  If that detail element
260     * was found, it's will be stored in this field.  (Otherwise, this field will contain null)
261     * 
262     * <BR /><BR />Below is the <CODE>&lt;A ID=..&gt;</CODE> generated by Java Doc for a method
263     * that is named {@code 'length'}, and takes zero parameters as input.
264     * 
265     * <DIV CLASS=HTML>{@code
266     * <a id="length()">
267     * <!--   -->
268     * </a>
269     * }</DIV>
270     */
271    public final String htmlID;
272
273    /**
274     * The should contain the simple name of this detail entity.  This can be a handy feature when
275     * debugging.
276     * 
277     * <BR /><BR />If {@code 'this'} Detail-Entity represented a method named with the signature
278     * {@code public void removeIt(String s)}, then this field would evaluate to "removeIt".
279     */
280    public final String nameAsStr;
281
282    /**
283     * This should contain the full-name of the CIET-Type.  This is also a feature for debugging
284     */
285    public final String fullNameNoGenerics;
286
287
288    // Every Detail-Element (Method, Field, Constructor, Enum-Constant and Annotation-Element)
289    // **MUST** have a name.  This should be a member field, instead of an entry in the
290    // TreeMap of 'possible' subsections
291
292    private final SubSection name;
293    private final SubSection signature;
294
295    // This Vector's contents are auto-inserted by the "NavButtons" class
296    private final Vector<HTMLNode> detailNavBar = new Vector<>();
297
298
299
300    // This is a TreeMap that will hold all of the 'optional' Detail-Elements.  Many of the
301    // entries in this TreeMap will be very common (at least as far as Java-HTML Type's goes),
302    // but *NONE* of them are 'mandatory' - Java Doc will not auto-create the detail-elements
303    // that are stored in this map.  They must be explicitly added by the user with taglets
304
305    private final TreeMap<Character, SubSection> subSections;
306
307
308    // The other 'simpleTagLabels' just have their index and value saved, furthermore this
309    // array-list is only built if one is found/identified in the JavaDoc page.  99% of the
310    // types in JavaHTML do not have these...
311
312    private final ReadOnlyList<TagNodeIndex> miscSimpleTagLabels;
313
314    /**
315     * This boolean indicates that the HTML description provided by this JavaDoc Detail has
316     * been copied from an parent-class or from an interface.  In cases where an abstract method
317     * is implemented, the programmer may "opt-out" of typing anything about what the method's
318     * purpose is.  If so, JavaDoc automatically copies the abstract (or parent) method's
319     * description, and leaves a little note saying so.
320     * 
321     * <BR /><BR />Note that when this occurs, there will by two HTML {@code <DIV CLASS="block">}
322     * elements on the page for that detail.
323     */
324    public final boolean secondDescFromTypeLabel;
325
326
327    // ********************************************************************************************
328    // ********************************************************************************************
329    // SubSection Accessor Methods
330    // ********************************************************************************************
331    // ********************************************************************************************
332
333
334    /**
335     * Returns an HTML-{@code Vector} of the HTML used to display the
336     * <B STYLE='color: red;'>name</B> of a detail element.
337     * 
338     * <BR /><BR />This also contains the same information as in the field
339     * {@link Declaration#name}, which is reflected (using <B>{@code Java Parer}</B>) from the
340     * associated {@code 'java'} source-code file.  The HTML for this segment is listed, here
341     * below:
342     * 
343     * <DIV CLASS=HTML>{@code
344     * <h4> [Name] </h4>
345     * }</DIV>
346     * 
347     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
348     * 
349     * @return An HTML-{@code Vector} of the Java Doc <B STYLE='color: red;'>name</B>
350     * segment of this detail.  This method will never return null, as all detail-elements have
351     * a name.
352     * 
353     * @see Declaration#name
354     */
355    public Vector<HTMLNode> name() { return name.html; }
356
357    /**
358     * Returns an HTML-{@code Vector} of the HTML used to display the
359     * <B STYLE='color: red;'>signature</B> of a detail element.
360     * 
361     * <BR /><BR />This also contains the same information as in the field
362     * {@link Declaration#signature}, which is reflected (using <B>{@code Java Parer}</B>) from the
363     * associated {@code 'java'} source-code file.  In the HTML below it is the text that appears
364     * between the <CODE>&lt;PRE&gt;</CODE> tags.  Note that the HTML {@code 'class'} attribute
365     * (present, below) will not always be included in every detail element.
366     * 
367     * <DIV CLASS=HTML>{@code
368     * <h4> [Name] </h4>
369     * <pre class="Signature"> ... </pre>
370     * }</DIV>
371     * 
372     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
373     * 
374     * @return An HTML-{@code Vector} of the Java Doc <B STYLE='color: red;'>signature</B>
375     * segment of this detail.  This method will never return null, as all detail-elements have
376     * a signature.
377     * 
378     * @see Declaration#signature
379     */
380    public Vector<HTMLNode> signature() { return signature.html; }
381
382    /**
383     * Returns an HTML-{@code Vector} of the HTML used to display the
384     * <B STYLE='color: red;'>description</B> of a detail element.
385     * 
386     * <BR /><BR />This HTML is generated by the Java Doc Tool using the text provided by a
387     * programmer in his Java Doc Comments directly above the code in a {@code '.java'} file.  In
388     * a Java Doc {@code '.html'} file, the description is always surrounded by an HTML divider
389     * ({@code '<DIV>'}) element, as appears below:
390     * 
391     * <DIV CLASS=HTML>{@code
392     * <div class="block"> ... [Text-Description of Method, Field, etc...] ... </div>
393     * }</DIV>
394     * 
395     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
396     * 
397     * @return An HTML-{@code Vector} of the Java Doc <B STYLE='color: red;'>description</B>
398     * segment of this detail.  Since a description is not mandatory, and it is not an
399     * auto-generated segment of a detail element, <I>this method will return null if a programmer
400     * has not written or included a description for this particular detail element in his
401     * source-code for this detail element.</I>
402     * 
403     */
404    public final Vector<HTMLNode> description()
405    {
406        SubSection s = subSections.get(ReflMapKeys.DESCRIPTION_KEY);
407        return (s!= null) ? s.html : null;
408    }
409
410    /**
411     * Returns an HTML-{@code Vector} of the HTML used to display the
412     * <B STYLE='color: red;'>Default Annotation Element Value</B> of an Annotation-Detail element.
413     * 
414     * <BR /><BR />This also contains the same information as in the field
415     * {@link AnnotationElem#defaultValue}, which is reflected (using <B>{@code Java Parer}</B>)
416     * from the associated {@code 'java'} source-code file.  The HTML for this segment is listed,
417     * here below:
418     * 
419     * <DIV CLASS=HTML>{@code
420     * <dl>
421     * <dt>Default:</dt>
422     * <dd> [ some values possibly inserted here ]</dd>
423     * </dl>
424     * }</DIV>
425     * 
426     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
427     * 
428     * <BR /><BR />Unless this detail is an "Annotation Detail", calling this method will generate
429     * an exception-throw.
430     * 
431     * @return An HTML-{@code Vector} of an annotation detail element's
432     * <B STYLE='color: red;'>Default Value</B>.  If the annotation does not have a default value
433     * assigned, or it is not present on the Java Doc Page, this method will return null.
434     * 
435     * @throws UpgradeException If the {@code ReflHTML} instance on which this method is being
436     * invoked is not for an Annotation Detail, the invocation will generate a
437     * {@code UpgradeException}
438     * 
439     * @see AnnotationElem#defaultValue
440     */
441    public Vector<HTMLNode> annotationDefault()
442    {
443        if (entityAsEnum != Entity.ANNOTATION_ELEM)
444
445            throw new UpgradeException(
446                "This ReflHTML is a Reflection of a(n) " + entityAsEnum.toString() + " details, " +
447                "however only Annotations may have Annotation-Element Default Values."
448            );
449
450        SubSection s = subSections.get(ReflMapKeys.ANNOTATION_DEFAULT_KEY);
451        return (s!= null) ? s.html : null;
452    }
453
454    /**
455     * Returns an HTML-{@code Vector} of the HTML used to display the
456     * <B STYLE='color: red;'>Returns:</B> segment of a Method Detail element.
457     * 
458     * <BR /><BR />This also contains some of the information present in the field
459     * {@link Method#returnType}, which is reflected (using <B>{@code Java Parer}</B>) from the
460     * associated {@code 'java'} source-code file.
461     * 
462     * <BR /><BR />This HTML is auto-generated by Java Doc using the
463     * <B><CODE STYLE='color: blue;'>&commat;return</CODE></B> taglet's, which may be provided
464     * by a programmer in his {@code '.java'} source-code file.  The HTML output generated by Java
465     * Doc is as below:
466     * 
467     * <DIV CLASS=HTML>{@code
468     * <dt><span class="returnLabel">Returns:</span></dt>
469     * <dd> [User-Provided Return-Value Information, as HTML, Here] </dd>
470     * }</DIV>
471     * 
472     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
473     * 
474     * <BR /><BR />Only methods may have return-values.  Furthermore, only methods for which the
475     * programmer has provided a <B><CODE STYLE='color: blue;'>&commat;return</CODE></B>
476     * taglet entry will the result of this method be non-null.
477     * 
478     * @return An HTML-{@code Vector} of a method detail element's
479     * <B STYLE='color: red;'>Returns:</B> label.  If the method does not have such a label,
480     * because the programmer did not provide a
481     * <B><CODE STYLE='color: blue;'>&commat;return</CODE></B> taglet, this method will
482     * return null.
483     * 
484     * @throws UpgradeException If the {@code ReflHTML} instance on which this method is being
485     * invoked is not for an Method Detail, the invocation will generate a
486     * {@code UpgradeException}
487     * 
488     * @see Method#returnType
489     */
490    public Vector<HTMLNode> returns()
491    {
492        if (entityAsEnum != Entity.METHOD)
493
494            throw new UpgradeException(
495                "This ReflHTML is a Reflection of a(n) " + entityAsEnum.toString() + " details, " +
496                "however only Methods may have Return-Values."
497            );
498
499        SubSection s = subSections.get(ReflMapKeys.RETURNS_KEY);
500        return (s!= null) ? s.html : null;
501    }
502
503    /**
504     * Returns an HTML-{@code Vector} of the HTML used to display the
505     * <B STYLE='color: red;'>See Also:</B> segment of any detail element.
506     * 
507     * <BR /><BR />This HTML is auto-generated by Java Doc using the
508     * <B><CODE STYLE='color: blue;'>&commat;see</CODE></B> taglet's, which may be provided
509     * by a programmer in his {@code '.java'} source-code file.  The HTML output generated by Java
510     * Doc is as below:
511     * 
512     * <DIV CLASS=HTML>{@code
513     * <dt><span class="seeLabel">See Also:</span></dt>
514     * <dd><a href="#someMethod()"><code>someMethod()</code></a></dd>
515     * }</DIV>
516     * 
517     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
518     * 
519     * <BR /><BR />Only detail elements for which the programmer has provided at least one
520     * <B><CODE STYLE='color: blue;'>&commat;see</CODE></B> taglet entry will the result of
521     * this method be non-null.
522     * 
523     * @return An HTML-{@code Vector} of a method detail element's
524     * <B STYLE='color: red;'>See Also:</B> label.  If the method does not have such a label,
525     * because the programmer did not provide any
526     * <B><CODE STYLE='color: blue;'>&commat;see</CODE></B> taglet, this method will
527     * return null.
528     * 
529     */
530    public Vector<HTMLNode> seeAlso()
531    {
532        SubSection s = subSections.get(ReflMapKeys.SEE_ALSO_KEY);
533        return (s!= null) ? s.html : null;
534    }
535
536    /**
537     * Returns an HTML-{@code Vector} of the HTML used to display the
538     * <B STYLE='color: red;'>Throws:</B> segment of a Method or Constructor Detail element.
539     * 
540     * <BR /><BR />This also contains some of the information present in the field
541     * {@link Callable#exceptions}, which is reflected (using <B>{@code Java Parer}</B>) from the
542     * associated {@code 'java'} source-code file.
543     * 
544     * <BR /><BR />This HTML is auto-generated by Java Doc using the
545     * <B><CODE STYLE='color: blue;'>&commat;throws</CODE></B> taglet's, which may be provided
546     * by a programmer in his {@code '.java'} source-code file.  If a method or constructor is
547     * throwing <I>checked exceptions</I>, Java Doc will auto-create a 'Throws:' label / segment.
548     * The HTML output generated by Java Doc is as below:
549     * 
550     * <DIV CLASS=HTML>{@code
551     * <dt><span class="throwsLabel">Throws:</span></dt>
552     * <dd> [Text explaining thrown exceptions by a method or constructor]</dd>
553     * }</DIV>
554     * 
555     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
556     * 
557     * <BR /><BR />Only methods and constructors are capable of throwing exceptions.  Furthermore,
558     * only details for which the programmer has provided a
559     * <B><CODE STYLE='color: blue;'>&commat;throws</CODE></B> taglet entry (or which throw
560     * checked-exceptions) will the result of this method be non-null.
561     * 
562     * @return An HTML-{@code Vector} of a method or constructor detail element's
563     * <B STYLE='color: red;'>Throws:</B> label.  If the detail does not have such a label, this
564     * method will return null.
565     * 
566     * @throws UpgradeException If the {@code ReflHTML} instance on which this method is being
567     * invoked is <I><B>neither</B></I> a Method Detail <B><I>nor</I></B> a Constructor Detail, the
568     * invocation will generate a {@code UpgradeException}
569     * 
570     * @see Callable#exceptions
571     */
572    public Vector<HTMLNode> throwing()
573    {
574        if ((entityAsEnum != Entity.METHOD) && (entityAsEnum != Entity.CONSTRUCTOR))
575
576            throw new UpgradeException(
577                "This ReflHTML is a Reflection of a(n) " + entityAsEnum.toString() + " details, " +
578                "however only Methods and Constructors may throw Exceptions."
579            );
580
581        SubSection s = subSections.get(ReflMapKeys.THROWS_KEY);
582        return (s!= null) ? s.html : null;
583    }
584
585    /**
586     * Returns an HTML-{@code Vector} of the HTML used to display the
587     * <B STYLE='color: red;'>Parmeters:</B> segment of a Method or Constructor Detail element.
588     * 
589     * <BR /><BR />This also contains some of the information present in the fields
590     * {@link Callable#parameterNames} and {@link Callable#parameterTypes}, which is reflected
591     * (using <B>{@code Java Parer}</B>) from the associated {@code 'java'} source-code file.
592     * 
593     * <BR /><BR />This HTML is auto-generated by Java Doc using the
594     * <B><CODE STYLE='color: blue;'>&commat;param</CODE></B> taglet's, which may be provided
595     * by a programmer in his {@code '.java'} source-code file.  The HTML output generated by Java
596     * Doc is as below:
597     * 
598     * <DIV CLASS=HTML>{@code
599     * <dt><span class="paramLabel">Parameters:</span></dt>
600     * <dd><code>[Parameter Name]</code> - [Some Parameter Description]</dd>
601     * }</DIV>
602     * 
603     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
604     * 
605     * <BR /><BR />Only methods and constructors may accept input parameters.  Furthermore,
606     * only details for which the programmer has provided a
607     * <B><CODE STYLE='color: blue;'>&commat;param</CODE></B> taglet entry will there be 
608     * parameter descriptive-text on a Java Doc Page. The result of this method will be non-null,
609     * only in cases where such descriptions have been included in their JavaDoc commenting.
610     * 
611     * @return An HTML-{@code Vector} of a method or constructor detail element's
612     * <B STYLE='color: red;'>Parameters:</B> label.  If the detail does not have such a label,
613     * this method will return null.
614     * 
615     * @throws UpgradeException If the {@code ReflHTML} instance on which this method is being
616     * invoked is <I><B>neither</B></I> a Method Detail <B><I>nor</I></B> a Constructor Detail, the
617     * invocation will generate a {@code UpgradeException}
618     * 
619     * @see Callable#parameterNames
620     * @see Callable#parameterTypes
621     */
622    public Vector<HTMLNode> parameters()
623    {
624        if ((entityAsEnum != Entity.METHOD) && (entityAsEnum != Entity.CONSTRUCTOR))
625
626            throw new UpgradeException(
627                "This ReflHTML is a Reflection of a " + entityAsEnum.toString() + " details, " +
628                "however only Methods and Constructors may have Parameters."
629            );
630
631        SubSection s = subSections.get(ReflMapKeys.PARAMETERS_KEY);
632        return (s!= null) ? s.html : null;
633    }
634
635    /**
636     * Returns an HTML-{@code Vector} of the HTML used to display the
637     * <B STYLE='color: red;'>Type Parmeters:</B> segment of a Method or Constructor Detail
638     * element.
639     * 
640     * <BR /><BR />This HTML is auto-generated by Java Doc using the
641     * <B><CODE STYLE='color: blue;'>&commat;param</CODE> <CODE>&lt;T&gt;</CODE></B> taglet's,
642     * which may be provided by a programmer in his {@code '.java'} source-code file.  The HTML
643     * output generated by Java Doc is as below:
644     * 
645     * <DIV CLASS=HTML>{@code
646     * <dt><span class="paramLabel">Type Parameters:</span></dt>
647     * <dd><code>[Type Parameter <T>]</code> - [Some Type Parameter Description]</dd>
648     * }</DIV>
649     * 
650     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
651     * 
652     * <BR /><BR />Only methods and constructors will allow type-parameters.  Furthermore,
653     * only details for which the programmer has provided a
654     * <B><CODE STYLE='color: blue;'>&commat;param</CODE> <CODE>&lt;T&gt;</CODE></B> taglet
655     * entry will there be parameter descriptive-text on a Java Doc Page. The result of this method
656     * will be non-null, only in cases where such descriptions have been included in their
657     * JavaDoc commenting.
658     * 
659     * @return An HTML-{@code Vector} of a method or constructor detail element's
660     * <B STYLE='color: red;'>Type Parameters:</B> label.  If the detail does not have such a
661     * label, this method will return null.
662     * 
663     * @throws UpgradeException If the {@code ReflHTML} instance on which this method is being
664     * invoked is <I><B>neither</B></I> a Method Detail <B><I>nor</I></B> a Constructor Detail, the
665     * invocation will generate a {@code UpgradeException}
666     */
667    public Vector<HTMLNode> typeParameters()
668    {
669        if ((entityAsEnum != Entity.METHOD) && (entityAsEnum != Entity.CONSTRUCTOR))
670
671            throw new UpgradeException(
672                "This ReflHTML is a Reflection of a(n) " + entityAsEnum.toString() + " details, " +
673                "however only Methods and Constructors may have Type-Parameters."
674            );
675
676        SubSection s = subSections.get(ReflMapKeys.TYPE_PARAMETERS_KEY);
677        return (s!= null) ? s.html : null;
678    }
679
680    /**
681     * Returns an HTML-{@code Vector} of the HTML used to display the
682     * <B STYLE='color: red;'>Overrides:</B> segment of a Method Detail element.
683     * 
684     * <BR /><BR />This HTML is auto-generated by Java Doc, for methods which override a parent
685     * class or interface. The HTML output generated by Java Doc is as below:
686     * 
687     * <DIV CLASS=HTML>{@code
688     * <dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
689     * <dd><code> [ Some Name ]</code>&nbsp;in interface&nbsp;<code> [Interface Name] </code></dd>
690     * }</DIV>
691     * 
692     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
693     * 
694     * <BR /><BR />Only methods may override other methods.  The result of this method will
695     * be non-null, only in cases where the Method Detail on which this invocation was made is
696     * actually an overrided method.
697     * 
698     * @return An HTML-{@code Vector} of a method detail element's
699     * <B STYLE='color: red;'>Overrides:</B> label.  If the detail does not have such a label, this
700     * method will return null.
701     * 
702     * @throws UpgradeException If the {@code ReflHTML} detail instance on which this method is
703     * being invoked is not a Method Detail, then a {@code UpgradeException} will throw.
704     */
705    public Vector<HTMLNode> overrides()
706    {
707        if (entityAsEnum != Entity.METHOD)
708
709            throw new UpgradeException(
710                "This ReflHTML is a Reflection of a(n) " + entityAsEnum.toString() + " details, " +
711                "however only Methods may have \"Overrides:\" Labels."
712            );
713
714        SubSection s = subSections.get(ReflMapKeys.OVERRIDES_KEY);
715        return (s!= null) ? s.html : null;
716    }
717
718    /**
719     * Returns an HTML-{@code Vector} of the HTML used to display the
720     * <B STYLE='color: red;'>Specified by:</B> segment of a Method Detail element.
721     * 
722     * <BR /><BR />This HTML is auto-generated by Java Doc, for methods which implement another
723     * method that was specified by an interface which the type implements, or a method specified
724     * by an abstract parent super-class.  The HTML output generated by Java Doc is as below:
725     * 
726     * <DIV CLASS=HTML>{@code
727     * <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
728     * <dd><code> [ Some Name ]</code>&nbsp;in interface&nbsp;<code> [Interface Name] </code></dd>
729     * }</DIV>
730     * 
731     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
732     * 
733     * <BR /><BR />Only methods may implement a "specified-method" (obviously!)  The result of this
734     * method will be non-null - only in cases where the Method Detail on which this invocation was
735     * made <I>actually implements another abstract method declaration.</I>
736     * 
737     * @return An HTML-{@code Vector} of a method detail element's
738     * <B STYLE='color: red;'>Specified by:</B> label.  If the detail does not have such a label,
739     * this method will return null.
740     * 
741     * @throws UpgradeException If the {@code ReflHTML} detail instance on which this method is
742     * being invoked is not a Method Detail, then a {@code UpgradeException} will throw.
743     */
744    public Vector<HTMLNode> specifiedBy()
745    {
746        if (entityAsEnum != Entity.METHOD)
747
748            throw new UpgradeException(
749                "This ReflHTML is a Reflection of a(n) " + entityAsEnum.toString() + " details, " +
750                "however only Methods may have \"Specified-By:\" Labels."
751            );
752
753        SubSection s = subSections.get(ReflMapKeys.SPECIFIED_BY_KEY);
754        return (s!= null) ? s.html : null;
755    }
756
757    /** This will be implented at a later date.  For now, this throws an exception. */
758    public Vector<HTMLNode> author()
759    {
760        if (1 == 1) throw new Torello.Java.ToDoException("Not Tested Yet");
761
762        SubSection s = subSections.get(ReflMapKeys.AUTHOR_KEY);
763        return (s!= null) ? s.html : null;
764    }
765
766    /**
767     * Returns an HTML-{@code Vector} of the HTML used to display the
768     * <B STYLE='color: red;'>Specified by:</B> segment of a Method Detail element.  
769     *  
770     * <DIV CLASS=HTML>{@code
771     * <dt><span class="simpleTagLabel">Since:</span></dt>
772     * <dd> [ Version Number Information ]</dd>
773     * }</DIV>
774     * 
775     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
776     * 
777     * <BR /><BR />Only details for which the programmer has provided a
778     * <B><CODE STYLE='color: blue;'>&commat;since</CODE></B> taglet entry will there be 'since'
779     * descriptive-text on a Java Doc Page. The result of this method will be non-null, only in
780     * cases where such version-information has been included in their JavaDoc commenting.
781     * 
782     * @return An HTML-{@code Vector} of a method detail element's
783     * <B STYLE='color: red;'>Since:</B> label.  If the detail does not have such a label, this
784     * method will return null. 
785     */
786    public Vector<HTMLNode> since()
787    {
788        SubSection s = subSections.get(ReflMapKeys.SINCE_KEY);
789        return (s!= null) ? s.html : null;
790    }
791
792    /**
793     * Returns an HTML-{@code Vector} of the HTML used to display the
794     * <B STYLE='color: red;'>Navigation Button-Bar</B> of a detail element.
795     * 
796     * <BR /><BR />This is a row of buttons that is present directly below the signature of an
797     * HTML Detail-Entry.  This row of buttons is automatically generated by the Java-Doc Upgrader
798     * Tool.  It isn't Standard JavaDoc HTML.
799     * 
800     * <BR /><BR />The actual HTML inserted by the Upgrader-Tool is included directly below:
801     * 
802     * <DIV CLASS=HTML>{@code
803     * <DIV CLASS=DetailNav>
804     *      <A HREF='#openTagPWA()'>&#129093;</A>
805     *      &nbsp;<A HREF='#isOpenTagPWA()'>&#129095;</A>
806     *      &nbsp;<A onclick="flashSumm('MD244')">&#8648;</A>
807     *      &nbsp;<A HREF='hilite-files/HTMLNode.java.html#L273'>&#11179;</A>
808     *      <SPAN>
809     *          <A onclick='minimize(244)'>&#x1F5D5;</A>
810     *          &nbsp;<A onclick='partialize(244)'>&#x1F5D7;</A>
811     *          &nbsp;<A onclick='maximize(244)'>&#x1F5D6;</A>
812     *      </SPAN>
813     *      <NOSCRIPT>
814     *      <DIV ID=NoScriptMPMAB>JavaScript is disabled on your browser.</DIV>
815     *      </NOSCRIPT>
816     * </DIV>
817     * }</DIV>
818     * 
819     * <EMBED CLASS='external-html' DATA-FILE-ID=REFL_MODIFY>
820     * 
821     * @return An HTML-{@code Vector} of the Java Doc
822     * <B STYLE='color: red;'>Navigation Button-Bar</B> segment of this detail.  This method will
823     * never return null, as all detail-elements have these buttons.
824     */
825    public Vector<HTMLNode> detailNavBar()
826    { return detailNavBar; }
827
828
829    // ********************************************************************************************
830    // ********************************************************************************************
831    // java.lang.Cloneable, java.lang.Comparable
832    // ********************************************************************************************
833    // ********************************************************************************************
834
835
836    /**
837     * Java's {@code interface Cloneable} requirements.  This provides a "Deep Clone", where all
838     * internal {@code Vector's} and {@code SubSection's} are also cloned, rather than a
839     * "Shallow Clone", having identical references.
840     * 
841     * @return A new {@code ReflHTML} whose internal fields are identical to this one.
842     */
843    public ReflHTML<ENTITY> clone() { return new ReflHTML<>(this); }
844
845    // Clone Constructor.
846    @SuppressWarnings("unchecked")
847    ReflHTML(ReflHTML<ENTITY> other)
848    {
849        this.entity                     = other.entity; /* not cloned, the reflected entity */
850        this.entityAsEnum               = other.entityAsEnum;
851        this.location                   = other.location; /* immutable, no need to clone */
852        this.endingLI                   = other.endingLI;
853        this.htmlID                     = other.htmlID;
854        this.openingUL                  = other.openingUL;
855        this.name                       = other.name.clone();
856        this.nameAsStr                  = other.nameAsStr;
857        this.fullNameNoGenerics         = other.fullNameNoGenerics;
858        this.signature                  = other.signature.clone();
859        this.secondDescFromTypeLabel    = other.secondDescFromTypeLabel;
860
861        // The Code-HiLited Details "Special Additions"
862        this.hiLitedCodeTNI = other.hiLitedCodeTNI;
863
864        this.needToAddOpenCloseDLsForHiLitedDetails =
865            other.needToAddOpenCloseDLsForHiLitedDetails;
866
867        this.subSections = (TreeMap<Character,SubSection>) other.subSections.clone();
868
869
870        // Since the time when this was converted to a "ReadOnlyList", this is no longer cloned,
871        // this reference is now just copied.  ReadOnly stuff doesn't need to be cloned.
872
873        this.miscSimpleTagLabels = other.miscSimpleTagLabels;
874    }
875
876    /**
877     * Java's {@code interface Comparable<T>} requirements.  This does a very simple comparison
878     * using the {@code location} field.
879     * 
880     * <BR /><BR /><B><SPAN STYLE="color: red;">FINAL METHOD:</B></SPAN> This method is declared 
881     * {@code final}, and cannot be modified by sub-classes.
882     * 
883     * @param other Any other {@code ReflHTML} to be compared to {@code 'this' ReflHTML}
884     * 
885     * @return An integer that fulfils Java's {@code interface Comparable<T> public boolean
886     * compareTo(T t)} method requirements.
887     * 
888     * @see DotPair#compareTo(DotPair)
889     */
890    public final int compareTo(ReflHTML other)
891    { return this.location.compareTo(other.location); }
892
893
894    // ********************************************************************************************
895    // ********************************************************************************************
896    // Rebuilding a ReflHTML from it's pieces
897    // ********************************************************************************************
898    // ********************************************************************************************
899
900
901    private static final Vector<HTMLNode> TEMP_END_VEC = new Vector<>(1);
902
903    TreeSet<Replaceable> allReplaceables()
904    {
905        TreeSet<Replaceable> replaceables = new TreeSet<>();
906        SubSection ss = null;
907
908        replaceables.add(this.openingUL);
909        replaceables.add(this.name);
910
911        replaceables.add
912            (Replaceable.createInsertion(this.name.location.end + 1, this.detailNavBar));
913
914        replaceables.add(this.signature);
915
916
917        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
918        // Add "Maximize-Partialize-Minimize" Button <DIV>'s - EMBARRASING THAT THIS IS DONE HERE
919        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
920        //
921        // It seems like this isn't the best place to do this, but I simply am at a loss for words
922        // about where I *SHOULD* put this stuff.
923
924        this.signature.html.add(
925            0,
926            new TextNode("<DIV CLASS=ORD ID=ORD" + this.entity.id + ">\n")
927        );
928
929        this.signature.html.add
930            (new TextNode("\n<DIV CLASS=IRD ID=IRD" + this.entity.id + ">\n"));
931
932        Vector<HTMLNode> TEMP_VEC = new Vector<>();
933
934        TEMP_VEC.add(
935            new TextNode(
936                "\n</DIV> <!-- IRD" + this.entity.id + " -->" +
937                "\n</DIV> <!-- ORD" + this.entity.id + " -->\n\n"
938            )
939        );
940
941
942        // NOTE:    The "Closing-</DIV>" stuff is inserted into the "Ending-</LI>".
943        // HOWEVER: This </LI> shares a "TagNodeIndex" (on occasion, not always) with the Hi-Lited
944        //          Source-Code Insert TNI.
945        // 
946        // This means IT IS IMERATIVE to add the this TextNode at the Second-To-Last Node inside
947        // this Vector.  The closing </DIV>'s must come after the Hi-Lited Code, and before the 
948        // actual Closing-</LI>
949
950        final Vector<HTMLNode> endingLIVec = endingLI.currentNodes();
951
952        endingLIVec.addAll(endingLIVec.size() - 1, TEMP_VEC);
953
954        replaceables.add(endingLI);
955
956
957        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
958        // All of the other's
959        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
960
961        if ((ss = this.subSections.get(ReflMapKeys.DESCRIPTION_KEY)) != null)
962            replaceables.add(ss);
963
964        if ((ss = this.subSections.get(ReflMapKeys.ANNOTATION_DEFAULT_KEY)) != null)
965            replaceables.add(ss);
966
967        if ((ss = this.subSections.get(ReflMapKeys.RETURNS_KEY)) != null)
968            replaceables.add(ss);
969
970        if ((ss = this.subSections.get(ReflMapKeys.SEE_ALSO_KEY)) != null)
971            replaceables.add(ss);
972
973        if ((ss = this.subSections.get(ReflMapKeys.THROWS_KEY)) != null)
974            replaceables.add(ss);
975
976        if ((ss = this.subSections.get(ReflMapKeys.PARAMETERS_KEY)) != null)
977            replaceables.add(ss);
978
979        if ((ss = this.subSections.get(ReflMapKeys.TYPE_PARAMETERS_KEY)) != null)
980            replaceables.add(ss);
981
982        if ((ss = this.subSections.get(ReflMapKeys.OVERRIDES_KEY)) != null)
983            replaceables.add(ss);
984
985        if ((ss = this.subSections.get(ReflMapKeys.SPECIFIED_BY_KEY)) != null)
986            replaceables.add(ss);
987
988        if ((ss = this.subSections.get(ReflMapKeys.AUTHOR_KEY)) != null)
989            replaceables.add(ss);
990
991        if ((ss = this.subSections.get(ReflMapKeys.SINCE_KEY)) != null)
992            replaceables.add(ss);
993
994
995        // NOTE: If the "Ending-<LI> Pointer" was re-used, then this would be the second
996        //       time that the "EndingLI" TagNodeIndex-Reference were added to this TreeSet.
997        //
998        // Luckily, a TreeSet doesn't allow multiple copies of the sam reference into its
999        // data-structure
1000        // 
1001        // There are two different "Variants" for which "TNI" is assigned to the Hi-Lited-Code TNI
1002        // If there were already a <DL> ... </DL> List, then the Hi-Lited Source-Code HTML is 
1003        // inserted right before the Closing-</DL>
1004        // 
1005        // If the user didn't add enough Java-Doc Documentation to his original source, then it 
1006        // may be possible that no <DL> ... </DL> has been created.  In such a case, the code 
1007        // creates a <DL> and inserts the Hi-Lited Source-Code HTML directly before the 
1008        // Closing-</LI> instead !!
1009
1010        replaceables.add(this.hiLitedCodeTNI);
1011
1012        /*
1013        if (this.fullNameNoGenerics.equals("Torello.HTML.TagNode"))
1014
1015            for (Replaceable r : replaceables)
1016
1017                if (r.originalLocationStart() == 5541)
1018                {
1019                    System.out.println(
1020                        "=========================================\n" +
1021                        "r.summarize(true):\n" +
1022                        r.summarize(true) + 
1023                        "=========================================\n" +
1024                        "this.hiLitedCode.summarize(true):\n" +
1025                        this.hiLitedCodeTNI.summarize(true) +
1026                        "=========================================\n"
1027                    );
1028
1029                    Torello.Java.Q.BP();
1030                }
1031        */
1032
1033        return replaceables;
1034    }
1035
1036
1037    // ********************************************************************************************
1038    // ********************************************************************************************
1039    // THE NEW-THING: Garbage-Collector Helper?
1040    // ********************************************************************************************
1041    // ********************************************************************************************
1042    // 
1043    // Does this help?  Is this "good" for the Garbage-Collect?  Is this going to speed it up,
1044    // or slow it down?  This is just a "C-Styled" FREE or DESTORY method...
1045    // It isn't publicly visible anyway...
1046    //
1047    // NOTE: Many of the null checks are completely superfluous, but not all of them...
1048    //       In any case, the worst feeling in the world would be NPE for this silly little
1049    //       "optimization"
1050
1051    void clear()
1052    {
1053        // public final TagNodeIndex openingUL;
1054        if (this.openingUL != null) this.openingUL.n = null;
1055
1056        // private final SubSection name;
1057        if (this.name != null) { this.name.html.clear(); name.html = null; }
1058
1059        // private final SubSection signature;
1060        if (this.signature != null) { this.signature.html.clear(); signature.html = null; }
1061
1062        // private final TreeMap<Character, SubSection> subSections = new TreeMap<>();
1063        if (this.subSections != null)
1064        {
1065            for (final SubSection ss : this.subSections.values())
1066            {
1067                ss.html.clear();
1068                ss.html = null;
1069            }
1070
1071            this.subSections.clear();
1072        }
1073
1074        // private Replaceable hiLitedCode = null;
1075        if (this.hiLitedCodeTNI != null) { this.hiLitedCodeTNI.clearHTML(); }
1076    }
1077}