Class HiLiteSrcCodeFile


  • public class HiLiteSrcCodeFile
    extends java.lang.Object
    HiLiteSrcCodeFile Upgrade (Builder) - Documentation.

    This class has but one method. It's job is to call the HiLite Server and have the entire contents of one Java Source-Code File HiLited.

    1. Transmit the '.java' Source-Code to the HiLite.ME Server, and wait for the Code-HiLiting results
    2. Save this to the appropriate javadoc/ output directory
    3. Insert a link to this '.html' file in the CIET - Class, Interface or Enumerated-Type Java-Doc HTML page

    In any Upgraded Java-Doc HTML Web-Page, unless explicitly requested by the user to "avoid adding Source-Code File HiLite", two links to the HiLited Version of the Source-Code will be inserted into the Java-Doc Page.

    The HiLited Source Code File procedure is the one which creates links on your Java Doc Pages that look like:

    HiLited Source Code File Link




Stateless Class: This class neither contains any program-state, nor can it be instantiated.
The @StaticFunctional Annotation may also be called 'The Spaghetti Report'
  • 1 Constructor(s), 1 declared private, zero-argument constructor
  • 3 Method(s), 3 declared static
  • 6 Field(s), 6 declared static, 6 declared final


    • Method Detail

      • retrieveHEADER

        public static java.util.Vector<HTMLNoderetrieveHEADER​
                    (java.lang.String cietName)
        
        Used in build library.
        Parameters:
        cietName - The name of the class, interface or enumerated-type that whose source-code file is being hilited. This name will be placed in the title portion of the HTML <HEAD>...</HEAD> section.
        Returns:
        A Clone of the Vector to place at the top of a HiLited Source Code File.
        Code:
        Exact Method Body:
        1
        2
        3
         Vector<HTMLNode> header = (Vector<HTMLNode>) PAGE_HEADER.clone();
         header.setElementAt(new TextNode(cietName), titlePos);
         return header;
        
      • retrieveFOOTER

        public static java.util.Vector<HTMLNoderetrieveFOOTER()
        Used in build code.
        Returns:
        a clone of the hilited source-code HTML-Vector page footer.
        Code:
        Exact Method Body:
        1
         return (Vector<HTMLNode>) PAGE_FOOTER.clone();
        
      • run

        public static void run​(CommonParamRecord pr)
        Converts a Java '.java' file to a Code-Hilited file.
        Parameters:
        pr - This contains all of the needed parameters for this method, encapsulated into a single record-class. The list is somewhat lengthy, so this makes the code "look cleaner"
        See Also:
        Features.insertCSSLink(Vector, String), Features.insertFavicon(Vector, String), FileRW.writeFile(CharSequence, String), TopDescription.descriptionAtTop(Vector)
        Code:
        Exact Method Body:
         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
         Vector<HTMLNode> hiLitedSource = null;
         String hiLitedSrcCodeFileName = null;
        
         if (pr.sw != null) pr.sw.println("HiLiteSrcCodeFile.run(...)");
        
         // ********** Invoke HiLite.ME on SourceCode *****************
         try
             { hiLitedSource = pr.hiLiter.hiLite(pr.srcCodeAsStr, "java", false); }
         catch (IOException | HiLiteException e)
         {
             throw new HiLiteError(
                 "There was a problem attempting to read either the Server 'http://HiLite.ME', " +
                 "or the file generated an Exception when trying to read from the cache. " +
                 "See getCause() for more information.",
                 e
             );
         }
        
         // ********** Save the HiLited Code to output file *****************
         try
         {
             // Insert Header and Footer
             hiLitedSource.addAll(0, retrieveHEADER(pr.jscf.name));
             hiLitedSource.addAll(PAGE_FOOTER);
        
             // Insert the CSS Relative-URL link into hilited-source-code HTML file vector
             Features.insertCSSLink(hiLitedSource, pr.dotDots + Upgrade.JAVA_DOC_CSS_FILE_NAME);
             if (pr.sw != null) pr.sw.println("\tInserted CSS Link");
        
             // Check for favicon request, and insert  into hilited-source-code HTML file vector
             if (pr.faviconImageFileName != null)
             {
                 Features.insertFavicon(hiLitedSource, pr.dotDots + pr.faviconImageFileName);
                 if (pr.sw != null) pr.sw.println("\tInserted Favicon");
             }
        
             // Compute LOCAL-FileName (which is also the GCS-Storage-Bucket name)
             hiLitedSrcCodeFileName =
                 pr.jdFileName.substring
                     (0, pr.jdFileName.length() - 5 /* (".html".length()) */) + ".java.html";
        
             // Save the HiLited Source Code String to disk.
             FileRW.writeFile(Util.pageToString(hiLitedSource), hiLitedSrcCodeFileName);
        
             // Now the "Anchor Link HREF=..." can leave out "the path" and go with just the
             // "file-name" (This variable is reused below, for the <A HREF=...> </A>
             // in "TopDescription")
             hiLitedSrcCodeFileName = StringParse.fromLastFileSeparatorPos(hiLitedSrcCodeFileName);
        
         } catch (IOException e) {
             throw new HiLiteError(
                "Failed to write HiLited Source-Code File: [" + hiLitedSrcCodeFileName + "]. " +
                "See getCause() for more information.",
                e
             );
         }
        
         // ******** Compute the Insertion Point, and insert an <A HREF=...> Anchor-Link ***********
         @SuppressWarnings("unchecked") // Need since this vector is changed.  Thread-safe
         Vector<HTMLNode> srcCodeAnchor = (Vector<HTMLNode>) SRCCODE_ANCHOR.clone();
        
         // insert the information specific to the source-code file. 
         Attributes.update
             (srcCodeAnchor, AUM.Set, anchorPosArr, "href", hiLitedSrcCodeFileName, SD.SingleQuotes);
        
         final TextNode sourceFileNameTxN = new TextNode(pr.srcCodeFileName);
         ReplaceNodes.r(
             srcCodeAnchor, fileNamePosArr,
             (HTMLNode n, int dummy1, int dummy2) -> sourceFileNameTxN
         );
        
         DotPair insertionPoint = TopDescription.descriptionAtTop(pr.fileVec);
        
         if (insertionPoint != null)
             pr.fileVec.addAll(insertionPoint.end, srcCodeAnchor);
         else
             throw new UpgradeException(
                 "Unable to insert HiLited Source Code Links.  Was unable to computer an " +
                 "insertion-point.  Currently Processing File:\n" +
                 pr.jdFileName
             );
        
         if (pr.sw != null) pr.sw.println(
             "\tHiLited '.java' Source-Code File saved successfully to disk: " +
             C.BYELLOW + hiLitedSrcCodeFileName + C.RESET
         );