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
package Torello.HTML.Tools.JavaDoc;

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

import java.util.*;
import java.io.*;

/**
 * <CODE>Details Class Documentation.</CODE><BR /><BR />
 * <EMBED CLASS="external-html" DATA-FILE-ID="DETMAINDESC">
 */
@StaticFunctional
public class Details
{
    private Details() { }

    /**
     * When a {@code JavaDocError} is thrown looking for a <B>Details Section,</B> this message
     * shall be produced.  JavaDoc will always produce a details section - however there have been
     * (some, not many) situations where the output HTML was not properly formatted.  This can be
     * remedied, but it is advisable to inspect what has caused the problem, and repair the HTML
     * first.
     *
     * <BR /><BR /><B>NOTE:</B> This particular error message is used only when the
     * {@code CommentNode} that looks like below is missing:
     * <BR />{@code '========= FIELD DETAIL =========='}
     *
     * <BR /><BR /><B><SPAN STYLE="color: red;">NOTE: </B></SPAN>
     * 
     * <BR /><BR /><UL CLASS="JDUL">
     * <LI> {@code TOK1} will be replaced by the word: {@code Field, Constructor} or
     *      {@code Method}.
     *      <BR /><BR />
     * </LI>
     * <LI> {@code TOK2} will be replaced by the word: {@code FIELD, CONSTRUCTOR} or
     *      {@code METHOD}.
     *      <BR />
     * </LI>
     * </UL>
     */
    protected static final String errorMsg1 =
        "Could not find a TOK1 Details Section in this JavaDoc Page.  " +
        "Returned DotPair would be null.  JavaDoc Class HTML Page did not have " +
        "a CommentNode whose body contained sub-string '======= TOK2 DETAIL ======='.  " +
        "Java Error.";

    /**
     * When a {@code JavaDocError} is thrown looking for a <B>Details Section,</B> this message
     * shall be produced. JavaDoc will always produce a details section - however there have been
     * (some, not many) situations where the output HTML was not properly formatted.  This can be
     * remedied, but it is advisable to inspect what has caused the problem, and repair the HTML
     * first.  There are also occasions when a class does not have have {@code Field's}, or
     * {@code Constructor's} - or possibly even {@code Method's.}
     *
     * <BR /><BR /><B>NOTE:</B> This particular error message is used only when the following
     * Unordered list seems to be missing.  This should not happen, but this is used with an
     * instance of the {@code 'Error' Throwable.}
     *
     * <BR /><BR /><B><SPAN STYLE="color: red;">NOTE: </B></SPAN>
     * {@code TOK} will be replaced by the word: {@code Field, Constructor} or {@code Method}.
     */
    protected static final String errorMsg2 =
        "Could not find a TOK Details Section in this JavaDoc Page.  " +
        "Returned DotPair would be null.  JavaDoc Class HTML Page did not have " +
        "a TagNode of HTML Element type <UL class='blockNode'>.  Java Error.";

    /**
     * When a {@code JavaDocError} is thrown looking for the "sublist {@code <UL>...</UL>} 
     * <B>Details Section,</B> this message shall be produced.  JavaDoc will always produce a
     * details section - however there have been (very few) situations where the output HTML was
     * not properly formatted.  This can be remedied, but it is advisable to inspect what has
     * caused the problem, and repair the HTML first.
     *
     * <BR /><BR /><B><SPAN STYLE="color: red;">NOTE: </B></SPAN>
     * {@code TOK} will be replaced by the word: {@code Field, Constructor} or {@code Method}.
     */
    protected static final String errorMsg3 = 
        "Search for TOK Summaries in this JavaDoc Page returned a null-valued Iterator.  " +
        "Class HNLIInclusive was not instantiated when searching for HTML <UL> Elements having " +
        "'class' Attributes = 'rowColor' or 'altColor.'  Java Error.";

    // ********************************************************************************************
    // ********************************************************************************************
    // Retrieve Details - Entire 'Details' Section
    // ********************************************************************************************
    // ********************************************************************************************

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="JDDETMETH">
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return An instance of {@code class DotPair} that points to the begin and end index
     * locations of input parameter {@code 'javaDocHTMLCIETPage'} were the primary <B>'Details
     * Section'</B> resides.
     * @see Torello.HTML.NodeSearch.AVT
     * @see Torello.HTML.NodeSearch.InnerTagFindInclusive
     * @see Torello.HTML.DotPair
     */
    public static DotPair details(Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        DotPair ret = InnerTagFindInclusive.first
            (javaDocHTMLCIETPage, "div", "class", TextComparitor.C, "details");

        if (ret == null) throw new JavaDocError
            ("Could not find an HTML Divider Element whose class attribute was class='details'");

        return ret;
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Retrieve Details - Complete Section
    // ********************************************************************************************
    // ********************************************************************************************

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="JDCONDET">
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return <EMBED CLASS='external-html' DATA-FILE-ID=DETAILDPRET>
     * @see Torello.HTML.NodeSearch.CommentNodeFind
     * @see Torello.HTML.NodeSearch.InnerTagFindInclusive
     * @see Torello.HTML.DotPair
     * @throws JavaDocError <EMBED CLASS="external-html" DATA-FILE-ID="JDERRUL">
     */
    public static DotPair constructorDetails (Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        int constructorDetailsPos = CommentNodeFind.first
            (javaDocHTMLCIETPage, TextComparitor.CN_CI, "== CONSTRUCTOR DETAIL ==");

        if (constructorDetailsPos == -1) throw new JavaDocError(
            errorMsg1.replace("TOK1", "Constructor").replace("TOK2", "CONSTRUCTOR")
        );

        DotPair ret = InnerTagFindInclusive.first(
            javaDocHTMLCIETPage, constructorDetailsPos, -1, "ul", "class",
            TextComparitor.C, "blockList"
        );

        if (ret == null) throw new JavaDocError(errorMsg2.replace("TOK", "Constructor"));

        return ret;
    }

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="JDFDET">
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">  
     * @return <EMBED CLASS='external-html' DATA-FILE-ID=DETAILDPRET>
     * @see Torello.HTML.NodeSearch.CommentNodeFind
     * @see Torello.HTML.NodeSearch.InnerTagFindInclusive
     * @see Torello.HTML.DotPair
     * @throws JavaDocError <EMBED CLASS="external-html" DATA-FILE-ID="JDERRUL">
     */
    public static final DotPair fieldDetails(Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        int fieldDetailsPos = CommentNodeFind.first
            (javaDocHTMLCIETPage, TextComparitor.CN_CI, "== FIELD DETAIL ==");

        if (fieldDetailsPos == -1) throw new JavaDocError(
            errorMsg1.replace("TOK1", "Field").replace("TOK2", "FIELD")
        );

        DotPair ret = InnerTagFindInclusive.first(
            javaDocHTMLCIETPage, fieldDetailsPos, -1, "ul", "class",
            TextComparitor.C, "blockList"
        );

        if (ret == null) throw new JavaDocError(errorMsg2.replace("TOK", "Field"));

        return ret;
    }

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="JDECDET"> 
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return <EMBED CLASS='external-html' DATA-FILE-ID=DETAILDPRET>
     * @see Torello.HTML.NodeSearch.CommentNodeFind
     * @see Torello.HTML.NodeSearch.InnerTagFindInclusive
     * @see Torello.HTML.DotPair
     * @throws JavaDocError <EMBED CLASS="external-html" DATA-FILE-ID="JDERRUL">
     */
    public static final DotPair enumConstDetails(Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        int fieldDetailsPos = CommentNodeFind.first
            (javaDocHTMLCIETPage, TextComparitor.CN_CI, "== ENUM CONSTANT DETAIL ==");

        if (fieldDetailsPos == -1) throw new JavaDocError(
            errorMsg1.replace("TOK1", "Enumerated-Constant").replace("TOK2", "ENUM CONSTANT")
        );

        DotPair ret = InnerTagFindInclusive.first(
            javaDocHTMLCIETPage, fieldDetailsPos, -1, "ul", "class",
            TextComparitor.C, "blockList"
        );

        if (ret == null) throw new JavaDocError(errorMsg2.replace("TOK", "Enumerated-Constant"));

        return ret;
    }

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="JDMETHDET">
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return <EMBED CLASS='external-html' DATA-FILE-ID=DETAILDPRET>
     * @see Torello.HTML.NodeSearch.CommentNodeFind
     * @see Torello.HTML.NodeSearch.InnerTagFindInclusive
     * @see Torello.HTML.DotPair
     * @throws JavaDocError <EMBED CLASS="external-html" DATA-FILE-ID="JDERRUL">
     */
    public static DotPair methodDetails (Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        int methodDetailsPos = CommentNodeFind.first
            (javaDocHTMLCIETPage, TextComparitor.CN_CI, "== METHOD DETAIL ==");

        if (methodDetailsPos == -1) throw new JavaDocError(
            errorMsg1.replace("TOK1", "Method").replace("TOK2", "METHOD")
        );

        DotPair ret = InnerTagFindInclusive.first(
            javaDocHTMLCIETPage, methodDetailsPos, -1, "ul", "class",
            TextComparitor.C, "blockList"
        );

        if (ret == null) throw new JavaDocError
            (errorMsg2.replace("TOK", "Method"));

        return ret;
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Retrieve Details - Complete Section, But Won't Throw JavaDocError
    // ********************************************************************************************
    // ********************************************************************************************


    /**
     * This method is identical to the method {@code DotPair constructorDetails(...)}, but it
     * catches the {@code JavaDocError}, and returns null instead.  Both methods are preserved in
     * this class, because there are, of course, situations where a class does not have a
     * Constructor Details Section.
     * 
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return <EMBED CLASS='external-html' DATA-FILE-ID=DETAILDPRET>
     * @see #constructorDetails(Vector)
     */
    public static DotPair hasConstructorDetails (Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        try
            { return constructorDetails(javaDocHTMLCIETPage); }
        catch (JavaDocError e)
            { return null; }
    }

    /**
     * This method is identical to the method {@code DotPair fieldDetails(...)}, but it catches
     * the {@code JavaDocError}, and returns null instead.  Both methods are preserved in this
     * class, because there are, of course, situations where a class does not have a Field Details
     * Section.
     * 
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return <EMBED CLASS='external-html' DATA-FILE-ID=DETAILDPRET>
     * @see #fieldDetails(Vector)
     */
    public static DotPair hasFieldDetails (Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        try
            { return fieldDetails(javaDocHTMLCIETPage); }
        catch (JavaDocError e)
            { return null; }
    }


    /**
     * This method is identical to the method {@code DotPair enumConstDetails(...)}, but it catches
     * the {@code JavaDocError}, and returns null instead.  Both methods are preserved in this
     * class, because there are, of course, situations where a class does not have an Enumerated
     * Constant Details Section.
     * 
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return <EMBED CLASS='external-html' DATA-FILE-ID=DETAILDPRET>
     * @see #fieldDetails(Vector)
     */
    public static DotPair hasEnumConstDetails (Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        try
            { return enumConstDetails(javaDocHTMLCIETPage); }
        catch (JavaDocError e) 
            { return null; }
    }

    /**
     * This method is identical to the method {@code DotPair methodDetails(...)}, but it catches
     * the {@code JavaDocError}, and returns null instead.  Both methods are preserved in this
     * class, because there are, of course, situations where a class does not have a Method Details
     * Section.
     * 
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return <EMBED CLASS='external-html' DATA-FILE-ID=DETAILDPRET>
     * @see #methodDetails(Vector)
     */
    public static DotPair hasMethodDetails (Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        try
            { return methodDetails(javaDocHTMLCIETPage); }
        catch (JavaDocError e)
            { return null; }
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Retrieve Summaries - HNLIInclusive Iterators
    // ********************************************************************************************
    // ********************************************************************************************


    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="JDCDITER">
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return <EMBED class='external-html' DATA-FILE-ID=DETHNLIRET>
     * <BR /><BR />The {@code <UL>} elements iterated contain {@code Constructor} definitions.
     * @see Torello.HTML.NodeSearch.InnerTagInclusiveIterator
     * @see Torello.HTML.NodeSearch.HNLIInclusive
     * @see #constructorDetails(Vector)
     * @throws JavaDocError <EMBED CLASS="external-html" DATA-FILE-ID="JDERRUL">
     */
    public static HNLIInclusive constructorDetailsIterator(Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        DotPair constructorDetailsSection = constructorDetails(javaDocHTMLCIETPage);

        HNLIInclusive ret = InnerTagInclusiveIterator.get
            (javaDocHTMLCIETPage, "ul", "class", TextComparitor.C, "blockList", "blockListLast");
            // <ul class='blockList'> is used for all entries, except the last in the last
            // <ul class='blockListLast'> is used for last entry.

        if (ret == null) throw new JavaDocError(errorMsg3.replace("TOK", "Constructor"));

        // '+ 1' is needed since there is an "outer <UL class='blockList'>" TagNode
        // ==>  The "Constructor Details (entire) Section" is 
        //      also a <UL CLASS='blockList'> too!
        ret.restrictCursor(constructorDetailsSection.start + 1, constructorDetailsSection.end);

        return ret;
    }

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="JDFDITER">
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return <EMBED class='external-html' DATA-FILE-ID=DETHNLIRET>
     * <BR /><BR />The {@code <UL>} elements iterated contain {@code Field} definitions.
     * @see Torello.HTML.NodeSearch.InnerTagInclusiveIterator
     * @see Torello.HTML.NodeSearch.HNLIInclusive
     * @see #fieldDetails(Vector)
     * @throws JavaDocError <EMBED CLASS="external-html" DATA-FILE-ID="JDERRUL">
     */
    public static HNLIInclusive fieldDetailsIterator(Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        DotPair fieldDetailsSection = fieldDetails(javaDocHTMLCIETPage);

        HNLIInclusive ret = InnerTagInclusiveIterator.get(javaDocHTMLCIETPage,
            "ul", "class", TextComparitor.C, "blockList", "blockListLast");
            // <ul class='blockList'> is used for all entries, except the last in the last
            // <ul class='blockListLast'> is used for last entry.

        if (ret == null) throw new JavaDocError(errorMsg3.replace("TOK", "Field"));

        // '+ 1' is needed since there is an "outer <UL class='blockList'>" TagNode
        // ==> The "Field Details (entire) Section" is also a <UL CLASS='blockList'> too!
        ret.restrictCursor(fieldDetailsSection.start + 1, fieldDetailsSection.end);

        return ret;
    }

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="JDECDITER">
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return <EMBED class='external-html' DATA-FILE-ID=DETHNLIRET>
     * <BR /><BR />The {@code <UL>} elements iterated contain {@code Enumerated-Constant}
     * definitions.
     * @see Torello.HTML.NodeSearch.InnerTagInclusiveIterator
     * @see Torello.HTML.NodeSearch.HNLIInclusive
     * @see #enumConstDetails(Vector)
     * @throws JavaDocError <EMBED CLASS="external-html" DATA-FILE-ID="JDERRUL">
     */
    public static HNLIInclusive enumConstDetailsIterator(Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        DotPair enumConstDetailsSection = enumConstDetails(javaDocHTMLCIETPage);

        HNLIInclusive ret = InnerTagInclusiveIterator.get(javaDocHTMLCIETPage,
            "ul", "class", TextComparitor.C, "blockList", "blockListLast");
            // <ul class='blockList'> is used for all entries, except the last in the last
            // <ul class='blockListLast'> is used for last entry.

        if (ret == null) throw new JavaDocError(errorMsg3.replace("TOK", "Enumerated-Constant"));

        // '+ 1' is needed since there is an "outer <UL class='blockList'>" TagNode
        // ==>  The "Enumerated-Constant Details (entire) Section" is 
        //      also a <UL CLASS='blockList'> too!
        ret.restrictCursor(enumConstDetailsSection.start + 1, enumConstDetailsSection.end);

        return ret;
    }

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="JDMDITER">
     * @param javaDocHTMLCIETPage <EMBED CLASS="external-html" DATA-FILE-ID="JDHCIETP">
     * @return <EMBED class='external-html' DATA-FILE-ID=DETHNLIRET>
     * <BR /><BR />The {@code <UL>} elements iterated contain {@code Method} definitions.
     * @see Torello.HTML.NodeSearch.InnerTagInclusiveIterator
     * @see Torello.HTML.NodeSearch.HNLIInclusive
     * @see #methodDetails(Vector)
     * @throws JavaDocError <EMBED CLASS="external-html" DATA-FILE-ID="JDERRUL">
     */
    public static HNLIInclusive methodDetailsIterator(Vector<HTMLNode> javaDocHTMLCIETPage)
    {
        DotPair methodDetailsSection = methodDetails(javaDocHTMLCIETPage);

        HNLIInclusive ret = InnerTagInclusiveIterator.get(javaDocHTMLCIETPage,
            "ul", "class", TextComparitor.C, "blockList", "blockListLast");
            // <ul class='blockList'> is used for all entries, except the last in the last
            // <ul class='blockListLast'> is used for last entry.

        if (ret == null) throw new JavaDocError(errorMsg3.replace("TOK", "Method"));

        // '+ 1' is needed since there is an "outer <UL class='blockList'>" TagNode
        // ==> The "Method Details (entire) Section" is also a <UL CLASS='blockList'> too!
        ret.restrictCursor(methodDetailsSection.start + 1, methodDetailsSection.end);

        return ret;
    }
}