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
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
package Torello.JavaDoc;


// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Java-HTML Imports
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

import Torello.Java.*;

import static Torello.Java.C.*;
import static Torello.JavaDoc.PF.*;


// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Standard-Java Imports
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

import java.util.Optional;
import java.io.IOException;


// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// The new Source-Code Parser: com.sun.source.*
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

import com.sun.source.tree.Tree;
import com.sun.source.doctree.DocCommentTree;

/**
 * Location Information storing line-number, column-number and character-number for items inside
 * of a Java Source-Code File (a {@code '.java'} file).
 */
public class Location implements java.io.Serializable, Cloneable
{
    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
    protected static final long serialVersionUID = 1;


    // ********************************************************************************************
    // ********************************************************************************************
    // This class' public fields
    // ********************************************************************************************
    // ********************************************************************************************


    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_SIG_START_POS> */
    public final int signatureStartPos;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_SIG_START_LINE> */
    public final int signatureStartLine;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_SIG_START_COL> */
    public final int signatureStartCol;


    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_SIG_END_POS> */
    public final int signatureEndPos;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_SIG_END_LINE> */
    public final int signatureEndLine;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_SIG_END_COL> */
    public final int signatureEndCol;


    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_JDC_START_POS> */
    public final int jdcStartPos;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_JDC_START_LINE> */
    public final int jdcStartLine;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_JDC_START_COL> */
    public final int jdcStartCol;


    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_JDC_END_POS> */
    public final int jdcEndPos;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_JDC_END_LINE> */
    public final int jdcEndLine;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_JDC_END_COL> */
    public final int jdcEndCol;


    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_BODY_START_POS> */
    public final int bodyStartPos;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_BODY_START_LINE> */
    public final int bodyStartLine;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_BODY_START_COL> */
    public final int bodyStartCol;


    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_BODY_END_POS> */
    public final int bodyEndPos;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_BODY_END_LINE> */
    public final int bodyEndLine;

    /** <EMBED CLASS='external-html' DATA-FILE-ID=LOC_BODY_END_COL> */
    public final int bodyEndCol;


    // ********************************************************************************************
    // ********************************************************************************************
    // Constructor - com.sun.source.tree 
    // ********************************************************************************************
    // ********************************************************************************************


    Location(TreeUtils util, Tree tree, DocCommentTree dct, Tree body, Tree fieldInitializerTree)
    {
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Java-Doc Comments Location-Information
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        if (dct == null)
        {
            // If this 'entity' doesn't have a JavaDoc Comment, then set these to '-1'
            this.jdcStartPos    = this.jdcEndPos    = -1;
            this.jdcStartLine   = this.jdcEndLine   = -1;
            this.jdcStartCol    = this.jdcEndCol    = -1;
        }

        else
        {
            int sPos = (int) util.docSourcePositions.getStartPosition
                (util.compilationUnitTree, dct, dct);

            int ePos = (int) util.docSourcePositions.getEndPosition
                (util.compilationUnitTree, dct, dct);

            // This can happen if the code has a /**  */ above a field or method that turns out to
            // just be totally and completely empty!  I am a little busy at the moment documenting
            // something else.  March 5th, 2024.  This is trivial, but I am not doing right now.

            if (ePos == -1) throw new Torello.Java.ToDoException(
                "This really needs to be analyzed, and it is likely very easy, but I am in the " +
                "middle of another documentation-thing right now...\n\n" +
                "To Quickly Fix your problem, make sure there are no JavaDoc Comments that look " +
                "like /** */ - where there is nothing but white-space inside your comment.\n\n" +
                "I will get to this hopefully soon.  Today is March 4th, 2024."
            );

            while (sPos >= 2)
                if (util.srcFileAsStr.charAt(sPos--) == '*')
                    if (util.srcFileAsStr.regionMatches(sPos - 1, "/**", 0, 3))
                    { sPos--; break; }

            int MAX = util.srcFileAsStr.length() - 2;

            while (ePos < MAX)
                if (util.srcFileAsStr.charAt(ePos++) == '*')
                    if (util.srcFileAsStr.regionMatches(ePos - 1, "*/", 0, 2))
                    { ePos++; break; }

            this.jdcStartPos    = sPos;
            this.jdcEndPos      = ePos;

            this.jdcStartLine   = (int) util.lineMap.getLineNumber(sPos);
            this.jdcEndLine     = (int) util.lineMap.getLineNumber(ePos);

            this.jdcStartCol    = positionToColumn(this.jdcStartPos, util.srcFileAsStr);
            this.jdcEndCol      = positionToColumn(this.jdcEndPos, util.srcFileAsStr);

            /*
            System.out.println(
                "TU: " + StrPrint.abbrev(
                    util.srcFileAsStr.substring(this.jdcStartPos, this.jdcEndPos),
                    60, true, null, 120
                ));
            */
        }


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Body Location-Information
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        //
        // NOTE: Fields that do not have any initialization expressions, and absolutely enum
        //       constants - will not have a body, and the 'body' parameter will be null in such
        //       cases.  Annotation-Elements without a default-value may pass null to the body too,
        //       as could a method defined inside of an interface that doesn't have a definition.

        if (body == null)
        {
            // If this 'entity' doesn't have a Body, then set these to '-1'
            this.bodyStartPos   = this.bodyEndPos   = -1;
            this.bodyStartLine  = this.bodyEndLine  = -1;
            this.bodyStartCol   = this.bodyEndCol   = -1;
        }
        else
        {
            this.bodyStartPos = (int) util.sourcePositions.getStartPosition
                (util.compilationUnitTree, body);

            this.bodyEndPos = (int) util.sourcePositions.getEndPosition
                (util.compilationUnitTree, body);

            this.bodyStartLine  = (int) util.lineMap.getLineNumber(this.bodyStartPos);
            this.bodyEndLine    = (int) util.lineMap.getLineNumber(this.bodyEndPos);

            this.bodyStartCol   = positionToColumn(this.bodyStartPos, util.srcFileAsStr);
            this.bodyEndCol     = positionToColumn(this.bodyEndPos, util.srcFileAsStr);

            /*
            System.out.println(
                "TU: " + StrPrint.abbrev(
                    util.srcFileAsStr.substring(this.bodyStartPos, this.bodyEndPos),
                    60, true, null, 120
                ));
            */
        }


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Signature Location-Information
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        this.signatureStartPos = (int) util.sourcePositions.getStartPosition
            (util.compilationUnitTree, tree);

        this.signatureStartLine = (int) util.lineMap.getLineNumber(this.signatureStartPos);
        this.signatureStartCol  = positionToColumn(this.signatureStartPos, util.srcFileAsStr);

        if (fieldInitializerTree != null)
        {
            // NOTE: Here, a '+1' is added at the very end of the statement to account for the
            //       ending semi-colon, which Java-Parser is adding.

            this.signatureEndPos = (int) util.sourcePositions.getEndPosition
                (util.compilationUnitTree, fieldInitializerTree) + 1;

            this.signatureEndLine   = (int) util.lineMap.getLineNumber(this.signatureEndPos);
            this.signatureEndCol    = positionToColumn(this.signatureEndPos, util.srcFileAsStr);
        }
        else if (body == null)
        {
            this.signatureEndPos = (int) util.sourcePositions.getEndPosition
                (util.compilationUnitTree, tree);

            this.signatureEndLine   = (int) util.lineMap.getLineNumber(this.signatureEndPos);
            this.signatureEndCol    = positionToColumn(this.signatureEndPos, util.srcFileAsStr);
        }
        else
        {
            int     line    = this.bodyStartLine;
            int     pos     = this.bodyStartPos;
            int     col     = 2;
            char    c       = 0;

            while (Character.isWhitespace(c = util.srcFileAsStr.charAt(--pos))) if (c == '\n') line--;
            while (util.srcFileAsStr.charAt(--pos) != '\n') col++;

            this.signatureEndLine   = line;
            this.signatureEndCol    = col;
            this.signatureEndPos    = pos + col;
        }
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Constructor for NestedType - com.sun.source.tree
    // ********************************************************************************************
    // ********************************************************************************************


    Location(TreeUtils util, Tree tree, DocCommentTree dct)
    {
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Java-Doc Comments Location (COPIED DIRECTLY/VERBATIM FROM PREVIOUS CONSTRUCTOR)
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        if (dct == null)
        {
            // If this 'entity' doesn't have a JavaDoc Comment, then set these to '-1'
            this.jdcStartPos    = this.jdcEndPos    = -1;
            this.jdcStartLine   = this.jdcEndLine   = -1;
            this.jdcStartCol    = this.jdcEndCol    = -1;
        }
        else
        {
            int sPos = (int) util.docSourcePositions.getStartPosition
                (util.compilationUnitTree, dct, dct);

            int ePos = (int) util.docSourcePositions.getEndPosition
                (util.compilationUnitTree, dct, dct);

            while (sPos >= 2)
                if (util.srcFileAsStr.charAt(sPos--) == '*')
                    if (util.srcFileAsStr.regionMatches(sPos - 1, "/**", 0, 3))
                    { sPos--; break; }

            int MAX = util.srcFileAsStr.length() - 2;
            while (ePos < MAX)
                if (util.srcFileAsStr.charAt(ePos++) == '*')
                    if (util.srcFileAsStr.regionMatches(ePos - 1, "*/", 0, 2))
                    { ePos++; break; }

            this.jdcStartPos    = sPos;
            this.jdcEndPos      = ePos;

            this.jdcStartLine   = (int) util.lineMap.getLineNumber(sPos);
            this.jdcEndLine     = (int) util.lineMap.getLineNumber(ePos);

            this.jdcStartCol    = positionToColumn(this.jdcStartPos, util.srcFileAsStr);
            this.jdcEndCol      = positionToColumn(this.jdcEndPos, util.srcFileAsStr);
        }


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Signature Location-Information - ONLY DO THE STARTING PART
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        this.signatureStartPos = (int) util.sourcePositions.getStartPosition
            (util.compilationUnitTree, tree);

        this.signatureStartLine = (int) util.lineMap.getLineNumber(this.signatureStartPos);
        this.signatureStartCol  = positionToColumn(this.signatureStartPos, util.srcFileAsStr);


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // Now do the body ***AND*** The rest of signature
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        int     line    = this.signatureStartLine;
        int     col     = this.signatureStartCol;
        int     pos     = StrIndexOf.nth(util.srcFileAsStr, line - 1, '\n') + col;
        int     MAX     = util.srcFileAsStr.length() - 1;
        char    c       = 0;

        while ((pos < MAX) && ((c = util.srcFileAsStr.charAt(++pos)) != '{') && (c != ';'))
            if (c == '\n') line++;

        if (c == '{')
        {
            this.bodyStartPos   = pos;
            this.bodyStartLine  = line;
            this.bodyStartCol   = positionToColumn(pos, util.srcFileAsStr);

            this.bodyEndPos = (int) util.sourcePositions.getEndPosition
                (util.compilationUnitTree, tree);

            this.bodyEndLine    = (int) util.lineMap.getLineNumber(this.bodyEndPos);
            this.bodyEndCol     = positionToColumn(this.bodyEndPos, util.srcFileAsStr);


            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
            // Signature-End
            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

            while ((--pos > 0) && Character.isWhitespace(c = util.srcFileAsStr.charAt(pos)))
                if (c == '\n') line--;

            this.signatureEndLine   = line;
            this.signatureEndPos    = pos + 1;
            this.signatureEndCol    = positionToColumn(this.signatureEndPos , util.srcFileAsStr);
        }
        else
        {
            this.bodyStartPos = this.bodyStartCol = this.bodyStartLine =
            this.bodyEndPos = this.bodyEndCol = this.bodyEndLine = -1;


            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
            // Signature-End
            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

            this.signatureEndPos = (int) util.sourcePositions.getEndPosition
                (util.compilationUnitTree, tree);

            this.signatureEndLine    = (int) util.lineMap.getLineNumber(this.signatureEndPos);
            this.signatureEndCol     = positionToColumn(this.signatureEndPos, util.srcFileAsStr);
        }
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Two Simple Constructor Helpers
    // ********************************************************************************************
    // ********************************************************************************************


    private static int positionToColumn(int pos, String srcFileAsStr)
    {
        int     col = 1;
        char    c;

        while (     (--pos >= 0)
                &&  ((c = srcFileAsStr.charAt(pos)) != '\n')
                &&  (c != '\r')
        )
            col++;

        return col;
    }

    // It is expected the line1, col1, pos1 define a specific location / are "consisten"
    // (I Hope you know what I mean by "consistent")
    //
    // ALSO: line2 & col2 are also consistent, and come AFTER the first position
    private static int colAndLineToPosition
        (String srcFileAsStr, int line1, int col1, int pos1, int line2, int col2)
    {
        if (line2 > line1)
        {
            // The presumption, here, is that 'pos1' is a "starting" location - for either the body
            // or the signature.  It **WILL NOT** be a new-line '\n' character, it will be
            // something like the letter 'p' which is the first letter in 'public' or 'private'
            //
            // If this is for a body, then it will hold a '{'  The only reason this code uses 'pos'
            // rather than just re-using 'pos1' from the input-parameter / signature, is for this
            // comment that you are reading right now!

            int pos = pos1;
            for (int count = line2-line1; count > 0; )
                if (srcFileAsStr.charAt(++pos) == '\n') count--;

            return pos + col2;
        }
        else if (line2 == line1) 
            return pos1 - col1 + col2;

        // This should never happen
        else
            throw new UnreachableError();
    }

    // ********************************************************************************************
    // ********************************************************************************************
    // Private Clone Constructor
    // ********************************************************************************************
    // ********************************************************************************************


    private Location(Location l)
    {
        this.signatureStartPos  = l.signatureStartPos;
        this.signatureStartLine = l.signatureStartLine;
        this.signatureStartCol  = l.signatureStartCol;
    
        this.signatureEndPos    = l.signatureEndPos;
        this.signatureEndLine   = l.signatureEndLine;
        this.signatureEndCol    = l.signatureEndCol;
    
        this.jdcStartPos        = l.jdcStartPos;
        this.jdcStartLine       = l.jdcStartLine;
        this.jdcStartCol        = l.jdcStartCol;
    
        this.jdcEndPos          = l.jdcEndPos;
        this.jdcEndLine         = l.jdcEndLine;
        this.jdcEndCol          = l.jdcEndCol;
    
        this.bodyStartPos       = l.bodyStartPos;
        this.bodyStartLine      = l.bodyStartLine;
        this.bodyStartCol       = l.bodyStartCol;
    
        this.bodyEndPos         = l.bodyEndPos;
        this.bodyEndLine        = l.bodyEndLine;
        this.bodyEndCol         = l.bodyEndCol;
    }


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


    /**
     * Standard Java {@code toString()} method
     * @return Returns the contents of this class, as a {@code java.lang.String}
     */
    public String toString()
    {
        return
            "signatureStartPos:  " + signatureStartPos + '\n' +
            "signatureStartLine: " + signatureStartLine + '\n' +
            "signatureStartCol:  " + signatureStartCol + '\n' +
    
            "signatureEndPos:    " + signatureEndPos + '\n' +
            "signatureEndLine:   " + signatureEndLine + '\n' +
            "signatureEndCol:    " + signatureEndCol + '\n' +
    
            "jdcStartPos:        " + jdcStartPos + '\n' +
            "jdcStartLine:       " + jdcStartLine + '\n' +
            "jdcStartCol:        " + jdcStartCol + '\n' +
    
            "jdcEndPos:          " + jdcEndPos + '\n' +
            "jdcEndLine:         " + jdcEndLine + '\n' +
            "jdcEndCol:          " + jdcEndCol + '\n' +
    
            "bodyStartPos:       " + bodyStartPos + '\n' +
            "bodyStartLine:      " + bodyStartLine + '\n' +
            "bodyStartCol:       " + bodyStartCol + '\n' +
    
            "bodyEndPos:         " + bodyEndPos + '\n' +
            "bodyEndLine:        " + bodyEndLine + '\n' +
            "bodyEndCol:         " + bodyEndCol + '\n';
    }

    /**
     * Standard Java {@code clone()} method
     * @return Returns a copy of {@code 'this'} instance
     */
    public Object clone()
    { return new Location(this); }

    /**
     * Standard Java {@code equals()} method
     * 
     * @param other This may be any Java Object, but one that extends class {@code 'Location'}
     * has the potential to result in a {@code TRUE} evaluation from this method.
     * 
     * @return {@code TRUE} if and only if the contents of {@code 'this'} instance are identical to
     * the contents of {@code 'other'} (and only if {@code 'other'} is actually an instance of
     * {@code Location}, or extends at least extends it).
     */
    public boolean equals(Object other)
    {
        if (! Location.class.isAssignableFrom(other.getClass())) return false;

        Location l = (Location) other;

        return
                (this.signatureStartPos     == l.signatureStartPos)
            &&  (this.signatureStartLine    == l.signatureStartLine)
            &&  (this.signatureStartCol     == l.signatureStartCol)
    
            &&  (this.signatureEndPos       == l.signatureEndPos)
            &&  (this.signatureEndLine      == l.signatureEndLine)
            &&  (this.signatureEndCol       == l.signatureEndCol)
    
            &&  (this.jdcStartPos           == l.jdcStartPos)
            &&  (this.jdcStartLine          == l.jdcStartLine)
            &&  (this.jdcStartCol           == l.jdcStartCol)
    
            &&  (this.jdcEndPos             == l.jdcEndPos)
            &&  (this.jdcEndLine            == l.jdcEndLine)
            &&  (this.jdcEndCol             == l.jdcEndCol)
    
            &&  (this.bodyStartPos          == l.bodyStartPos)
            &&  (this.bodyStartLine         == l.bodyStartLine)
            &&  (this.bodyStartCol          == l.bodyStartCol)
    
            &&  (this.bodyEndPos            == l.bodyEndPos)
            &&  (this.bodyEndLine           == l.bodyEndLine)
            &&  (this.bodyEndCol            == l.bodyEndCol);
    }

    /**
     * Simply invokes the {@code hashCode()} static-method provided by class {@code java.lang.Integer}.
     * @return a hash code value for this object.
     */
    public int hashCode()
    { return Integer.hashCode(this.signatureStartPos * this.signatureEndPos); }


    // ********************************************************************************************
    // ********************************************************************************************
    // Specialized toString
    // ********************************************************************************************
    // ********************************************************************************************


    /**
     * Generates a {@code String} - with all information available, including any content requested
     * by the {@code 'flags'} parameter.
     * 
     * @param flags These are the {@code toString(...)} flags from class {@code PF}
     * ("Print Flags"). View available flags listed in class {@link PF}.
     * 
     * @param srcFileAsStr This parameter should contain the complete {@code '.java'} source-code
     * file as a {@code String}.  If you have passed the Print-Flags for requesting that the body
     * or Java-Doc Comment be output to the returned-{@code String}, this parameter must be passed
     * a valid copy of the {@code '.java'} File.
     * 
     * <BR /><BR />This parameter may be null, and if it is it will be ignored.  When null is
     * passed to this parameter, the actual Body, Java-Doc Comment &amp; Signature simply cannot
     * be extracted, and the output of this {@code toString} method shall only print the location
     * numbers, column's and line-numbers instead.
     * 
     * <BR /><BR />If a valid copy of the contents of the {@code '.java'} file that produced
     * {@code 'this'} instance of {@code Location} is passed <B STYLE='color: red;'><I>and</I></B>
     * if the appropriate Print-Flags are passed tot he {@code 'flags'} parameter requesting that
     * the specified-elements (signature, comment and body) be output to the
     * returned-{@code String},  <B STYLE='color: red;'><I>then</I></B> those elements will be 
     * printed to the output-{@code String}.
     * 
     * <BR /><BR /><B>NOTE:</B> If the contents of parameter {@code 'srcFileAsstr'} are not the
     * exact and un-modified contents of the {@code'.java} file that produced {@code 'this'}
     * instance of location, then the {@code String} returned will contain erroneous information.
     * It is even possible that a {@code StringIndexOutOfBoundsException} may be thrown.
     * 
     * @return A printable {@code String} of the locations represented by this instance
     * 
     * @see PF
     * @see StrCSV#toCSV(String[], boolean, boolean, Integer)
     * @see #toString()
     */
    public String toString(int flags, String srcFileAsStr)
    {
        boolean color       = (flags & UNIX_COLORS) > 0;
        boolean src         = srcFileAsStr != null;
        boolean signature   = src;
        boolean bodyShort   = src && ((flags & BODY_SHORT) > 0);
        boolean bodyLong    = (! bodyShort) && src && ((flags & BODY) > 0);
        boolean jdc         = src && ((flags & JAVADOC_COMMENTS) > 0);
        boolean locShort    = (flags & BRIEF_LOCATION) > 0;
        int     M_OVER_2    = MAX_STR_LEN / 2;

        if (locShort) return

            (signature
                ? ("Signature:        " + StrIndent.indentAfter2ndLine
                    (srcFileAsStr.substring(signatureStartPos, signatureEndPos), 4, true, false) +
                    '\n')
                : "") +

            "Signature-Start:  " +
            "pos="  + (color ? BGREEN : "") + signatureStartPos  + (color ? RESET : "") + ", " +
            "line=" + (color ? BGREEN : "") + signatureStartLine + (color ? RESET : "") + ", " +
            "col="  + (color ? BGREEN : "") + signatureStartCol  + (color ? RESET : "") + "\n" +

            "Signature-End:    " +
            "pos="  + (color ? BCYAN : "") + signatureEndPos  + (color ? RESET : "") + ", " +
            "line=" + (color ? BCYAN : "") + signatureEndLine + (color ? RESET : "") + ", " +
            "col="  + (color ? BCYAN : "") + signatureEndCol  + (color ? RESET : "") + "\n" +

            (jdc
                ? ("Java-Doc Comment: " + StrPrint.abbrev(srcFileAsStr.substring
                    (jdcStartPos, jdcEndPos), M_OVER_2, true, null, MAX_STR_LEN) + '\n')
                : "") +

            "Java-Doc-Start:   " +
            "pos="  + (color ? BGREEN : "") + jdcStartPos  + (color ? RESET : "") + ", " +
            "line=" + (color ? BGREEN : "") + jdcStartLine + (color ? RESET : "") + ", " +
            "col="  + (color ? BGREEN : "") + jdcStartCol  + (color ? RESET : "") + "\n" +

            "Java-Doc-End:     " +
            "pos="  + (color ? BCYAN : "") + jdcEndPos  + (color ? RESET : "") + ", " +
            "line=" + (color ? BCYAN : "") + jdcEndLine + (color ? RESET : "") + ", " +
            "col="  + (color ? BCYAN : "") + jdcEndCol  + (color ? RESET : "") + "\n" +

            (bodyShort
                ? ("Body:             " + StrPrint.abbrev(srcFileAsStr.substring
                    (signatureStartPos, signatureEndPos), M_OVER_2, true, null, MAX_STR_LEN))
                : "") +

            (bodyLong
                ? ("Body:             " + StrIndent.indentAfter2ndLine
                    (srcFileAsStr.substring(signatureStartPos, signatureEndPos), 4, true, false))
                : "") +

            "Body-Start:       " +
            "pos="  + (color ? BGREEN : "") + bodyStartPos  + (color ? RESET : "") + ", " +
            "line=" + (color ? BGREEN : "") + bodyStartLine + (color ? RESET : "") + ", " +
            "col="  + (color ? BGREEN : "") + bodyStartCol  + (color ? RESET : "") + "\n" +

            "Body-End:         " +
            "pos="  + (color ? BCYAN : "") + bodyEndPos  + (color ? RESET : "") + ", " +
            "line=" + (color ? BCYAN : "") + bodyEndLine + (color ? RESET : "") + ", " +
            "col="  + (color ? BCYAN : "") + bodyEndCol  + (color ? RESET : "");

        else return

            (signature
                ? ("SIGNATURE: " + StrIndent.indentAfter2ndLine
                    (srcFileAsStr.substring(signatureStartPos, signatureEndPos), 4, true, false))
                : "") +

            "signatureStartPos:  " + (color ? BGREEN : "") + signatureStartPos + '\n' +
                (color ? RESET : "") + 
            "signatureStartLine: " + (color ? BGREEN : "") + signatureStartLine + '\n' +
                (color ? RESET : "") + 
            "signatureStartCol:  " + (color ? BGREEN : "") + signatureStartCol + '\n' +
                (color ? RESET : "") + 
    
            "signatureEndPos:    " + (color ? BCYAN : "") + signatureEndPos + '\n' +
                (color ? RESET : "") + 
            "signatureEndLine:   " + (color ? BCYAN : "") + signatureEndLine + '\n' +
                (color ? RESET : "") + 
            "signatureEndCol:    " + (color ? BCYAN : "") + signatureEndCol + '\n' +
                (color ? RESET : "") + 

            (jdc
                ? ("BODY: " + StrPrint.abbrev(srcFileAsStr.substring
                    (jdcStartPos, jdcEndPos), M_OVER_2, true, null, MAX_STR_LEN))
                : "") +

            "jdcStartPos:        " + (color ? BGREEN : "") + jdcStartPos + '\n' +
                (color ? RESET : "") + 
            "jdcStartLine:       " + (color ? BGREEN : "") + jdcStartLine + '\n' +
                (color ? RESET : "") + 
            "jdcStartCol:        " + (color ? BGREEN : "") + jdcStartCol + '\n' +
                (color ? RESET : "") + 

            "jdcEndPos:          " + (color ? BCYAN : "") + jdcEndPos + '\n' +
                (color ? RESET : "") + 
            "jdcEndLine:         " + (color ? BCYAN : "") + jdcEndLine + '\n' +
                (color ? RESET : "") + 
            "jdcEndCol:          " + (color ? BCYAN : "") + jdcEndCol + '\n' +
                (color ? RESET : "") + 

            (bodyShort
                ? ("BODY: " + StrPrint.abbrev(srcFileAsStr.substring
                    (signatureStartPos, signatureEndPos), M_OVER_2, true, null, MAX_STR_LEN))
                : "") +

            (bodyLong
                ? ("BODY: " + StrIndent.indentAfter2ndLine
                    (srcFileAsStr.substring(signatureStartPos, signatureEndPos), 4, true, false))
                : "") +

            "bodyStartPos:       " + (color ? BGREEN : "") + bodyStartPos +'\n' +
                (color ? RESET : "") + 
            "bodyStartLine:      " + (color ? BGREEN : "") + bodyStartLine + '\n' +
                (color ? RESET : "") +
            "bodyStartCol:       " + (color ? BGREEN : "") + bodyStartCol + '\n' +
                (color ? RESET : "") + 

            "bodyEndPos:         " + (color ? BCYAN : "") + bodyEndPos + '\n' +
                (color ? RESET : "") + 
            "bodyEndLine:        " + (color ? BCYAN : "") + bodyEndLine + '\n' +
                (color ? RESET : "") + 
            "bodyEndCol:         " + (color ? BCYAN : "") + bodyEndCol + '\n' +
                (color ? RESET : "");
    }

    /**
     * Produces a quick-summary, as a {@code String}.
     * @return a very brief summary of the information contained by this class.  Lists only the
     * starting line numbers for the three sections.
     */
    public String quickSummary()
    {
        return "signature-line=" + this.signatureStartLine + ", javadoc-line=" + this.jdcStartLine +
            ", body-line=" + this.bodyStartLine;        
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Error-Checking
    // ********************************************************************************************
    // ********************************************************************************************


    private void check()
    {

    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Package-Private Debugging Tool for finding where two Declaration instances are different
    // ********************************************************************************************
    // ********************************************************************************************


    // NOTE: This class has a local copy of 'diff' -> since the only diff's that are being done
    //       here are for integers.

    void diff(Location other, Appendable a, String indentation) throws IOException
    {
        diff(this.signatureStartPos, other.signatureStartPos, "signatureStartPos", a, indentation);

        diff(
            this.signatureStartLine, other.signatureStartLine, "signatureStartLine", a,
            indentation
        );

        diff(this.signatureStartCol, other.signatureStartCol, "signatureStartCol", a, indentation);

        diff(this.signatureEndPos, other.signatureEndPos, "signatureEndPos", a, indentation);
        diff(this.signatureEndLine, other.signatureEndLine, "signatureEndLine", a, indentation);
        diff(this.signatureEndCol, other.signatureEndCol, "signatureEndCol", a, indentation);

        diff(this.jdcStartPos, other.jdcStartPos, "jdcStartPos", a, indentation);
        diff(this.jdcStartLine, other.jdcStartLine, "jdcStartLine", a, indentation);
        diff(this.jdcStartCol, other.jdcStartCol, "jdcStartCol", a, indentation);

        diff(this.jdcEndPos, other.jdcEndPos, "jdcEndPos", a, indentation);
        diff(this.jdcEndLine, other.jdcEndLine, "jdcEndLine", a, indentation);
        diff(this.jdcEndCol, other.jdcEndCol, "jdcEndCol", a, indentation);

        diff(this.bodyStartPos, other.bodyStartPos, "bodyStartPos", a, indentation);
        diff(this.bodyStartLine, other.bodyStartLine, "bodyStartLine", a, indentation);
        diff(this.bodyStartCol, other.bodyStartCol, "bodyStartCol", a, indentation);

        diff(this.bodyEndPos, other.bodyEndPos, "bodyEndPos", a, indentation);
        diff(this.bodyEndLine, other.bodyEndLine, "bodyEndLine", a, indentation);
        diff(this.bodyEndCol, other.bodyEndCol, "bodyEndCol", a, indentation);
    }

    private void diff(int int1, int int2, String intName, Appendable a, String indentation)
        throws IOException
    {
        if (int2 != int1) a.append(
            indentation +
            "this.location." + intName + ": [" + BGREEN + ("" + int1) + RESET + "], " +
            "other.location." + intName + ": [" + BGREEN + ("" + int2) + RESET + "]\n"
        );
    }
}