1 9 package com.roblisa.classfinder; 10 11 import java.io.*; 12 import java.util.*; 13 14 public class JavadocSummaryGenerator 15 { 16 private static final Map summaryFiles; 17 18 static 19 { 20 summaryFiles=new HashMap(); 21 summaryFiles.put("constant-values.html","Constant Values"); 22 summaryFiles.put("deprecated-list.html","Deprecated API"); 23 summaryFiles.put("overview-summary.html","Overview Summary"); 24 summaryFiles.put("overview-tree.html","Class Hierachies"); 25 summaryFiles.put("serialized-form.html","Serialized Form"); 26 summaryFiles.put("index-all.html","Index"); 27 } 28 29 public boolean isSummaryFile(String file) 30 { 31 return summaryFiles.containsKey(file); 32 } 33 34 public void printJavadocHeader(PrintStream ps) throws IOException 35 { 36 ps.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\"http://www.w3.org/TR/REC-html40/loose.dtd\">"); 37 ps.println("<!--NewPage-->"); 38 ps.println("<html>"); 39 ps.println("<head>"); 40 ps.print("<!-- Generated by ClassFinder on "); 41 ps.print(new Date()); 42 ps.println("-->"); 43 ps.println("<title>"); 44 ps.println("Java ClassFinder"); 45 ps.println("</title>"); 46 ps.println("<link REL =\"stylesheet\" TYPE=\"text/css\" HREF=\"stylesheet.css\" TITLE=\"Style\""); 47 ps.println("</head>"); 48 ps.println("<script>"); 49 ps.println("function asd()"); 50 ps.println("{"); 51 ps.println("parent.document.title=\"Java ClassFinder\";"); 52 ps.println("}"); 53 ps.println("</SCRIPT>"); 54 ps.println("<body BGCOLOR=\"white\" onload=\"asd();\">"); 55 } 56 57 public void printHeader(PrintStream ps,String file,String name,String thisFile) 58 { 59 if (file.equals(thisFile)) 60 { 61 ps.print(" <TD BGCOLOR=\"#FFFFFF\" CLASS=\"NavBarCell1Rev\"> <FONT CLASS=\"NavBarFont1Rev\"><B>"); 62 ps.print(name); 63 ps.println("</B></FONT> </TD>"); 64 } 65 else 66 { 67 ps.print(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\""); 68 ps.print(file); 69 ps.print('"'); 70 if (file.equals("/")) 71 ps.print(" TARGET=\"_top\""); 72 ps.print("><FONT CLASS=\"NavBarFont1\"><B>"); 73 ps.print(name); 74 ps.println("</B></FONT></A> </TD>"); 75 } 76 } 77 78 public void printSplitupDocFile(PrintStream ps,String file,List javadocTitles) throws IOException 79 { 80 printJavadocHeader(ps); 81 ps.println("<!-- ========== START OF NAVBAR ========== -->"); 82 ps.println("<A NAME=\"navbar_top\"><!-- --></A>"); 83 ps.println("<TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"1\" CELLSPACING=\"0\">"); 84 ps.println("<TR>"); 85 ps.println("<TD COLSPAN=2 BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\">"); 86 ps.println("<A NAME=\"navbar_top_firstrow\"><!-- --></A>"); 87 ps.println("<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"3\">"); 88 ps.println(" <TR ALIGN=\"center\" VALIGN=\"top\">"); 89 printHeader(ps,"/","Home",file); 90 printHeader(ps,"/search?f=t","Search",file); 91 printHeader(ps,"overview-summary.html","Overview",file); 92 ps.println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <FONT CLASS=\"NavBarFont1\">Package</FONT> </TD>"); 93 ps.println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <FONT CLASS=\"NavBarFont1\">Class</FONT> </TD>"); 94 95 printHeader(ps,"deprecated-list.html","Deprecated",file); 96 printHeader(ps,"index-all.html","Index",file); 97 printHeader(ps,ClassFinder.DOC_ROOT+"help-doc.html","Help",file); 98 99 ps.println(" </TR></TABLE></TD><TD ALIGN=\"right\" VALIGN=\"top\" ROWSPAN=3><EM>"); 100 ps.println("<b>Java ClassFinder</b></EM></TD></TR>\n<TR>"); 101 ps.println("<TD BGCOLOR=\"white\" CLASS=\"NavBarCell2\"><FONT SIZE=\"-2\">"); 102 ps.println(" PREV "); 103 ps.println(" NEXT</FONT></TD>"); 104 ps.println("<TD BGCOLOR=\"white\" CLASS=\"NavBarCell2\"><FONT SIZE=\"-2\">"); 105 ps.println(" <A HREF=\"index.html\" TARGET=\"_top\"><B>FRAMES</B></A> "); 106 ps.println(" <A HREF=\"overview-summary.html\" TARGET=\"_top\"><B>NO FRAMES</B></A> "); 107 ps.println("<A HREF=\"allclasses-noframe.html\" TARGET=\"\"><B>All Classes</B></A>"); 108 ps.println("</FONT></TD></TR></TABLE>"); 109 ps.println("<!-- =========== END OF NAVBAR =========== -->"); 110 ps.println(""); 111 ps.println("<HR>"); 112 ps.print("<center><h1>"); 113 ps.print(summaryFiles.get(file)); 114 ps.println("</h1></center>"); 115 ps.println("The following javadoc collections are installed on the system."); 116 ps.println("Please select the appropriate one to display.<p><ul>"); 117 int id=0; 118 for(Iterator it=javadocTitles.iterator();it.hasNext();) 119 { 120 ps.print("<li><a HREF=\"../"); 121 int slash=file.indexOf('/'); 122 while (slash!=-1) 123 { 124 ps.print("../"); 125 slash=file.indexOf('/',slash+1); 126 } 127 ps.print("doc-summary/"); 128 ps.print(id++); 129 ps.print('/'); 130 ps.print(file); 131 ps.print("\">"); 132 ps.print(it.next()); 133 ps.println("</a></li>"); 134 } 135 ps.println("</body></html>"); 136 } 137 138 public void printClassList(PrintStream ps,boolean frame,String title,LibClass[] results) throws IOException 139 { 140 printJavadocHeader(ps); 141 ps.println("<font size=\"+1\" CLASS=\"FrameHeadingFont\">"); 142 ps.println("<b>"); 143 ps.println(title); 144 ps.println("</b></font>"); 145 ps.println("<br>"); 146 ps.println(); 147 ps.println("<table BORDER=\"0\" WIDTH=\"100%\">"); 148 ps.println("<tr>"); 149 ps.println("<td NOWRAP><font CLASS=\"FrameItemFont\">"); 150 String target=frame?"classFrame":""; 151 152 Arrays.sort(results,new Comparator(){ 153 public int compare(Object o1,Object o2) 154 { 155 String s1=((LibClass)o1).getSortName(); 156 String s2=((LibClass)o2).getSortName(); 157 boolean u1=s1.charAt(0)=='_'; 158 boolean u2=s2.charAt(0)=='_'; 159 if (u1&&!u2) 160 return 1; 161 else 162 if (!u1&&u2) 163 return -1; 164 return s1.compareTo(s2); 165 } 166 }); 167 168 if (results==null||results.length==0) 169 { 170 ps.println("None found.<br>"); 171 } 172 else 173 { 174 for(int i=0;i<results.length;i++) 175 { 176 LibClass cla=results[i]; 177 ps.print("<a HREF=\""); 178 ps.print(cla.getClassPath()); 179 ps.print(".html\" TARGET=\""); 180 ps.print(target); 181 ps.print("\">"); 182 ps.print(cla.getName()); 183 ps.println("</a><br>"); 184 } 185 } 186 187 } 188 189 public void printOverviewFrame(PrintStream ps,String[] packages) throws IOException 190 { 191 printJavadocHeader(ps); 192 ps.println("<TABLE BORDER=\"0\" WIDTH=\"100%\">"); 193 ps.println("<TR>"); 194 ps.println("<TD NOWRAP><FONT size=\"+1\" CLASS=\"FrameTitleFont\">"); 195 ps.println("<B><b>Java ClassFinder</b></B></FONT></TD>"); 196 ps.println("</TR>"); 197 ps.println("</TABLE>"); 198 ps.println(); 199 ps.println("<TABLE BORDER=\"0\" WIDTH=\"100%\">"); 200 ps.println("<TR>"); 201 ps.println("<TD NOWRAP><FONT CLASS=\"FrameItemFont\"><A HREF=\"allclasses-frame.html\" TARGET=\"packageFrame\">All Classes</A></FONT>"); 202 ps.println("<FORM action=\"search\" target=\"packageFrame\">"); 203 ps.println("<input type=\"text\" name=\"q\" size=\"15\">"); 204 ps.println("<input type=\"submit\" value=\"Go\">"); 205 ps.println("</FORM>"); 206 ps.println("<P>"); 207 ps.println("<FONT size=\"+1\" CLASS=\"FrameHeadingFont\">"); 208 ps.println("Packages</FONT>"); 209 ps.println("<BR>"); 210 ps.println("<FONT CLASS=\"FrameItemFont\">"); 211 for(int i=0;i<packages.length;i++) 212 { 213 ps.print("<A HREF=\""); 214 ps.print(packages[i].replace('.','/')); 215 ps.print("/package-frame.html\" TARGET=\"packageFrame\">"); 216 ps.print(packages[i]); 217 ps.println("</A><BR>"); 218 } 219 ps.println("</FONT></TD></TR></TABLE><P></BODY></HTML><BR>"); 220 } 221 } | Popular Tags |