API Overview API Index Package Overview Direct link to this page
JavaOnTracks 0.1.2
  net.jot.doclet. JOTDocletNavView View Javadoc
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
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.jot.doclet;

import com.sun.javadoc.AnnotationDesc;
import com.sun.javadoc.AnnotationTypeDoc;
import com.sun.javadoc.AnnotationTypeElementDoc;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.ConstructorDoc;
import com.sun.javadoc.Doc;
import com.sun.javadoc.FieldDoc;
import com.sun.javadoc.MethodDoc;
import com.sun.javadoc.PackageDoc;
import com.sun.javadoc.ParamTag;
import com.sun.javadoc.Parameter;
import com.sun.javadoc.ProgramElementDoc;
import com.sun.javadoc.RootDoc;
import com.sun.javadoc.SeeTag;
import com.sun.javadoc.Tag;
import com.sun.javadoc.ThrowsTag;
import com.sun.javadoc.Type;
import com.sun.javadoc.TypeVariable;
import com.sun.tools.doclets.formats.html.HtmlDocletWriter;
import com.sun.tools.doclets.formats.html.LinkInfoImpl;
import com.sun.tools.doclets.internal.toolkit.util.ClassTree;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;
import java.util.Vector;
import net.jot.web.views.JOTLightweightView;

/**
 * View object passed from the doclet to the Template parser.
 * Contains data and methods used by the parser to fill in tne pacge variables.
 * @author thibautc
 */
public class JOTDocletNavView extends JOTLightweightView
{

    /**
     * We will leverage some of the standard javadoc features
     * In particualr comments parsing/formatting.
     */
    private HtmlDocletWriter docWriter;
    private List subs;
    private List allSubs;
    private Doc curtag;
    // cahe methods of an item(ie: class etc..) cause it's slow
    private Hashtable methodCache = new Hashtable();
    private Hashtable fieldsCache = new Hashtable();

    public void reset()
    {
        subs = null;
        allSubs = null;
    }

    public JOTDocletNavView(HtmlDocletWriter docWriter)
    {
        this.docWriter = docWriter;
    }
    public final static String PACKAGES = "packages";

    public String getItemLink(PackageDoc pack)
    {
        return getPathToRoot() + JOTDoclet.getPkgFolder(pack) + "package-summary.html";
    }

    public String getItemLink(ClassDoc doc, int context)
    {
        LinkInfoImpl lnInfo = new LinkInfoImpl(context, doc, "", null);
        String link = docWriter.getLink(lnInfo);
        return getHref(link);
    }

    public boolean isClassDoc()
    {
        Object cur = getVariables().get("curitem");
        return (cur instanceof ClassDoc);
    }

    public String getItemLink(ClassDoc doc)
    {
        return getItemLink(doc, LinkInfoImpl.CONTEXT_CLASS);
    }

    public String getItemLink(JOTDocletHolder holder)
    {
        return getItemLink(holder, LinkInfoImpl.CONTEXT_CLASS);
    }

    public String getPackageLink(ClassDoc doc)
    {
        return getItemLink(doc.containingPackage());
    }

    public String getItemLink(JOTDocletHolder holder, int context)
    {
        LinkInfoImpl lnInfo = new LinkInfoImpl(context, holder.getDoc().containingClass(), "", null);
        String link = docWriter.getLink(lnInfo);
        if (link == null)
        {
            return null;
        }
        return getHref(link) + "#" + getSignature(holder.getDoc());
    }

    public String getDirectLink()
    {
        return getDirectLink((String) null);
    }

    public String getDirectLink(JOTDocletHolder handler)
    {
        return getDirectLink(getAnchorName(handler));
    }

    public String getDirectLink(ConstructorDoc doc)
    {
        return getDirectLink(getAnchorName(doc));
    }

    public String getDirectLink(FieldDoc doc)
    {
        return getDirectLink(getAnchorName(doc));
    }

    public String getDirectLink(String anchor)
    {
        String curPage = (String) getVariables().get("curpage");
        String index = (String) getVariables().get("indexfile");
        return getPathToRoot() + index+"?page=" + curPage + (anchor == null ? "" : "#" + anchor);
    }

    public String getAnchorName(JOTDocletHolder handler)
    {
        return getSignature(handler.getDoc());
    }

    public String getAnchorName(ConstructorDoc doc)
    {
        return getSignature(doc);
    }

    public String getAnchorName(FieldDoc doc)
    {
        return doc.name();
    }

    public ClassDoc[] getSortedClasses()
    {
        PackageDoc pack = (PackageDoc) getVariables().get("curitem");
        return getSortedClasses(pack);
    }

    public ClassDoc[] getSortedClasses(PackageDoc pack)
    {
        ClassDoc[] clazzes = pack.allClasses();
        Arrays.sort(clazzes);
        return clazzes;
    }

    public boolean isDeprecated(Doc doc)
    {
        return doc.tags("deprecated").length > 0;
    }

    public boolean isDeprecated(JOTDocletHolder holder)
    {
        return isDeprecated(holder.getDoc());
    }

    public Vector getEnumConstants()
    {
        Vector myDocs = new Vector();
        ClassDoc mainDoc = (ClassDoc) getVariables().get("curitem");
        FieldDoc[] docs = mainDoc.enumConstants();
        ClassDoc doc = mainDoc.superclass();
        for (int i = 0; i != docs.length; i++)
        {
            myDocs.add(docs[i]);
        }
        // go through all superclasses fields
        while (doc != null && !doc.name().equalsIgnoreCase("object"))
        {
            //note: We don't add the "object" fields (clutter)
            docs = doc.enumConstants();
            for (int i = 0; i != docs.length; i++)
            {
                myDocs.add(docs[i]);
            }
            doc = doc.superclass();
        }
        FieldDoc[] docArray = (FieldDoc[]) myDocs.toArray(new FieldDoc[0]);
        Arrays.sort(docArray);
        return myDocs;

    }

    public Vector getInnerClasses()
    {
        Vector myDocs = new Vector();
        ClassDoc mainDoc = (ClassDoc) getVariables().get("curitem");
        ClassDoc[] docs = mainDoc.innerClasses(false);
        for (int i = 0; i != docs.length; i++)
        {
            // don't add private
            if (docs[i].isPrivate())
            {
                continue;
            }
            myDocs.add(docs[i]);
        }
        ClassDoc doc = mainDoc.superclass();
        // go through all superclasses fields
        while (doc != null && !doc.name().equalsIgnoreCase("object"))
        {
            //note: We don't add the "object" fields (clutter)
            docs = doc.innerClasses(false);
            for (int i = 0; i != docs.length; i++)
            {
                // don't add superclasses private fields
                if (docs[i].isPrivate())
                {
                    continue;
                }
                // don't add superclasses package private and != packages
                if (docs[i].isPackagePrivate() && !mainDoc.containingPackage().name().equals(doc.containingPackage().name()))
                {
                    continue;
                }
                // OK, finally add it.
                myDocs.add(docs[i]);
            }
            doc = doc.superclass();
        }
        ClassDoc[] docArray = (ClassDoc[]) myDocs.toArray(new ClassDoc[0]);
        Arrays.sort(docArray);
        return myDocs;
    }

    public Vector getHierarchy()
    {
        Vector results = new Vector();
        ClassDoc doc = (ClassDoc) getVariables().get("curitem");
        while (doc != null)
        {
            results.add(0, doc);
            if (doc.isInterface())
            {
                ClassDoc[] docs = doc.interfaces();
                if (docs == null || docs.length == 0)
                {
                    doc = null;
                } else // an interface might have ONE superinterface
                {
                    doc = docs[0];
                }
            } else
            {
                doc = doc.superclass();
            }

        }
        return results;
    }

    public String getShortDescription(JOTDocletHolder holder)
    {
        return getShortDescription(holder.getDoc());
    }

    public String getFullDescription(JOTDocletHolder holder)
    {
        return getFullDescription(holder.getDoc());
    }

    public Boolean hasMoreClasses()
    {
        return new Boolean(getAllSubClasses().size() > getSubClasses().size());
    }

    public List getSubClasses()
    {
        if (subs == null)
        {
            ClassDoc doc = (ClassDoc) getVariables().get("curitem");
            ClassTree tree = (ClassTree) getVariables().get("classTree");
            subs = getSubClassesCopy(doc, tree, false);
        }
        return subs;
    }

    private String buildParamTagText(ParamTag tag)
    {
        String result = "<font class='tagInfo'>" + tag.parameterName() + "</font>";
        result += " - " + tag.parameterComment();
        return result;
    }

    private String buildThrowTag(ThrowsTag tag)
    {
        String result = "";
        if (tag.exception() == null)
        {
            result = "<font class='tagInfo'>" + tag.exceptionName() + "</font>";
        } else
        {
            String link = getItemLink(tag.exception());
            if (link == null)
            {
                result = "<font class='tagInfo'>" + tag.exception().qualifiedName() + "</font>";
            } else
            {
                result = "<a href='" + link + "'>" + tag.exceptionName() + "</a>";
            }
        }
        result += " - " + tag.exceptionComment();
        return result;
    }

    private String formatValue(Object value)
    {
        if (value == null)
        {
            return null;
        }
        if (value instanceof String)
        {
            return "\"" + value + "\"";
        }
        if (value instanceof Character)
        {
            return "'" + value + "'";
        }
        return value.toString();
    }

    private String getHref(String link)
    {
        if (link == null)
        {
            return null;
        }
        int i = link.indexOf("HREF=\"") + 6;
        if (i >= 6)
        {
            return link.substring(i, link.indexOf("\"", i));
        } else
        {
            return null;
        }
    }

    public String getAnchorImage()
    {
        return "<img border=0 src='" + getPathToRoot() + "img/anchor.png'>";
    }

    public String getSignature(Doc doc)
    {
        if (doc instanceof MethodDoc)
        {
            return doc.name() + ((MethodDoc) doc).signature();
        } else if (doc instanceof FieldDoc)
        {
            return doc.name();
        } else if (doc instanceof ConstructorDoc)
        {
            return doc.name() + ((ConstructorDoc) doc).signature();
        }
        return "";
    }

    private List getSubClassesCopy(ClassDoc doc, ClassTree tree, boolean all)
    {
        List subs = all ? tree.allSubs(doc, false) : tree.subs(doc, false);
        if (subs.size() > 100)
        {
            subs = new Vector().subList(0, 0);
        }
        // we do a defensive copy, otherwise we have issues later.
        ArrayList list = new ArrayList(subs);
        //System.out.println("copy " + list.size() + " " + all);
        return list;
    }

    public List getAllSubClasses()
    {
        if (allSubs == null)
        {
            ClassDoc doc = (ClassDoc) getVariables().get("curitem");
            ClassTree tree = (ClassTree) getVariables().get("classTree");
            allSubs = getSubClassesCopy(doc, tree, true);
        }
        return allSubs;
    }

    public String getPathToRoot()
    {
        String path = "";
        Doc doc = (Doc) getVariables().get("curitem");
        if (getVariables().get("manualPath") != null)
        {
            path = (String) getVariables().get("manualPath");
        } else if (doc != null && !(doc instanceof RootDoc))
        {
            String name = doc.name();
            if (doc instanceof ClassDoc)
            {
                name = ((ClassDoc) doc).containingPackage().name();
            }
            for (int i = 0; i != name.split("\\.").length; i++)
            {
                path += "../";
            }
        }
        return path;
    }

    public boolean hasValue(JOTDocletFieldHolder doc)
    {
        return ((FieldDoc) doc.getDoc()).constantValue() != null;
    }

    public String getElemValue(AnnotationTypeElementDoc doc)
    {
        Object value = doc.defaultValue();
        return value == null ? null : formatValue(value);
    }

    public String getFieldValue(JOTDocletFieldHolder doc)
    {
        Object value = ((FieldDoc) doc.getDoc()).constantValue();
        if (value == null)
        {
            return "";
        }
        return formatValue(value.toString());
    }

    public ConstructorDoc[] getConstructors()
    {
        ClassDoc doc = (ClassDoc) getVariables().get("curitem");
        ConstructorDoc[] docs = doc.constructors(false);
        // constructors are not inherited.
        // we show private constructors as this is useful info.
        Arrays.sort(docs);
        return docs;
    }

    public JOTDocletFieldHolder[] getFields()
    {
        ClassDoc mainDoc = (ClassDoc) getVariables().get("curitem");
        return getFields(mainDoc);
    }

    public AnnotationTypeElementDoc[] getAnnotElems()
    {
        Vector myDocs = new Vector();
        ClassDoc mainDoc = (ClassDoc) getVariables().get("curitem");
        //System.out.println(mainDoc.typeName());
        //System.out.println(mainDoc instanceof AnnotationTypeDoc);
        AnnotationTypeDoc doc = (AnnotationTypeDoc) mainDoc;
        AnnotationTypeElementDoc[] docs = doc.elements();

        for (int i = 0; i != docs.length; i++)
        {
            if (docs[i].isPrivate())
            {
                continue;
            }
            myDocs.add(docs[i]);
        }
        AnnotationTypeElementDoc[] docArray = (AnnotationTypeElementDoc[]) myDocs.toArray(new AnnotationTypeElementDoc[0]);
        Arrays.sort(docArray);
        return docArray;
    }

    public Integer getLineNb(Integer nb)
    {
        return new Integer(nb.intValue() + 1);
    }

    public JOTDocletFieldHolder[] getFields(ClassDoc mainDoc)
    {
        if (fieldsCache.containsKey(mainDoc.qualifiedName()))
        {
            return (JOTDocletFieldHolder[]) fieldsCache.get(mainDoc.qualifiedName());
        }
        Vector myDocs = new Vector();
        FieldDoc[] docs = mainDoc.fields(false);
        for (int i = 0; i != docs.length; i++)
        {
            // don't add private fields
            if (docs[i].isPrivate())
            {
                continue;
            }
            JOTDocletFieldHolder holder = new JOTDocletFieldHolder(docs[i], null);
            myDocs.add(holder);
        }
        // for all the fields in those class, check if fields where
        // specified in implemented interfaces, to mark them as such
        ClassDoc[] interfaces = mainDoc.interfaces();
        for (int k = 0; k != interfaces.length; k++)
        {
            // go trough each impl interfaces and their potential superclasses
            JOTDocletFieldHolder[] intFields = getFields(interfaces[k]);
            for (int l = 0; l != intFields.length; l++)
            {
                intFields[l].setSuperClass(interfaces[k]);
                myDocs.add(intFields[l]);
            }
        }
        ClassDoc doc = mainDoc.superclass();
        // go through all superclasses fields
        while (doc != null && !doc.name().equalsIgnoreCase("object"))
        {
            //note: We don't add the "object" fields (clutter)
            docs = doc.fields(false);
            for (int i = 0; i != docs.length; i++)
            {
                // don't add superclasses private fields
                if (docs[i].isPrivate())
                {
                    continue;
                }
                // don't add superclasses package private and != packages
                if (docs[i].isPackagePrivate() && !mainDoc.containingPackage().name().equals(doc.containingPackage().name()))
                {
                    continue;
                }
                // check if the field was overriden in our object
                // if so mark that
                boolean skip = false;
                String sig = getSignature(docs[i]);
                for (int j = 0; j != myDocs.size(); j++)
                {
                    JOTDocletFieldHolder holder = (JOTDocletFieldHolder) myDocs.get(j);
                    if (sig.equals(getSignature((FieldDoc) holder.getDoc())))
                    {
                        skip = true;
                        if (holder.getOverridenIn() == null)
                        {
                            if (holder.getSuperClass() == null)
                            {
                                // mark only the first level override (closer in hierarchy)
                                holder.setOverridenIn(doc);
                            }
                        }
                    }
                }
                // if it was overidden/impl. we don't want to add the original field
                if (skip)
                {
                    continue;
                }
                // OK, finally add it.
                myDocs.add(new JOTDocletFieldHolder(docs[i], doc));
            }
            doc = doc.superclass();
        }
        JOTDocletFieldHolder[] docArray = (JOTDocletFieldHolder[]) myDocs.toArray(new JOTDocletFieldHolder[0]);
        Arrays.sort(docArray);
        fieldsCache.put(mainDoc.qualifiedName(), docArray);
        return docArray;
    }

    public JOTDocletMethodHolder[] getMethods()
    {
        ClassDoc mainDoc = (ClassDoc) getVariables().get("curitem");
        return getMethods(mainDoc);
    }

    public JOTDocletMethodHolder[] getMethods(ClassDoc mainDoc)
    {
        if (methodCache.containsKey(mainDoc.qualifiedName()))
        {
            return (JOTDocletMethodHolder[]) methodCache.get(mainDoc.qualifiedName());
        }
        Vector myDocs = new Vector();
        //Vector intMethods=getAllInterfaceMethods(mainDoc);
        MethodDoc[] docs = mainDoc.methods(false);
        for (int i = 0; i != docs.length; i++)
        {
            // don't add private methods
            if (docs[i].isPrivate())
            {
                continue;
            }

            JOTDocletMethodHolder holder = new JOTDocletMethodHolder(docs[i], null);
            String sig = getSignature(docs[i]);
            ClassDoc[] interfaces = mainDoc.interfaces();
            // for all the methods in this class, check if methods where
            // specified in implemented interfaces, to mark them as such
            for (int k = 0; k != interfaces.length; k++)
            {
                // go trough each impl interfaces and their potential superclasses

                JOTDocletMethodHolder[] intMethods = getMethods(interfaces[k]);
                for (int l = 0; l != intMethods.length; l++)
                {
                    if (getSignature((MethodDoc) intMethods[l].getDoc()).equals(sig))
                    {
                        if (holder.getSpecifiedIn() == null)
                        {
                            holder.setSpecifiedIn(interfaces[k]);
                        }
                    }
                }
            }
            myDocs.add(holder);
        }
        ClassDoc doc = mainDoc.superclass();
        // go through all superclasses methods
        while (doc != null && !doc.name().equalsIgnoreCase("object"))
        {
            //note: We don't add the "object" methods (clutter)
            docs = doc.methods(false);
            for (int i = 0; i != docs.length; i++)
            {
                // don't add superclasses private methods
                if (docs[i].isPrivate())
                {
                    continue;
                }
                // don't add superclasses package private and != packages
                if (docs[i].isPackagePrivate() && !mainDoc.containingPackage().name().equals(doc.containingPackage().name()))
                {
                    continue;
                }
                // check if the method was overriden in our object
                // if so mark that
                boolean skip = false;
                String sig = getSignature(docs[i]);
                for (int j = 0; j != myDocs.size(); j++)
                {
                    JOTDocletMethodHolder holder = (JOTDocletMethodHolder) myDocs.get(j);
                    if (sig.equals(getSignature((MethodDoc) holder.getDoc())))
                    {
                        skip = true;
                        if (docs[i].isAbstract())
                        {
                            //in case of absract method, mark as "specified" rather than ovveriden
                            if (holder.getSpecifiedIn() == null)
                            {
                                holder.setSpecifiedIn(doc);
                            }

                        } else if (holder.getOverridenIn() == null)
                        {
                            if (holder.getSuperClass() == null)
                            {
                                // mark only the first level override (closer in hierarchy)
                                holder.setOverridenIn(doc);
                            }
                        }
                    }
                }
                // if it was overidden/impl. we don't want to add the original method
                if (skip)
                {
                    continue;
                }
                // OK, finally add it.
                myDocs.add(new JOTDocletMethodHolder(docs[i], doc));
            }
            doc = doc.superclass();
        }
        JOTDocletMethodHolder[] docArray = (JOTDocletMethodHolder[]) myDocs.toArray(new JOTDocletMethodHolder[0]);
        Arrays.sort(docArray);
        methodCache.put(mainDoc.qualifiedName(), docArray);
        return docArray;
    }

    public String getModifiersString(JOTDocletMethodHolder holder)
    {
        return getModifiersString(holder.getDoc());
    }

    public String getModifiersString(JOTDocletFieldHolder holder)
    {
        return getModifiersString(holder.getDoc());
    }

    public String getReturnString(JOTDocletHolder holder)
    {
        Type type = null;
        if (holder instanceof JOTDocletFieldHolder)
        {
            type = ((FieldDoc) holder.getDoc()).type();
        } else
        {
            type = ((MethodDoc) holder.getDoc()).returnType();
        }
        String str = "";
        if (type.asParameterizedType() != null)
        {
            str += handleGenerics(type, 0);
        } else if (type.asTypeVariable() != null)
        {
            str += handleGenerics(type, 0);
        } else if (type.asClassDoc() != null)
        {
            str += getTypeLink(type.asClassDoc());
        } else
        {
            str += "<font class='type'>" + type.simpleTypeName() + "</font>";
        }
        return str;
    }

    private String getTypeLink(ClassDoc doc)
    {
        String str = "";
        String link = getItemLink(doc);
        if (link == null)
        {
            str = "<font class='type'>" + doc.qualifiedName() + "</font>";
        } else
        {
            str = "<a class='regular' href='" + link + "'><font class='type'>" + doc.simpleTypeName() + "</font></a>";
        }
        return str;
    }

    public String getModifiersString(ProgramElementDoc doc)
    {
        String modifs = "";
        int modif = doc.modifierSpecifier();
        if (Modifier.isPrivate(modif))
        {
            modifs += "<span class='private'>private</span>";
        } else if (Modifier.isProtected(modif))
        {
            modifs += "<span class='protected'>protected</span>";
        } else if (Modifier.isPublic(modif))
        {
            modifs += "<span class='public'>public</span>";
        } else
        {
            modifs += "<span class='protected'>pack-private</span>";
        }
        if (Modifier.isAbstract(modif))
        {
            modifs += "<span class='abstract'>abstract</span>";
        }
        if (Modifier.isFinal(modif))
        {
            modifs += "<span class='final'>final</span>";

        }
        if (Modifier.isStatic(modif))
        {
            modifs += "<span class='static'>static</span>";

        }
        if (Modifier.isSynchronized(modif))
        {
            modifs += "<span class='synchronized'>synchronized</span>";

        }
        if (Modifier.isNative(modif))
        {
            modifs += "<span class='native'>native</span>";

        }
        if (Modifier.isTransient(modif))
        {
            modifs += "<span class='transient'>transient</span>";
        }
        if (Modifier.isVolatile(modif))
        {
            modifs += "<span class='volatile'>volatile</span>";
        }
        return modifs;
    }

    public String getParamString(ConstructorDoc doc)
    {
        String str = "(";
        Parameter[] params = doc.parameters();
        str = str + processParams(params);
        str += ")";
        return str;
    }

    public String getParamString(JOTDocletMethodHolder holder)
    {
        String str = "(";
        Parameter[] params = ((MethodDoc) holder.getDoc()).parameters();
        str = str + processParams(params);
        str += ")";
        return str;
    }

    public boolean hasMoreInfos(JOTDocletHolder holder)
    {
        return hasMoreInfos(holder.getDoc());
    }

    public boolean hasMoreInfos()
    {
        Doc doc = (Doc) getVariables().get("curitem");
        return hasMoreInfos(doc);
    }

    /**
     * Compares full desc. to short desc. to see wether more infos avail.
     * @return
     */
    public boolean hasMoreInfos(Doc doc)
    {
        //System.out.println(doc.name());
        String s1, s2;
        try
        {
            s1 = docWriter.commentTagsToString(null, doc, doc.inlineTags(), false);
            s2 = docWriter.commentTagsToString(null, doc, doc.firstSentenceTags(), true);
        } catch (ClassCastException e)
        {
            // java/lang/StringBuilder.html codePointAt javadic causes this -> why ??
            System.err.println("Error parsing comments for " + doc.name());
            return false;
        }
        return s1.length() > s2.length() ||
                doc.tags("return").length > 0 ||
                doc.tags("param").length > 0 ||
                doc.tags("see").length > 0 ||
                doc.tags("since").length > 0 ||
                doc.tags("throws").length > 0 ||
                doc.tags("exception").length > 0;
    }

    public String getType(ClassDoc clazz)
    {
        if (clazz.isOrdinaryClass())
        {
            if (!clazz.isAbstract())
            {
                return "class";
            } else
            {
                return "abstract class";
            }
        } else if (clazz.isInterface())
        {
            return "interface";
        } else if (clazz.isEnum())
        {
            return "enum";
        } else if (clazz.isError())
        {
            return "error";
        } else if (clazz.isException())
        {
            return "exception";
        } else if (clazz.isAnnotationType())
        {
            return "annotation";
        }
        //default;
        return "class";
    }

    public String getTypeImage(ClassDoc clazz)
    {
        if (clazz.isOrdinaryClass())
        {
            if (!clazz.isAbstract())
            {
                return getPathToRoot() + "img/class.png";
            } else
            {
                return getPathToRoot() + "img/abstract.png";
            }
        } else if (clazz.isInterface())
        {
            return getPathToRoot() + "img/interface.png";
        } else if (clazz.isEnum())
        {
            return getPathToRoot() + "img/enum.png";
        } else if (clazz.isError() || clazz.isException())
        {
            return getPathToRoot() + "img/error.png";
        } else if (clazz.isAnnotationType())
        {
            return getPathToRoot() + "img/annotation.png";
        }
        //default;
        return getPathToRoot() + "img/class.png";
    }

    public String getTreeOffset(Doc doc)
    {
        String result = "";
        int nb = doc.name().split("\\.").length;
        for (int i = 1; i < nb; i++)
        {
            result += "&nbsp;&nbsp;&nbsp;&nbsp;";
        }
        return result;
    }

    public String getShortDescription()
    {
        Doc pack = (Doc) getVariables().get("curitem");
        return getShortDescription(pack);
    }

    public String getShortDescription(Doc doc)
    {
        String text = docWriter.commentTagsToString(null, doc, doc.firstSentenceTags(), true);
        return text;
    }

    public Vector getSeeTags()
    {
        // adjust the path, so the links get build correctly
        docWriter.relativePath = getPathToRoot();
        Doc pack = (Doc) getVariables().get("curitem");
        Tag[] tags = pack.tags("see");
        Vector results = new Vector();
        for (int i = 0; i != tags.length; i++)
        {
            SeeTag tag = (SeeTag) tags[i];

            String link = docWriter.seeTagToString(tag);

            results.add(link);
        }
        return results;
    }

    public boolean hasItemTags(String tagName)
    {
        return getItemTags(tagName).length > 0;
    }

    public Tag[] getItemTags(String tagName)
    {
        Tag[] tags = getJDOCTags(curtag, tagName);
        //System.out.println(curtag.name()+" / "+ tagName+" : "+tags.length);
        return tags;
    }

    public String charVal(Character c)
    {
        int nb = (c.charValue() - ('A' - 1));
        if (c.equals(new Character('_')))
        {
            nb = 27;
        }
        if (c.equals(new Character('$')))
        {
            nb = 28;
        }
        return "" + nb;
    }

    public String getIndexFile()
    {
        // TODO: index-1.html might not exist if there are no items starting by 'a' ... unlikely
        if (docWriter.configuration.splitindex)
        {
            return getPathToRoot() + "index-files/index-1.html";
        } else
        {
            return getPathToRoot() + "index-files/index-all.html";
        }
    }

    public Tag[] getJDOCTags(String tagName)
    {
        Doc doc = (Doc) getVariables().get("curitem");
        return getJDOCTags(doc, tagName);
    }

    public Tag[] getJDOCTags(Doc doc, String tagName)
    {
        Tag[] tags = doc.tags(tagName);
        return tags;
    }

    public AnnotationDesc[] getAnnotations(JOTDocletHolder holder)
    {
        return getAnnotations(holder.getDoc());
    }

    public AnnotationDesc[] getAnnotations(ProgramElementDoc doc)
    {
        AnnotationDesc[] annots = doc.annotations();
        return annots;
    }

    public AnnotationDesc[] getAnnotations()
    {
        Object doc = getVariables().get("curitem");
        if (!(doc instanceof ProgramElementDoc))
        {
            return null;
        }
        return getAnnotations((ProgramElementDoc) doc);
    }

    public String getAnnotationString(AnnotationDesc annot)
    {
        String result = "<span class='annotation'>";
        String link = getItemLink(annot.annotationType());
        result += link == null ? "@" + annot.annotationType().qualifiedName() : "<a href='" + link + "'>@" + annot.annotationType().name() + "</a>";
        AnnotationDesc.ElementValuePair[] pairs = annot.elementValues();
        if (pairs.length > 0)
        {
            result += " (";
            for (int i =__JOT_PIECE_144__; i != pairs.length; i++)
            {
                if (i > 0)
                {
                    result += ", ";
                }
                AnnotationDesc.ElementValuePair pair = pairs[i];
                String link2 = getItemLink(pair.element().containingClass());
                result += link2 == null ? pair.element().qualifiedName() : "<a href='" + link2 + "#" + getSignature(pair.element()) + "'>" + pair.element().name() + "</a>";
                result += "=" + formatValue(pair.value());
            }
            result += ")";
        }
        return result + "</span>";
    }

    public String getTagText(Tag tag)
    {
        if (tag.name().equals("@see"))
        {
            try
            {
                return docWriter.seeTagToString((SeeTag) tag);
            } catch (ClassCastException e)
            {
                System.err.println("Error bulding @see tag " + tag.name());
                return tag.text();
            }
        } else if (tag.name().equals("@param"))
        {
            return buildParamTagText((ParamTag) tag);
        } else if (tag.name().equals("@throws") || tag.name().equals("@exception"))
        {
            return buildThrowTag((ThrowsTag) tag);
        }

        return tag.text();
    }

    public String getShortItemName()
    {
        return getShortItemName((Doc) getVariables().get("curitem"));
    }

    public String getShortItemName(Doc doc)
    {
        String name = doc.name();
        if (name.indexOf(".") > 0)
        {
            name = name.substring(0, name.indexOf("."));
        }
        return name;
    }

    public String getFullDescription()
    {
        Doc doc = (Doc) getVariables().get("curitem");
        return getFullDescription(doc);
    }

    public String getFullDescription(Doc doc)
    {
        String text = docWriter.commentTagsToString(null, doc, doc.inlineTags(), false);

        if (text == null)
        {
            text = "";
        }
        if (!containsBreaks(text))
        {
            /**
             * If there is no html tag, it's probably a raw text comments that would gain
             * fromm converting line feeds into <br/>
             */
            text = text.replaceAll("\n", "<br/>");
        }
        return text;
    }

    public String getStrippedShortDescription(Doc doc)
    {
        // short description without any html tags whch messthings up when bot closed on first line.
        return getShortDescription(doc).replaceAll("\\<.*>", "");
    }

    private boolean containsBreaks(String txt)
    {
        // kinda lame
        return txt.indexOf("<br/>") != -1 || txt.indexOf("<BR/>") != -1 || txt.indexOf("<p>") != -1 || txt.indexOf("<P>") != -1;
    }

    private String handleGenerics(Type type, int depth)
    {
        String str = "";
        depth++;
        // lame anti-recusrion hack
        if (depth > 15)
        {
            return str;
        }
        //System.out.println(type.qualifiedTypeName());
        if (type.asParameterizedType() != null)
        {
            str += getTypeLink(type.asParameterizedType().asClassDoc());
            Type[] args = type.asParameterizedType().typeArguments();
            if (args.length > 0)
            {
                str += "<";
                for (int i = 0; i != args.length; i++)
                {
                    if (i > 0)
                    {
                        str += ", ";
                    }
                    // generic might be imbricated, so recurse as needed
                    //System.out.println("$ "+str);
                    str += handleGenerics(args[i], depth);
                }
                str += ">";
            }
        } else if (type.asTypeVariable() != null)
        {
            String name = type.simpleTypeName();

            /*Type[] types=type.asTypeVariable().bounds();
            for (int i = 0; i != types.length; i++)
            {
            if (i > 0)
            {
            str += ", ";
            }
            // generic might be imbricated, so recurse as needed
            str+=handleGenerics(types[i],depth);
            }*/
            str += (sameName(name, type.asTypeVariable()) ? "" : " <font class='genericVar'>" + type.asTypeVariable().typeName() + "</font>");
        } else if (type.asClassDoc() != null)
        {
            str = getTypeLink(type.asClassDoc());
        } else
        {
            str = "<font class='type'>" + type.simpleTypeName() + "</font>";
        }

        return str;
    }

    private String processParams(Parameter[] params)
    {
        String str = "";
        for (int i = 0; i != params.length; i++)
        {
            if (str.length() > 1)
            {
                str += ", ";
            }
            if ((params[i].type().asParameterizedType() != null || params[i].type().asTypeVariable() != null))
            {
                str += handleGenerics(params[i].type(), 0);
            } else if (params[i].type().asClassDoc() != null)
            {
                str += getTypeLink(params[i].type().asClassDoc());
            } else
            {
                str += "<font class='type'>" + params[i].typeName() + "</font>";
            }
            str += " " + params[i].name();
        }
        return str;
    }

    public String getInheritedFromItem(JOTDocletHolder holder)
    {
        String link = getItemLink(holder.getSuperClass());
        if (link == null)
        {
            return "<font class='type'>" + holder.getSuperClass().qualifiedName() + "</font>";
        }
        link += "#" + getSignature(holder.getDoc());
        return "<a class='regular' href='" + link + "'><font class='type'>" + holder.getSuperClass().name() + "</font></a>";
    }

    public String getOverridenInItem(JOTDocletHolder holder)
    {
        String link = getItemLink(holder.getOverridenIn());
        if (link == null)
        {
            return "<font class='type'>" + holder.getOverridenIn().qualifiedName() + "</font>";
        }
        link += "#" + getSignature(holder.getDoc());
        return "<a class='regular' href='" + link + "'><font class='type'>" + holder.getOverridenIn().name() + "</font></a>";
    }

    public String getSpecifiedInItem(JOTDocletHolder holder)
    {
        String link = getItemLink(holder.getSpecifiedIn());
        if (link == null)
        {
            return "<font class='type'>" + holder.getSpecifiedIn().qualifiedName() + "</font>";
        }
        link += "#" + getSignature(holder.getDoc());
        return "<a class='regular' href='" + link + "'><font class='type'>" + holder.getSpecifiedIn().name() + "</font></a>";
    }

    public boolean hasDeclaredThrows(ConstructorDoc doc)
    {
        return getDeclaredThrows(doc).size() > 0;
    }

    public Vector getDeclaredThrows(ConstructorDoc doc)
    {
        ClassDoc[] exceptions = doc.thrownExceptions();
        return getDeclaredThrows(exceptions);
    }

    public boolean hasDeclaredThrows(JOTDocletMethodHolder holder)
    {
        return getDeclaredThrows(holder).size() > 0;
    }

    public Vector getDeclaredThrows(JOTDocletMethodHolder holder)
    {
        ClassDoc[] exceptions = ((MethodDoc) holder.getDoc()).thrownExceptions();
        return getDeclaredThrows(exceptions);
    }

    public Vector getDeclaredThrows(ClassDoc[] exceptions)
    {
        Vector v = new Vector();
        for (int i = 0; i != exceptions.length; i++)
        {
            String link = getItemLink(exceptions[i]);
            if (link != null)
            {
                v.add("<a href=" + link + ">" + exceptions[i].name() + "</a>");
            } else
            {
                v.add(exceptions[i].containingPackage().name() + "." + exceptions[i].name());
            }
        }
        return v;
    }

    public String setTagsItem(JOTDocletHolder holder)
    {
        return setTagsItem(holder.getDoc());
    }

    public String setTagsItem(Doc doc)
    {
        curtag = doc;
        return "";
    }

    private boolean sameName(String name, TypeVariable type)
    {
        if (name == null || type == null)
        {
            return true;
        }
        if (type.asClassDoc() == null || type.asClassDoc().name() == null)
        {
            return true;
        }
        return name.equals(type.asClassDoc().name());
    }
}

Generated By: JavaOnTracks Doclet 0.1.5     ©Thibaut Colar