001package Torello.JavaDoc; 002 003import static Torello.Java.C.*; 004 005import Torello.HTML.*; 006import Torello.HTML.NodeSearch.*; 007 008import Torello.Java.FileRW; 009import Torello.Java.StringParse; 010import Torello.Java.StrCSV; 011import Torello.Java.StrIndexOf; 012 013import Torello.Java.Additional.Ret2; 014import Torello.Java.Additional.Ret3; 015 016import Torello.JavaDoc.Messager.Messager; 017import Torello.JDUInternal.Miscellaneous.Where.JDUUserAPI; 018import Torello.JavaDoc.Messager.Where_Am_I; 019 020import java.io.File; 021import java.io.IOException; 022import java.io.Serializable; 023 024import Torello.Java.ReadOnly.ReadOnlyVector; 025import Torello.Java.ReadOnly.ROTreeSetBuilder; 026import Torello.Java.ReadOnly.ReadOnlyTreeSet; 027 028import java.util.*; 029 030import java.util.function.Consumer; 031 032/** 033 * A class that parses and encapsulates the contents of a <B>{@code 'package-summary.html'}</B> 034 * File. 035 */ 036public class PackageSummaryHTML implements Serializable 037{ 038 // When the Messager Reports its errors, this class passes this reference to the Messager 039 // to facilitate the printing of that information (What class encountered an error or warning 040 // that needs to be printed by the Messager). 041 042 private static final Where_Am_I WHERE_AM_I = JDUUserAPI.PackageSummaryHTML; 043 044 045 // ******************************************************************************************** 046 // ******************************************************************************************** 047 // Constructor 048 // ******************************************************************************************** 049 // ******************************************************************************************** 050 051 052 public PackageSummaryHTML( 053 final String packageName, 054 final SubSection head, 055 final SubSection topNavBar, 056 final SubSection bottomNavBar, 057 final SubSection description 058 ) 059 { 060 this.packageName = packageName; 061 this.head = head; 062 this.topNavBar = topNavBar; 063 this.bottomNavBar = bottomNavBar; 064 this.description = description; 065 } 066 067 068 // ******************************************************************************************** 069 // ******************************************************************************************** 070 // Static-Final Constant Fields 071 // ******************************************************************************************** 072 // ******************************************************************************************** 073 074 075 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 076 protected static final long serialVersionUID = 1; 077 078 /** Deprecated, but useful API Error-Message */ 079 public static final String JD_FRAMES_WARNING_MESSAGE = 080 "javadoc: warning - You have specified to generate frames, by using the --frames " + 081 "option.\n" + 082 "The default is currently to not generate frames and the support for \n" + 083 "frames will be removed in a future release.\n" + 084 "To suppress this warning, remove the --frames option and avoid the use of frames.\n"; 085 086 087 // ******************************************************************************************** 088 // ******************************************************************************************** 089 // final Class-Data Fields 090 // ******************************************************************************************** 091 // ******************************************************************************************** 092 093 094 /** The name of the Java Package represented by this instance. */ 095 public final String packageName; 096 097 098 // Contains the top Navigation Bar's HTML 099 // This, and all SubSection instances, must be private, because they are mutable 100 101 private final SubSection head; 102 103 // Contains the top Navigation Bar's HTML 104 private final SubSection topNavBar; 105 106 // Contains the bottom Navigation Bar's HTML 107 private final SubSection bottomNavBar; 108 109 // THe Top-Description HTML/Text 110 private final SubSection description; 111 112 113 // ******************************************************************************************** 114 // ******************************************************************************************** 115 // Simple Accessor Methods 116 // ******************************************************************************************** 117 // ******************************************************************************************** 118 119 120 /** 121 * Allows a User to both retrieve and to modify the contents of the 122 * {@code 'package-summary.html'} {@code <HEAD>}-Section. 123 * 124 * @return Vectorized-HTML of this Web-Page's {@code <HEAD>...</HEAD>} Section. 125 */ 126 public Vector<HTMLNode> head() { return this.head.html; } 127 128 /** 129 * Allows a User to both retrieve and to modify the contents of the 130 * {@code 'package-summary.html'} Nav-Bar. 131 * 132 * @return Vectorized-HTML of this Web-Page's Upper Navigation Menu-Bar. 133 */ 134 public Vector<HTMLNode> topNavBar() 135 { return (this.topNavBar == null) ? null : this.topNavBar.html; } 136 137 /** 138 * Allows a User to both retrieve and to modify the contents of the 139 * {@code 'package-summary.html'} Nav-Bar. 140 * 141 * @return Vectorized-HTML of this Web-Page's Lower Navigation Menu-Bar. 142 */ 143 public Vector<HTMLNode> bottomNavBar() 144 { return (this.bottomNavBar == null) ? null : this.bottomNavBar.html; } 145 146 /** 147 * Allows a User to both retrieve and to modify the contents of the 148 * {@code 'package-summary.html'} Description Text-Area. 149 * 150 * @return Vectorized-HTML of this Web-Page's Main Description Box. 151 */ 152 public Vector<HTMLNode> description() { return this.description.html; } 153 154 155 // ******************************************************************************************** 156 // ******************************************************************************************** 157 // Default Package-Summary Cleaner 158 // ******************************************************************************************** 159 // ******************************************************************************************** 160 161 162 private static final String[] searches = { ".", "<br/>", "\n" }; 163 164 public static final void defaultCleaner(Vector<HTMLNode> cietSummary) 165 { 166 // boolean VERBOSE = MsgVerbose.isVerbose(); 167 168 // System.out.println("INSIDE MY LAMBDA:\n" + Util.pageToString(cietSummary)); 169 170 int i=0, nodePos=-1; 171 172 /* 173 if (VERBOSE) MsgVerbose.println 174 ("cietSummary: " + BGREEN + Util.pageToString(cietSummary) + RESET); 175 */ 176 177 while ((nodePos == -1) && (i < searches.length)) 178 nodePos = TextNodeFind.first(cietSummary, TextComparitor.CN_CI, searches[i++]); 179 180 if (nodePos == -1) 181 { 182 // if (VERBOSE) MsgVerbose.println("No String Markers Found! Exiting..."); 183 return; 184 } 185 186 String s = cietSummary.elementAt(nodePos).str; 187 int pos = StrIndexOf.first_CI(s, searches[--i]); 188 189 /* 190 if (VERBOSE) MsgVerbose.println("s: " + s); 191 */ 192 193 s = s.substring(0, pos); 194 195 /* 196 if (VERBOSE) MsgVerbose.println("s.substring: " + s); 197 */ 198 199 if (s.length() != 0) 200 cietSummary.setElementAt(new TextNode(s), nodePos++); 201 202 if (nodePos < cietSummary.size()) 203 Util.Remove.range(cietSummary, nodePos, cietSummary.size()); 204 205 206 // Util.removeAllTagNodes(cietSummary); 207 // CHANGED March 2nd 2022 208 209 TagNodeRemove.allExcept(cietSummary, TC.Both, "a", "b", "i", "code", "span"); 210 211 /* 212 if (VERBOSE) MsgVerbose.println( 213 BCYAN + Util.pageToString(cietSummary) + RESET + 214 "\n************************************************************\n" 215 ); 216 */ 217 } 218 219}