Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 2bc808da01ce8c55a5599577a3a303208d59c4c5 (plain) (blame)
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
/**
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.emf.cdo.releng;

import org.eclipse.osgi.util.ManifestElement;

import org.osgi.framework.BundleException;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.CharArrayWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Eike Stepper
 */
public class AssembleJavaDocOptions
{
  private static final String EXPORT_PACKAGE = "Export-Package";

  private static final AntLib ANTLIB = new AntLib();

  private static final Pattern PACKAGE_INFO_PATTERN = Pattern.compile(".*<body[^>]*>\\s*(.*)\\s*<p>\\s*</body>.*",
      Pattern.MULTILINE | Pattern.DOTALL);

  private static final String NL = System.getProperty("line.separator");

  private static File workspace;

  private static File plugins;

  private static File releng;

  public static void main(String[] args) throws Exception
  {
    String workspacePath = args.length == 0 ? "../../.." : args[0];
    workspace = new File(workspacePath).getCanonicalFile();
    plugins = new File(workspace, "plugins");
    releng = new File(plugins, "org.eclipse.emf.cdo.releng");

    for (File plugin : plugins.listFiles())
    {
      if (plugin.isDirectory())
      {
        Properties buildProperties = getProperties(new File(plugin, "build.properties"));
        String javadocProject = buildProperties.getProperty("org.eclipse.emf.cdo.releng.javadoc.project");
        if (javadocProject != null)
        {
          Set<String> excludedPackages = getExcludedPackages(buildProperties);
          assembleJavaDocOptions(plugin, javadocProject, excludedPackages);
        }
      }
    }

    for (JavaDoc javaDoc : ANTLIB.getJavaDocs())
    {
      javaDoc.generateAnt();
      javaDoc.generateToc();
    }

    ANTLIB.generate();
    ANTLIB.generateDebug();
    System.out.println();

    for (JavaDoc javaDoc : ANTLIB.getJavaDocs())
    {
      for (SourcePlugin sourcePlugin : javaDoc.getSourcePlugins())
      {
        sourcePlugin.validatePackageInfos();
      }
    }

    System.out.println();
  }

  private static void assembleJavaDocOptions(File plugin, String javadocProject, Set<String> excludedPackages)
      throws IOException, BundleException
  {
    SourcePlugin sourcePlugin = ANTLIB.getSourcePlugin(plugin.getName());

    JavaDoc javaDoc = ANTLIB.getJavaDoc(javadocProject);
    javaDoc.getSourcePlugins().add(sourcePlugin);

    Manifest manifest = getManifest(plugin);
    for (ManifestElement manifestElement : getManifestElements(manifest))
    {
      String packageName = manifestElement.getValue().trim();
      if (isPublic(manifestElement) && !excludedPackages.contains(packageName))
      {
        javaDoc.getSourceFolders().add(plugin.getName() + "/src/" + packageName.replace('.', '/'));
        javaDoc.getPackageNames().add(packageName);
        sourcePlugin.getPackageNames().add(packageName);
      }
      else
      {
        javaDoc.getPackageExcludes().add(packageName);
      }
    }
  }

  private static boolean isPublic(ManifestElement manifestElement)
  {
    return manifestElement.getDirective("x-internal") == null && manifestElement.getDirective("x-friends") == null;
  }

  private static Set<String> getExcludedPackages(Properties buildProperties)
  {
    Set<String> excludedPackages = new HashSet<String>();

    String javadocExclude = buildProperties.getProperty("org.eclipse.emf.cdo.releng.javadoc.exclude");
    if (javadocExclude != null)
    {
      for (String exclude : javadocExclude.split(","))
      {
        exclude = exclude.trim();
        if (exclude.length() != 0)
        {
          excludedPackages.add(exclude);
        }
      }
    }
    return excludedPackages;
  }

  private static ManifestElement[] getManifestElements(Manifest manifest) throws BundleException
  {
    Attributes attributes = manifest.getMainAttributes();
    String exportPackage = attributes.getValue(EXPORT_PACKAGE);
    ManifestElement[] manifestElements = ManifestElement.parseHeader(EXPORT_PACKAGE, exportPackage);
    return manifestElements;
  }

  private static Manifest getManifest(File plugin) throws IOException
  {
    File metaInf = new File(plugin, "META-INF");
    File manifest = new File(metaInf, "MANIFEST.MF");
    InputStream in = null;

    try
    {
      in = new FileInputStream(manifest);
      return new Manifest(in);
    }
    finally
    {
      if (in != null)
      {
        in.close();
      }
    }
  }

  private static Properties getProperties(File file) throws IOException
  {
    Properties properties = new Properties();

    if (file.exists())
    {
      InputStream in = null;

      try
      {
        in = new FileInputStream(file);
        properties.load(in);
      }
      finally
      {
        if (in != null)
        {
          in.close();
        }
      }
    }

    return properties;
  }

  private static List<String> sort(Collection<String> collection)
  {
    List<String> result = new ArrayList<String>(collection);
    Collections.sort(result);
    return result;
  }

  public static void writeGenerationWarning(BufferedWriter writer) throws IOException
  {
    writer.write("\t<!-- =========================================== -->\n");
    writer.write("\t<!-- THIS FILE HAS BEEN GENERATED, DO NOT CHANGE -->\n");
    writer.write("\t<!-- =========================================== -->\n");
  }

  /**
   * @author Eike Stepper
   */
  private static class AntLib
  {
    private Map<String, SourcePlugin> sourcePlugins = new HashMap<String, SourcePlugin>();

    private Map<String, JavaDoc> javaDocs = new HashMap<String, JavaDoc>();

    public AntLib()
    {
    }

    public SourcePlugin getSourcePlugin(String projectName) throws IOException
    {
      SourcePlugin sourcePlugin = sourcePlugins.get(projectName);
      if (sourcePlugin == null)
      {
        sourcePlugin = new SourcePlugin(projectName);
        sourcePlugins.put(projectName, sourcePlugin);
      }

      return sourcePlugin;
    }

    public Collection<JavaDoc> getJavaDocs()
    {
      return javaDocs.values();
    }

    public Collection<JavaDoc> getJavaDocsSortedByDependencies()
    {
      List<JavaDoc> javaDocs = new ArrayList<JavaDoc>(getJavaDocs());
      Collections.sort(javaDocs, new Comparator<JavaDoc>()
      {
        public int compare(JavaDoc javaDoc1, JavaDoc javaDoc2)
        {
          String name1 = javaDoc1.getProject().getName();
          if (javaDoc2.getAllDependencies().contains(name1))
          {
            return -1;
          }

          String name2 = javaDoc2.getProject().getName();
          if (javaDoc1.getAllDependencies().contains(name2))
          {
            return 1;
          }

          return 0;
        }
      });

      return javaDocs;
    }

    public JavaDoc getJavaDoc(String projectName) throws IOException
    {
      JavaDoc javaDoc = javaDocs.get(projectName);
      if (javaDoc == null)
      {
        javaDoc = new JavaDoc(projectName);
        javaDocs.put(projectName, javaDoc);

        Properties buildProperties = getProperties(new File(javaDoc.getProject(), "build.properties"));
        String depends = buildProperties.getProperty("org.eclipse.emf.cdo.releng.javadoc.depends");
        if (depends != null)
        {
          StringTokenizer tokenizer = new StringTokenizer(depends, ",");
          while (tokenizer.hasMoreTokens())
          {
            String depend = tokenizer.nextToken().trim();
            javaDoc.getDependencies().add(depend);
          }
        }
      }

      return javaDoc;
    }

    public JavaDoc getJavaDocIfExists(String projectName)
    {
      JavaDoc javaDoc = javaDocs.get(projectName);
      if (javaDoc == null)
      {
        throw new IllegalStateException("JavaDoc project not found: " + projectName);
      }

      return javaDoc;
    }

    public void generate() throws IOException
    {
      FileWriter out = null;

      try
      {
        File target = new File(releng, "javadoc/javadocLib.ant");
        System.out.println("Generating " + target.getCanonicalPath());

        out = new FileWriter(target);
        BufferedWriter writer = new BufferedWriter(out);

        writer.write("<?xml version=\"1.0\"?>\n");
        writer.write("<project name=\"JavaDocLib\" default=\"delegate\" basedir=\"..\">\n");

        writer.write("\n");
        writeGenerationWarning(writer);
        writer.write("\n");

        writer.write("\t<target name=\"delegate\">\n");

        for (JavaDoc javaDoc : (List<JavaDoc>)getJavaDocsSortedByDependencies())
        {
          writer.write("\t\t<ant antfile=\"plugins/" + javaDoc.getProject().getName()
              + "/javadoc.ant\" target=\"${delegate.target}\" />\n");
        }

        writer.write("\t</target>\n");
        writer.write("\n");
        writer.write("</project>\n");
        writer.flush();
      }
      finally
      {
        if (out != null)
        {
          out.close();
        }
      }
    }

    public void generateDebug() throws IOException
    {
      FileWriter out = null;

      try
      {
        File target = new File(releng, "javadoc/debug-frame.html");
        System.out.println("Generating " + target.getCanonicalPath());

        out = new FileWriter(target);
        BufferedWriter writer = new BufferedWriter(out);

        List<JavaDoc> javaDocs = new ArrayList<JavaDoc>(getJavaDocsSortedByDependencies());
        Collections.reverse(javaDocs);

        for (JavaDoc javaDoc : javaDocs)
        {
          for (SourcePlugin sourcePlugin : javaDoc.getSortedSourcePlugins())
          {
            List<String> sortedPackageNames = sourcePlugin.getSortedPackageNames();
            writer.write("<b><a href=\"../../" + javaDoc.getProject().getName() + "/javadoc/"
                + sortedPackageNames.get(0).replace('.', '/') + "/package-summary.html\" target=\"debugDetails\">"
                + sourcePlugin.getLabel() + "</a></b>\n");
            writer.write("<ul>\n");

            for (String packageName : sortedPackageNames)
            {
              writer.write("\t<li><a href=\"../../" + javaDoc.getProject().getName() + "/javadoc/"
                  + packageName.replace('.', '/') + "/package-summary.html\" target=\"debugDetails\">" + packageName
                  + "</a>\n");
            }

            writer.write("</ul>\n");
          }
        }

        writer.flush();
      }
      finally
      {
        if (out != null)
        {
          out.close();
        }
      }
    }
  }

  /**
   * @author Eike Stepper
   */
  private static class SourcePlugin implements Comparable<SourcePlugin>
  {
    private String projectName;

    private String label;

    private Set<String> packageNames = new HashSet<String>();

    public SourcePlugin(String projectName) throws IOException
    {
      this.projectName = projectName;
      Properties pluginProperties = getProperties(new File(getProject(), "plugin.properties"));
      label = pluginProperties.getProperty("pluginName");
      if (label == null)
      {
        label = "Plugin " + projectName;
      }
    }

    @Override
    public String toString()
    {
      return projectName;
    }

    public File getProject()
    {
      return new File(plugins, projectName);
    }

    public String getLabel()
    {
      return label;
    }

    public Set<String> getPackageNames()
    {
      return packageNames;
    }

    public List<String> getSortedPackageNames()
    {
      List<String> names = new ArrayList<String>(packageNames);
      Collections.sort(names);
      return names;
    }

    public int compareTo(SourcePlugin o)
    {
      return getLabel().compareTo(o.getLabel());
    }

    public void validatePackageInfos() throws IOException
    {
      Set<String> packageNames2 = getPackageNames();
      for (String packageName : packageNames2)
      {
        File packageFolder = new File(getProject(), "src/" + packageName.replace('.', '/'));
        File packageInfo = new File(packageFolder, "package-info.java");
        if (!packageInfo.isFile())
        {
          File packageHtml = new File(packageFolder, "package.html");
          if (packageHtml.isFile())
          {
            convertPackageHTML(packageHtml, packageInfo, packageName);
          }

          if (!packageInfo.isFile())
          {
            System.err.println("Package info missing: " + packageInfo.getCanonicalPath());
          }
        }
      }
    }

    private void convertPackageHTML(File packageHtml, File packageInfo, String packageName) throws IOException
    {
      int length = (int)packageHtml.length();
      char[] content = new char[length];

      FileReader reader = null;

      try
      {
        reader = new FileReader(packageHtml);
        if (reader.read(content) != length)
        {
          throw new IOException("Invalid file length: " + packageHtml.getCanonicalPath());
        }
      }
      finally
      {
        if (reader != null)
        {
          reader.close();
        }
      }

      String input = new String(content);
      Matcher matcher = PACKAGE_INFO_PATTERN.matcher(input);
      if (!matcher.matches())
      {
        System.err.println("No match: " + packageHtml.getCanonicalPath());
        return;
      }

      System.out.println("Converting " + packageHtml.getCanonicalPath());
      String comment = matcher.group(1);
      FileWriter out = null;

      try
      {
        out = new FileWriter(packageInfo);
        BufferedWriter writer = new BufferedWriter(out);

        writer.write("/*" + NL);
        writer.write(" * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others." + NL);
        writer.write(" * All rights reserved. This program and the accompanying materials" + NL);
        writer.write(" * are made available under the terms of the Eclipse Public License v1.0" + NL);
        writer.write(" * which accompanies this distribution, and is available at" + NL);
        writer.write(" * http://www.eclipse.org/legal/epl-v10.html" + NL);
        writer.write(" * " + NL);
        writer.write(" * Contributors:" + NL);
        writer.write(" *    Eike Stepper - initial API and implementation" + NL);
        writer.write(" */" + NL);
        writer.write(NL);
        writer.write("/**" + NL);

        String[] lines = comment.split("\n");
        for (String line : lines)
        {
          writer.write(" * ");
          writer.write(line);
          writer.write(NL);
        }

        writer.write(" */" + NL);
        writer.write("package " + packageName + ";" + NL);
        writer.flush();
      }
      finally
      {
        if (out != null)
        {
          out.close();
        }
      }
    }
  }

  /**
   * @author Eike Stepper
   */
  private static class JavaDoc
  {
    private String projectName;

    private Set<String> dependencies = new HashSet<String>();

    private Set<SourcePlugin> sourcePlugins = new HashSet<SourcePlugin>();

    private List<String> sourceFolders = new ArrayList<String>();

    private Set<String> packageNames = new HashSet<String>();

    private Set<String> packageExcludes = new HashSet<String>();

    public JavaDoc(String projectName)
    {
      this.projectName = projectName;
    }

    @Override
    public String toString()
    {
      return projectName;
    }

    public File getProject()
    {
      return new File(plugins, projectName);
    }

    public Set<String> getDependencies()
    {
      return dependencies;
    }

    public Set<String> getAllDependencies()
    {
      Set<String> result = new HashSet<String>();
      recurseDependencies(this, result);
      return result;
    }

    private void recurseDependencies(JavaDoc javaDoc, Set<String> result)
    {
      for (String dependency : javaDoc.getDependencies())
      {
        if (result.add(dependency))
        {
          JavaDoc child = ANTLIB.getJavaDocIfExists(dependency);
          recurseDependencies(child, result);
        }
      }
    }

    public Set<SourcePlugin> getSourcePlugins()
    {
      return sourcePlugins;
    }

    public List<SourcePlugin> getSortedSourcePlugins()
    {
      List<SourcePlugin> plugins = new ArrayList<SourcePlugin>(sourcePlugins);
      Collections.sort(plugins);
      return plugins;
    }

    public List<String> getSourceFolders()
    {
      return sourceFolders;
    }

    public Set<String> getPackageNames()
    {
      return packageNames;
    }

    public Set<String> getPackageExcludes()
    {
      return packageExcludes;
    }

    public void generateAnt() throws IOException
    {
      File project = getProject();
      FileWriter out = null;
      FileReader in = null;

      try
      {
        File target = new File(project, "javadoc.ant");
        System.out.println("Generating " + target.getCanonicalPath());

        out = new FileWriter(target);
        BufferedWriter writer = new BufferedWriter(out);

        try
        {
          in = new FileReader(new File(releng, "javadoc/javadocTemplate.ant"));
          BufferedReader reader = new BufferedReader(in);

          String line;
          while ((line = reader.readLine()) != null)
          {
            line = line.replace("${PROJECT-NAME}", projectName);

            String id = line.trim();
            if ("<!-- GENERATION WARNING -->".equals(id))
            {
              writeGenerationWarning(writer);
            }
            else if ("<!-- SOURCE FOLDERS -->".equals(id))
            {
              for (String sourceFolder : sort(sourceFolders))
              {
                writer.write("\t\t\t\t<include name=\"" + sourceFolder + "/*.java\" />\n");
              }
            }
            else if ("<!-- COPY DOC FILES -->".equals(id))
            {
              CharArrayWriter buffer = new CharArrayWriter();
              buffer.write("\t\t<copy todir=\"${destdir}\" verbose=\"true\" failonerror=\"false\">\n");
              buffer.write("\t\t\t<cutdirsmapper dirs=\"2\" />\n");
              buffer.write("\t\t\t<fileset dir=\"plugins\" defaultexcludes=\"true\">\n");

              boolean exist = false;
              for (String sourceFolder : sort(sourceFolders))
              {
                File docFiles = new File("../../../plugins/" + sourceFolder + "/doc-files");
                if (docFiles.isDirectory())
                {
                  exist = true;
                  buffer.write("\t\t\t\t<include name=\"" + sourceFolder + "/doc-files/**\" />\n");
                }
              }

              if (exist)
              {
                buffer.write("\t\t\t</fileset>\n");
                buffer.write("\t\t</copy>\n");
                buffer.write("\n");
                writer.write(buffer.toCharArray());
              }
            }
            else if ("<!-- PACKAGE NAMES -->".equals(id))
            {
              for (String packageName : sort(packageNames))
              {
                writer.write("\t\t\t<package name=\"" + packageName + "\" />\n");
              }
            }
            else if ("<!-- PACKAGE EXCLUDES -->".equals(id))
            {
              for (String packageExclude : sort(packageExcludes))
              {
                writer.write("\t\t\t<excludepackage name=\"" + packageExclude + "\" />\n");
              }
            }
            else if ("<!-- DEPENDENCIES -->".equals(id))
            {
              for (String dependency : sort(getAllDependencies()))
              {
                writer.write("\t\t\t<link href=\"MAKE-RELATIVE/" + dependency
                    + "/javadoc\" offline=\"true\" packagelistloc=\"plugins/" + dependency + "/javadoc\" />\n");
              }
            }
            else if ("<!-- GROUPS -->".equals(id))
            {
              for (SourcePlugin sourcePlugin : getSortedSourcePlugins())
              {
                writer.write("\t\t\t<group title=\"" + sourcePlugin.getLabel() + "\">\n");

                for (String packageName : sourcePlugin.getSortedPackageNames())
                {
                  writer.write("\t\t\t\t<package name=\"" + packageName + "\" />\n");
                }

                writer.write("\t\t\t</group>\n");
              }
            }
            else
            {
              writer.write(line);
              writer.write("\n");
            }
          }

          writer.flush();
        }
        finally
        {
          if (in != null)
          {
            in.close();
          }
        }
      }
      finally
      {
        if (out != null)
        {
          out.close();
        }
      }
    }

    public void generateToc() throws IOException
    {
      File project = getProject();
      FileWriter out = null;
      FileReader in = null;

      try
      {
        File target = new File(project, "toc.xml");
        System.out.println("Generating " + target.getCanonicalPath());

        out = new FileWriter(target);
        BufferedWriter writer = new BufferedWriter(out);

        try
        {
          in = new FileReader(new File(project, "tocTemplate.xml"));
          BufferedReader reader = new BufferedReader(in);

          String line;
          while ((line = reader.readLine()) != null)
          {
            String id = line.trim();
            if ("<!-- GROUPS -->".equals(id))
            {
              for (SourcePlugin sourcePlugin : getSortedSourcePlugins())
              {
                List<String> sortedPackageNames = sourcePlugin.getSortedPackageNames();
                writer.write("\t\t<topic label=\"" + sourcePlugin.getLabel() + "\" href=\"javadoc/"
                    + sortedPackageNames.get(0).replace('.', '/') + "/package-summary.html\">\n");

                for (String packageName : sortedPackageNames)
                {
                  writer.write("\t\t\t<topic label=\"" + packageName + "\" href=\"javadoc/"
                      + packageName.replace('.', '/') + "/package-summary.html\" />\n");
                }

                writer.write("\t\t</topic>\n");
              }
            }
            else
            {
              writer.write(line);
              writer.write("\n");
            }
          }

          writer.flush();
        }
        finally
        {
          if (in != null)
          {
            in.close();
          }
        }
      }
      finally
      {
        if (out != null)
        {
          out.close();
        }
      }
    }
  }
}

Back to the top