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