Package Torello.HTML.Tools.JavaDoc
Class HiLiteFields
- java.lang.Object
-
- Torello.HTML.Tools.JavaDoc.HiLiteFields
-
public class HiLiteFields extends java.lang.Object
HiLiteFields - Documentation.
The primary use of this class is that it allows a user to request that the Java-Doc upgrade package hilite each and every field within an (already existing) Java-Doc HTML Class, Enumerated-Type, or Interface Page.
NOTE: This class will only provide Field Declarations as Hilited Code. Constructors and Methods are not hilited here.
TheHiLite Field Declaration
procedure is the one which creates segments on your Java Doc Pages that look like:
Hi-Lited Source-Code:
- View Here: Torello/HTML/Tools/JavaDoc/HiLiteFields.java
- Open New Browser-Tab: Torello/HTML/Tools/JavaDoc/HiLiteFields.java
Stateless Class:
This class neither contains any program-state, nor can it be instantiated.
The
The
@StaticFunctional
Annotation may also be called 'The Spaghetti Report'- 1 Constructor(s), 1 declared private, zero-argument constructor
- 2 Method(s), 2 declared static
- 1 Field(s), 1 declared static, 1 declared final
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method static int
run(CommonParamRecord pr)
-
-
-
Method Detail
-
run
public static int run(CommonParamRecord pr)
This method will hilite allField's
that are scraped from a Java Doc Generated HTML Documentation Page for a Class, Enumerated Type, or Interface. The hilited source-code is inserted into the Java-Doc HTML Web-Page in the'Field Details'
section for any / allField's
found on the page.- 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"- Returns:
- This will return a count on exactly how many
Field's
have had their code-hilited declarations inserted into the JavaDoc Documentation File for this class. - 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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
if (pr.sw != null) pr.sw.println("HiLiteFields.run(...) "); int countNumFieldsHiLited = 0; int numFieldsSkipped = 0; // ********** Check whether the fileVec has any Fields in the first place **************** if (Details.hasFieldDetails(pr.fileVec) == null) { if (pr.sw != null) pr.sw.println( "\tJavaDoc File: " + C.BYELLOW + pr.jdFileName + C.RESET + " does not have a " + "Field-Details-Section, Skipping..." ); return 0; // No Fields, Skip this file } // ********** Check whether the fileVec has any Fields in the first place **************** // ********** Iterate through every field found in the '.html' file ********************** HNLIInclusive fieldsIter = Details.fieldDetailsIterator(pr.fileVec); boolean firstIteration = true; int cur = 0; while (fieldsIter.hasNext()) { // Retrieves the next field-details section defined in the HTML file using the // "Field Details Iterator" DotPair fieldDP = fieldsIter.nextDotPair(); // The instance of JavaDocHTMLFile (jdhf) was built using the same '.html' file, and // the same iterator. Using the 'getField(counter)' should retrieve the parsed version // of this HTML-defined java field from the javadoc documentation HTML page. Field fromHTMLFileField = pr.jdhf.getField(cur++); // Now we need to search through all of the fields in the JavaSourceCodeFile for a // field with the EXACT SAME NAME. Field fromSrcFileField = (fromHTMLFileField != null) ? pr.jscf.findField(fromHTMLFileField) : null; // Since the instance of "Field" that is retrieved from the Source-Code '.java' file // is guaranteed to have the "declaration" (as a String) - we can get that string and // save it and hilite it. String fieldDeclStr = (fromSrcFileField != null) ? fromSrcFileField.signature : null; // Output a tab or else it will look "lopsided" if (pr.sw != null) if (firstIteration) { firstIteration = false; pr.sw.print('\t'); } // If there was no field-definition string found ... skip to the next method. if (fieldDeclStr == null) { if (pr.sw != null) pr.sw.print ("[NOT-FOUND]: " + C.BRED + fromHTMLFileField.name + C.RESET + " "); numFieldsSkipped++; continue; } // PRINT OUT THE FIELD if (pr.sw != null) pr.sw.print(C.BGREEN + fromHTMLFileField.name + C.RESET + " "); // ********** Compute the Insertion Point ***************** // The "<DL> <DT></DT><DD></DD> </DL>" lists are for the throws, see-also, returns, etc.... // The Code HiLited Field-Definition HTML needs to be inserted into its own: // <DT>Code:</DT>\n // <DD> Hi-Lited Field-Declaration DIV created by HiLite.ME Server</DD> // The Insertion point shall be right before the closing </DL> HTML Element. This means // HiLited Code will *always* be the last 'thing' (for lack of a technical term) that you // can see in a Field-Details Section. // // ALSO: There are some fields for which no Javadoc Comments have been written, and // therefore, there is no // HTML "Definition List" already present in that particular field's "Field Details" // Section. In this case, an HTML <DL> ... </DL> surrounding element needs to be // created. // ********** Compute the Insertion Point ***************** int insertionPoint = TagNodeFind.last (pr.fileVec, fieldDP.start, fieldDP.end, TC.ClosingTags, "dl"); boolean needToBuildDefList = insertionPoint == -1; // ********** Compute the Insertion Point ***************** // If we need to build the <DL> (Definition List), then we will also have to find a new // insertion point. The field-details section ends with a closing '</LI>' element, and // then a closing '</UL>' Element right before the '</LI>' is where the insertion should // occur. // NOTE: Most of the time, for fields (different from methods), a <DL> ... </DL> will // need to be built. // ********** Compute the Insertion Point ***************** if (needToBuildDefList) insertionPoint = TagNodeFind.last (pr.fileVec, fieldDP.start, fieldDP.end, TC.ClosingTags, "li"); if (insertionPoint == -1) // This case should never happen, but keep it is here, just in case. // (Kind of the point of exceptions). Guarantees no "Index Out of Bounds" // Exceptions, and a friendly message. { if (pr.sw != null) pr.sw.println( C.BRED + "Could not determine a place to put the hilited code in the JD Page. " + "NOT INSERTING CODE." + C.RESET ); continue; } // ******************************************************** // ************ Call the Code Hilite Server *************** // ******************************************************** try { fieldsIter.insertAt(hiLiteFieldDeclaration (fieldDeclStr, needToBuildDefList, pr.hiLiter), insertionPoint); } catch (IOException | HiLiteException e) { throw new HiLiteError( "Failed to HiLite Field-Declaration (first three lines): [\n" + StringParse.firstNLines(fieldDeclStr, 3) + "\n].\n" + "Currently Processing Java Source Code File: [" + pr.srcCodeFileName + "].\n" + "Currently Processing JavaDoc HTML Documentation Page: [" + pr.jdFileName + "].\n" + "Please see getCause() throwable for details.\n" + EXCC.toString(e), e ); } // ********** Call the Code Hilite Server ***************** // Loop to the next method. countNumFieldsHiLited++; } if ((countNumFieldsHiLited > 0) || (numFieldsSkipped > 0)) if (pr.sw != null) pr.sw.println(); if (numFieldsSkipped > 0) if (pr.sw != null) pr.sw.println( "\t" + C.BRED + "Skipped " + C.RESET + C.BBLUE + StringParse.zeroPad(numFieldsSkipped, 5) + C.RESET + " Fields." ); if (pr.sw != null) pr.sw.println( "\tHilited " + C.BBLUE + StringParse.zeroPad(countNumFieldsHiLited, 5) + C.RESET + " Fields." ); return countNumFieldsHiLited;
-
-