01 
02 /*
03  *  JavaDoq 1.0 - DOCUment JAVA In Source
04  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.javadoq.com>
05  *  
06  *  This program is free software: you can redistribute it and/or modify
07  *  it under the terms of the GNU Affero General Public License as published by
08  *  the Free Software Foundation, either version 3 of the License, or
09  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Affero General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU Affero General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 package com.javadoq.html;
21 
22 import java.io.File;
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.List;
26 
27 import com.javadoq.JavaPackage;
28 import com.javadoq.SourceFile;
29 
30 /**
31  * <p>Creates HTML package files.</p>
32  * <p>Note that a transformer of this type needs to close to close its target HTML file.</p>
33  * 
34  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.javadoq.com" target="_blank">http://www.javadoq.com</a>
35  */
36 public class DoqHTMLPackage extends DoqHTMLBody
37 {
38     /**
39      * <p>Constructs a {@link DoqHTMLPackage} transformer.</p>
40      * <p>This constructor invokes its super constructor to create and open the target file
41      * and HTML body.</p>
42      * @param pkg The {@link JavaPackage} for the transformer.
43      * @since 1.0
44      */
45     public DoqHTMLPackage(JavaPackage pkg) {
46         super(pkg.jdoq, pkg.jdoq.dst + File.separator + pkg.getLink(), "Package " + pkg.title());
47         if (pkg.hasDescription) {
48             writeLine("<font size=\"+1\">Package <a href=\"" + pkg.name.path() + "/package.html\" target=\"source-frame\">" + pkg.title() + "</a></font>");
49         } else {
50             writeLine("<font size=\"+1\">Package " + pkg.title() + "</font>");
51         }
52         writeLine("<br/>");
53 
54         List<String> list = new ArrayList<String>(pkg.files.keySet());
55         Collections.sort(list);
56         for (String k : list) {
57             SourceFile f = pkg.files.get(k);
58             writeFrameItem(f.getLink(), "source-frame", f.name);
59         }
60     }
61 }