Package Torello.JavaDoc
Class Method
- java.lang.Object
-
- Torello.JavaDoc.Declaration
-
- Torello.JavaDoc.Callable
-
- Torello.JavaDoc.Method
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<Method>
public class Method extends Callable implements java.io.Serializable, java.lang.Comparable<Method>, 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'Source-Files about Method's 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
ClassMethodallows for storing the name, definition and modifiers list of a method.- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/JavaDoc/Method.java
- Open New Browser-Tab: Torello/JavaDoc/Method.java
File Size: 17,675 Bytes Line Count: 422 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field static longserialVersionUIDReflection & Inspection final-String(s) Modifier and Type Field StringreturnTypeStringreturnTypeJOWSource-Parser Library-Hook References (Transient / Not Serializable) Modifier and Type Field MethodTreemethodTree-
Fields inherited from class Torello.JavaDoc.Callable
autoFindID, exceptions, parameterAnnotations, parameterNames, parameterTypes, parameterTypesJOW
-
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 Method(MethodTree mt, Torello.JDUInternal.Miscellaneous.EntityAnnotationData ead, TreeUtils util)Method(Torello.JDUInternal.Parse.HTML.Signature.D1_CallableSignature cSig)Method(Torello.JDUInternal.Parse.HTML.Signature.D1_CallableSignature cSig, Method mFromSourceParser)
-
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(Method m)Methods: class java.lang.Object Modifier and Type Method booleanequals(Method other)StringtoString()StringtoString(int flags)-
Methods inherited from class Torello.JavaDoc.Callable
getParameterAnnotations, getParameterType, getParameterTypeJOW, hasAnnotatedParameters, nearlyEqualsCallableSig, numAnnotatedParameters, numParameters
-
-
-
-
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;
-
returnType
public final java.lang.String returnType
The return type of themethod, as aString. If this is a method with a'void'return-type, this shall be "void".- Code:
- Exact Field Declaration Expression:
public final String returnType;
-
returnTypeJOW
public final java.lang.String returnTypeJOW
The return type of themethod, as aString.
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.
As an example of this, If a parameter to aMethod, or the type of aFieldinside of a class had the fully qualified type-name:java.util.stream.Stream.Builder<String>
theJOW-Stringfor that type would simply be the word"Builder"
For Arrays:
If the type, itself, is an array of any kind, any & all Array-Brackets will be included in thisString-Name. Please review the Example Table, below:Output JOW-String Input Type "Entry""java.util.Map.Entry<K, V>""Vector""java.util.Vector<E>""Vector""Vector<TagNode>""Vector""Vector<Vector<TagNode>>""Vector""java.util.Vector<Vector<TagNode>>""String""String""String""java.lang.String""String[]""java.lang.String[]""Integer""Integer""Integer[]""java.lang.Integer[]""String[]""String...""String[]""java.lang.String..."- Code:
- Exact Field Declaration Expression:
public final String returnTypeJOW;
-
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 thisMethodinstance, it may be retrieved from thistransientfield.- Code:
- Exact Field Declaration Expression:
public final transient MethodTree methodTree;
-
-
Method Detail
-
toString
public java.lang.String toString()
Generates a string of this method, with most information included.
Reduced Information:
This'toString'will not return every piece of information contained by this class. For example, both the method body, and any possible JavaDoc Comments are not included. For a more enhancedtoString()method version, invoke thetoString(PrintFlags)method which acceptsPrint-Flags.- Overrides:
toStringin classCallable- Returns:
- A printable
Stringof this method. - See Also:
PF,toString(int)- Code:
- Exact Method Body:
return "Name: [" + name + "]\n" + "Signature: [" + StrPrint.abbrevEndRDSF(signature, MAX_STR_LEN, true) + "]\n" + "Modifiers: [" + StrCSV.toCSV(modifiers, true, true, null) + "]\n" + printedParameterNamesTS() + printedParameterTypesTS() + "Return Type: [" + returnType + "]\n" + printedExceptionsTS() + // 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.- Overrides:
toStringin classCallable- Parameters:
flags- These are defined in thePrint-Flagsclass- Returns:
- A printable
Stringof thisMethod. - See Also:
toString(),PF- Code:
- Exact Method Body:
boolean color = (flags & UNIX_COLORS) > 0; Ret2<Boolean, Boolean> jow = jowFlags(flags); return printedName("Method", 20, color) + printedSignature(20, color) + printedModifiers(20) + printedParamNames() + printedParamTypes(jow) + printedReturnType(jow, color) + printedExceptions() + printedLocation(20, 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 printedComments(20, color, (flags & JAVADOC_COMMENTS) > 0) + printedCallableBody(flags);
-
compareTo
public int compareTo(Method m)
Java'sinterface Comparable<T>requirements. This does a very simple comparison using the two method'sDeclaration.namefield. If the name comparison will not suffice in making a decision, then the number of parameters, and parameter-types are used to making the sort-decision.- Specified by:
compareToin interfacejava.lang.Comparable<Method>- Parameters:
m- Any otherMethodto be compared to'this' Method- Returns:
- An integer that fulfills Java's
Comparable<Method>interface requirements. - Code:
- Exact Method Body:
// Identical References if (this == m) return 0; // Sorting by ignoring case is best - usually for the looks of a list // NOTE: Returning '0' is bad, because a TreeSet will remove duplicate-elements. This // means two different meethods with the same name would not "fit" into a treeset. int ret = this.name.compareToIgnoreCase(m.name); if (ret != 0) return ret; // Try to identify a different without ignoring case. ret = this.name.compareTo(m.name); if (ret != 0) return ret; ret = this.numParameters() - m.numParameters(); if (ret != 0) return ret; for (int i=0; i < this.parameterTypesJOW.size(); i++) { ret = this.parameterTypesJOW.get(i).compareTo(m.parameterTypesJOW.get(i)); if (ret != 0) return ret; } return 0;
-
equals
public boolean equals(Method other)
This should be called an "atypical version" of the usualequals(Object other)method. This version of equals merely compares the name and parameters-list of the method. The presumption here is that the definition of a 'method' only has meaning - at all - inside the context of aclass, interface,orenumerated-typewhere that method is defined. Since inside any'.java'source-code file, there may only be one method with a given name and parameter-list, this shall returnTRUEwhenever the method being compared has the same name and parameter types as'this'does.- Parameters:
other- This may be any othermethod. It is strongly suggested that this be amethoddefined in the same'.java'source-code file as'this' method.- Returns:
- This method returns
TRUEwhen'this'instance ofMethodhas both the samepublic final Sting nameand the same parameter-list as'other'. - Code:
- Exact Method Body:
// The method's must have the same name! if (! this.name.equals(other.name)) return false; // If the number of parameters in the 'other' instance of Method differ from the number // of parameters in 'this' Method, then return FALSE immediately. It cannot be a match. if (this.numParameters() != other.numParameters()) return false; // If both of these have zero parameters, and their names have matched, return true // immediately if (this.numParameters() == 0) return true; // If any of the parameter-names are different, break immediately and return false; for (int i=0; i < this.parameterNames.size(); i++) if (! this.parameterNames.get(i).equals(other.parameterNames.get(i))) return false; // If the parameter-types listed by the javadoc '.html' file differ from the parameter // types listed in the original '.java' source-code file, then break immediately. // // NOTE: The "package-information" for the FULL CLASS OR INTERFACE NAME is not always // available. for (int i=0; i < this.parameterTypesJOW.size(); i++) if (! this.parameterTypesJOW.get(i).equals(other.parameterTypesJOW.get(i))) return false; // ALL TEST PASSED return true;
-
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", "method")); tokens.add(ReadOnlyList.of("SECTION", "name", this.name)); tokens.add(ReadOnlyList.of("SECTION", "signature", this.signature)); tokens.add(ReadOnlyList.of("SECTION", "return-type", this.returnTypeJOW)); if ((this.parameterNames != null) && (this.parameterNames.size() > 0)) { b.add("SECTION"); b.add("parameters"); for (int i = 0; i < this.parameterNames.size(); i++) b.add(this.parameterTypesJOW.get(i) + " " + this.parameterNames.get(i)); tokens.add(b.build()); } if ((this.modifiers != null) && (modifiers.size() > 0)) { b = new ROArrayListBuilder<>(); b.add("SECTION"); b.add("modifiers"); for (String m : this.modifiers) b.add(m); tokens.add(b.build()); } if ((this.exceptions != null) && (this.exceptions.size() > 0)) { b = new ROArrayListBuilder<>(); b.add("SECTION"); b.add("throws"); for (String exn : this.exceptions) b.add(exn); tokens.add(b.build()); } if ((this.annotations != null) && (annotations.size() > 0)) { b = new ROArrayListBuilder<>(); b.add("SECTION"); b.add("annotations"); for (String a : this.annotations) b.add(a); tokens.add(b.build()); } return tokens.build();
-
-