Package Torello.JavaDoc
Class AnnotationElem
- java.lang.Object
-
- Torello.JavaDoc.Declaration
-
- Torello.JavaDoc.AnnotationElem
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<AnnotationElem>
public class AnnotationElem extends Declaration implements java.io.Serializable, java.lang.Comparable<AnnotationElem>, java.lang.Cloneable
Similar tojava.lang.reflect
This class is heavily used internally, and can be used (if needed) to modify Java Doc Web-Pages, programmatically.
HTML Processors that sort the Web-Page "Summary-Tables" will provide instances of this class to your Summary-Sorter Handler methods. Summary-Sorter handlers usually implement theSummarySorterHelperinterface; please review that class for more about sorting Java-Doc Page Summary Tables.
The HTML Processors that upgrade Web-Page "Detail Elements" also rely heavily on this class. Please review the class:ReflHTMLfor more information about Java-Doc Web-Page Detail Sections.Reflection Class:
Holds all information extracted from'.java'Annotation (@interface) Source-Files about all Elements identified in that file.
Instances of this Class are Obtained From:
Use of the Reflection-HTML API is *NOT REQUIRED* to perform a standard Java Doc HTML File Upgrade. This "extra API" allows for programmatic modification of Java Doc HTML. This class contains quite a bit of reflected information, and furthermore, here there is a hook to the Native Java Parser Reflection Class.ReflHTML&SummaryTableHTML
Classclass AnnotationElemallows for storing the name, definition, default-value, etc... of anAnnotation Element. Note that an'Annotation Element'is not the same as a Java'Annotation' (@interface). An'Annotation Element'is merely the (optional) element / parameter which may (if used) help specify the contents of a JavaAnnotation.
For Instance: With the commonly-usedannotationnamed@SuppressWarnings(...), the Value-Parameters that are passed inside the parenthesis are the'value'Annotation-Element. This'value'may be assigned several JavaString'ssuch as:'rawtypes', 'unchecked',etc...- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/JavaDoc/AnnotationElem.java
- Open New Browser-Tab: Torello/JavaDoc/AnnotationElem.java
File Size: 14,841 Bytes Line Count: 336 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field static longserialVersionUIDReflection & Inspection final-String(s) Modifier and Type Field StringdefaultValueStringtypeStringtypeJOWSource-Parser Library-Hook References (Transient / Not Serializable) Modifier and Type Field MethodTreemethodTree-
Fields inherited from class Torello.JavaDoc.Declaration
annotations, body, entity, id, jdComment, jduAnnotationMirrors, location, modifiers, name, signature
-
-
Constructor Summary
Public Constructors that are Intended for Internal-Use, Only Constructor AnnotationElem(MethodTree mt, Torello.JDUInternal.Miscellaneous.EntityAnnotationData ead, TreeUtils util)AnnotationElem(AnnotationElem aeFromSourceParser, String jdTypeStr)
-
Method Summary
Generate Artificial-Intelligence Token-Streams, which are easily converted to Embeddings. Modifier and Type Method ReadOnlyList<ReadOnlyList<String>>getTokenStreams()Methods: interface java.lang.Comparable Modifier and Type Method intcompareTo(AnnotationElem ae)Methods: class java.lang.Object Modifier and Type Method booleanequals(AnnotationElem other)StringtoString()StringtoString(int flags)
-
-
-
Field Detail
-
serialVersionUID
public static final long serialVersionUID
This fulfils the SerialVersion UID requirement for all classes that implement Java'sinterface java.io.Serializable. Using theSerializableImplementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final long serialVersionUID = 1;
-
type
public final java.lang.String type
An Annotation-Element may only assume one of several types, as per the Java Sun / Oracle Documentation. The type must be one of the following, or a compile-time error occurs:- a primitive type
- String
- Class or an invocation of Class
- An enum type
- An annotation type
- An (1 dimensional) array type whose component type is one of the preceding types
- Code:
- Exact Field Declaration Expression:
public final String type;
-
typeJOW
public final java.lang.String typeJOW
JOW: Just One Word
The Just One Word convention used by the JDU Tool elminates BOTH Package-Name Information AND (for Inner-Types / Nested-Types) any & all Container-Class Information from the Type-String's.
The Java-Doc Upgrader does not perform a Compiler-Styled "Linking Pass" on the Java-Doc Web-Pages it parses, and must suffice with the unlinked Type-Names provided by the Oracle AST-Parser and Java-Doc'.html'Output Pages.- Code:
- Exact Field Declaration Expression:
public final String typeJOW;
-
defaultValue
public final java.lang.String defaultValue
The default value assigned to this element. This may be null if there is no assigned default value.- Code:
- Exact Field Declaration Expression:
public final String defaultValue;
-
methodTree
public final transient com.sun.source.tree.MethodTree methodTree
Hook Reference to Sun/Oracle Parser-Refletion Class
Though this class offers a streamlined set of reflection features, the Native Oracle Library Reflection-Classes offer a detailed AST interface into the standard Java Compiler. If you would like to use these Tree's to provide further code analysis on your Java-Doc Pages, this field is provided as a convenience for such purposes.
If a user decides to make use of the native OracleMethodTreeinstance that was used to build thisAnnotationEleminstance, it may be retrieved from thistransientfield.MethodTreeNote:
The packagecom.sun.source.tree"reuses" or "overloads" theMethodTreeclass.com.sun.source.tree.MethodTreecan actually represent either a Method, or an Annotation-Element (or even a Constructor! but that's besides the point).- Code:
- Exact Field Declaration Expression:
public final transient MethodTree methodTree;
-
-
Method Detail
-
toString
public java.lang.String toString()
Generates aStringof thisAnnotation Element, with all information included.- Overrides:
toStringin classDeclaration- Returns:
- A printable string of this
AnnotationElem. - See Also:
toString(int)- Code:
- Exact Method Body:
String def = (defaultValue != null) ? ("Default: [" + StrPrint.abbrevEndRDSF(defaultValue, MAX_STR_LEN, true) + "]\n") : ""; return "Name: [" + name + "]\n" + "Declaration: [" + StrPrint.abbrevEndRDSF(signature, MAX_STR_LEN, true) + "]\n" + "Type: [" + typeJOW + "]\n" + "Modifiers: [" + StrCSV.toCSV(modifiers, true, true, null) + "]\n" + def + // This will **NEVER** be null - unless 'this' instance was built from an HTML File, // rather than a source-code file. Instances like that are only used temporarily, and // are garbage collected instantly. Do this check anyway (just in case). "Location: " + ((this.location == null) ? "null" : ('[' + this.location.quickSummary() + ']'));
-
toString
public java.lang.String toString(int flags)
This method accepts a'flags'parameter which has been constructed using the Bit-Masks provided by thePFclass. Please view the Static-Constants which are provided by classPFfor more information about modifying the return-value of thistoString(int)method.
There is additional information printed by this'toString'method (versus the zero-argument, standard, Java'toString'). This method will print any available Java-Doc Comment's that were placed on thisAnnotationElem.
This'toString'also allows for adding UNIX-Terminal color codes.- Overrides:
toStringin classDeclaration- Parameters:
flags- These are defined in thePrint-Flagsclass- Returns:
- A printable
Stringof thisAnnotationElem. - See Also:
PF,toString()- Code:
- Exact Method Body:
boolean color = (flags & UNIX_COLORS) > 0; return printedName("Element", 14, color) + printedDeclaration(14, color) + "Type-JOW: [" + typeJOW + "]\n" + printedModifiers(14) + printedLocation(14, color, (flags & BRIEF_LOCATION) > 0) + // The previous method does not add a '\n' end to the end of the returned string // These are both optional, they add a '\n' AT THE BEGINNING if one of them is included printedDefault(color) + printedComments(14, color, (flags & JAVADOC_COMMENTS) > 0);
-
compareTo
public int compareTo(AnnotationElem ae)
Java'sinterface Comparable<T>requirements. This does a very simple comparison using the two elements'Declaration.namefield.- Specified by:
compareToin interfacejava.lang.Comparable<AnnotationElem>- Parameters:
ae- Any otherAnnotationElemto be compared to'this' AnnotationElem- Returns:
- An integer that fulfills Java's
Comparable<AnnotationElem>interface requirements. - Code:
- Exact Method Body:
return (this == ae) ? 0 : this.name.compareTo(ae.name);
-
equals
public boolean equals(AnnotationElem other)
This should be called an "atypical version" of the usualequals(Object other)method. This version of equals merely compares the name of the element defined. The presumption here is that the definition of an 'element' only has meaning - at all - inside the context of anAnnotationwhere that element has been defined. Since inside any'.java'Annotation, there may only be one element with a given name, this method shall returnTRUEwhenever the element being compared also has the same name.- Parameters:
other- This may be any otherAnnotation-Element. It is strongly suggested that'other'be anelementdefined in the same'.java'source-code file as'this'element.- Returns:
- This method returns
TRUEwhen'this'instance ofAnnotationElemhas the same'name'as the name of input-parameter'other' - Code:
- Exact Method Body:
return this.name.equals(other.name);
-
getTokenStreams
public ReadOnlyList<ReadOnlyList<java.lang.String>> getTokenStreams()
Description copied from class:DeclarationChat-GPT and me wrote a Token-Stream Generator-Method that can be used for creating the List-Data that needs to be sent to the Embeddings-Generator for creating an Embeddings-RAG using my Reflection-Classes.- Specified by:
getTokenStreamsin classDeclaration- Returns:
- A proper list of "Chunked Tokens" that may be sent to the Open-AI REST-API to generate an Embeddings-Vector
- Code:
- Exact Method Body:
final ROArrayListBuilder<ReadOnlyList<String>> tokens = new ROArrayListBuilder<>(); ROArrayListBuilder<String> b = new ROArrayListBuilder<>(); tokens.add(ReadOnlyList.of("SECTION", "entity", "annotation-element")); tokens.add(ReadOnlyList.of("SECTION", "name", this.name)); tokens.add(ReadOnlyList.of("SECTION", "type", this.typeJOW)); if ((this.defaultValue != null) && (!this.defaultValue.isEmpty())) tokens.add(ReadOnlyList.of("SECTION", "default", this.defaultValue)); if ((this.annotations != null) && (this.annotations.size() > 0)) { b.add("SECTION"); b.add("annotations"); for (String a : this.annotations) b.add(a); tokens.add(b.build()); } return tokens.build();
-
-