Package Torello.JavaDoc
Class Callable
- java.lang.Object
-
- Torello.JavaDoc.Declaration
-
- Torello.JavaDoc.Callable
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
Constructor
,Method
public abstract class Callable extends Declaration implements java.io.Serializable
Reflection Class:
Common-Root Ancestor Class of bothMethod
andConstructor
.
This class isabstract
and is simply used to represent either a method, or a constructor - both of which can be'called'
by a line of java code. AllCallable's
have a few things in common, a parameter list, and exception throw list, and a name.
Thisabstract
class has Method'ss for handling these features. BothConstructor
andMethod
inherit this class, and allow for 're-using' the Reflection-Stuff about Parameter-Lists, Parameter-Types and Throw-Clauses.- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/JavaDoc/Callable.java
- Open New Browser-Tab: Torello/JavaDoc/Callable.java
File Size: 29,827 Bytes Line Count: 700 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field static long
serialVersionUID
ID Reserved for Future Use Modifier and Type Field String
autoFindID
Read-Only List of Parameter-Information, as a Java String Modifier and Type Field ReadOnlyList<ReadOnlyList<String>>
parameterAnnotations
ReadOnlyList<String>
parameterNames
ReadOnlyList<String>
parameterTypes
ReadOnlyList<String>
parameterTypesJOW
Read-Only List of Exception-Information, as a Java String Modifier and Type Field ReadOnlyList<String>
exceptions
-
Fields inherited from class Torello.JavaDoc.Declaration
annotations, body, entity, id, jdComment, jduAnnotationMirrors, location, modifiers, name, signature
-
-
Method Summary
Get Parameter Information, by Parameter-Name Modifier and Type Method ReadOnlyList<String>
getParameterAnnotations(String parameterName)
String
getParameterType(String parameterName)
String
getParameterTypeJOW(String parameterName)
boolean
nearlyEqualsCallableSig(Torello.JDUInternal.Parse.HTML.Other.CallableSignature cSig)
Get Parameter Count Data Modifier and Type Method boolean
hasAnnotatedParameters()
int
numAnnotatedParameters()
int
numParameters()
Methods: class java.lang.Object Modifier and Type Method String
toString()
String
toString(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 theSerializable
Implementation 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;
-
autoFindID
public final java.lang.String autoFindID
-
parameterNames
public final ReadOnlyList<java.lang.String> parameterNames
The names of all parameters to thisMethod
orConstructor
.
Parallel List:
This list must be considered a parallel list to the other parameter-related list:parameterTypes
,parameterTypesJOW
andparameterAnnotations
-
parameterTypes
public final ReadOnlyList<java.lang.String> parameterTypes
This contains the types of the parameters, stored asString's
. The contents of theseString's
do include: package-name, containing classes (if inner-classes), and generic-parameter expressions (if generic-types). These names are as fully-qualified as the AST Parser allows.
JOW Alternative:
TheReadOnlyList
parameterTypesJOW
reduces these types (asString's
) to a single-word. If aMethod
or aConstructor
that accepts a paremeter such asjava.util.Iterable<Integer>
, and it seems 'difficult to work with' - the entry inparameterTypesJOW
at the same array-location would contain, simply, the JavaString 'Iterable'
.
Parallel List:
This list must be considered a parallel list to the other parameter-related list:parameterNames
,parameterTypesJOW
andparameterAnnotations
-
parameterTypesJOW
public final ReadOnlyList<java.lang.String> parameterTypesJOW
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 aField
inside of a class had the fully qualified type-name:java.util.stream.Stream.Builder<String>
theJOW-String
for 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..."
Parallel List:
This list must be considered a parallel list to the other parameter-related list:parameterNames
,parameterTypes
andparameterAnnotations
-
parameterAnnotations
public final ReadOnlyList<ReadOnlyList<java.lang.String>> parameterAnnotations
Any parameters that are annotated will have the exact text-String
of the annotations that were used in the source-code for that parameter stored in this two-dimensionalString[][]
array.
This list will retrieve and contain the actual character data that may be found in the source-code file for an element in acom.sun.source
'AST' (Abstract Syntax Tree). The list of annotations on a parameter (if any) will each be saved as ajava.lang.String
.
Null Warning:
Unlike the other lists in classCallable
, when there are no parameters for aCallabe
, or when there are parameters, but none of them have been annotated, for the purposes of efficiency and better memory management, this field will simply be assigned null.
In almost all cases (particularly in the Java HTML Library), this two-dimensional list, itself, really will be null - since parameter annotations are quite uncommon. Perhaps, some users make use of them from time to time.
Parallel List:
This list must be considered a parallel list to the other parameter-related list:parameterNames
,parameterTypes
andparameterTypesJOW
-
exceptions
public final ReadOnlyList<java.lang.String> exceptions
The names of allException, Error
andThrowable
that may be thrown by thisConstructor
orMethod
.
NOTE: Only exceptions which are included in the actualDeclaration.signature
, inside the original'.java'
source-file for thisCallable
will be listed in this array.
-
-
Method Detail
-
numParameters
public int numParameters()
- Returns:
- The size of all three of the parameter
ReadOnlyList
's' - Code:
- Exact Method Body:
return parameterNames.size();
-
getParameterType
public java.lang.String getParameterType(java.lang.String parameterName)
This will retrieve the type of the parameter (as aString
) that has the name'parameterName'
. This method will simply return null, gracefully, if thisMethod
orConstructor
does not have a parameter with that name. This method will not throw an exception in such cases.- Parameters:
parameterName
- The name of the parameter whose type you are requesting.- Returns:
- The fully-qualified type of the parameter, as a
String
having the name'parameterName'
, or null if no such type exists. - See Also:
parameterTypes
,parameterNames
- Code:
- Exact Method Body:
for (int i=0; i < parameterNames.size(); i++) if (parameterNames.get(i).equals(parameterName)) return parameterTypes.get(i); return null;
-
getParameterTypeJOW
public java.lang.String getParameterTypeJOW (java.lang.String parameterName)
This will retrieve the type of the parameter (as aString
) that has the name'parameterName'
. This method will simply return null, gracefully, if thisMethod
orConstructor
does not have a parameter with that name. This method will not throw an exception in such cases.JOW: Just One Word
- The types in theString[]
array fieldparameterTypesJOW
are simplified to just a single 'Java Identifier' part. All outer-class, package, and generic type-parameter information are stripped from these array entries. Please see the detailed-description ofparameterTypesJOW
for a better explanation.- Parameters:
parameterName
- The name of the parameter whose type you are requesting.- Returns:
- The type of the parameter, as a one-word
String
having the name'parameterName'
. - See Also:
parameterTypesJOW
,parameterTypes
,parameterNames
- Code:
- Exact Method Body:
if (parameterNames != null) for (int i=0; i < parameterNames.size(); i++) if (parameterNames.get(i).equals(parameterName)) return parameterTypesJOW.get(i); return null;
-
getParameterAnnotations
public ReadOnlyList<java.lang.String> getParameterAnnotations (java.lang.String parameterName)
This will retrieve the annotations-list that may (or may not) adorn the parameter which uses the name'parameterName'
.
This method will simply return null, gracefully, if thisMethod
orConstructor
does not have a parameter with that name. This method will not throw an exception in such cases.
NOTE:This method will also return null even if a parameter having the provided name is found, but that parameter wasn't annotated with anything. If a null is returned, distinguishing between the case where'parameterName'
just wasn't found, and the case where that parameter wasn't annotated - isn't possible here.- Parameters:
parameterName
- The name of the parameter whose annotation-list you are requesting.- Returns:
- The type of the parameter having the name
'parameterName'
. - See Also:
parameterAnnotations
,parameterNames
- Code:
- Exact Method Body:
if (parameterAnnotations == null) return null; for (int i=0; i < parameterNames.size(); i++) if (parameterNames.get(i).equals(parameterName)) return parameterAnnotations.get(i); // In the line above, if a parameter isnt annotated, that location in the // array will have a 'null' return null;
-
hasAnnotatedParameters
public boolean hasAnnotatedParameters()
This will look at each parmeter's annotation array to see if there are any parameters in thisCallable's
invocation parameter-list that were annotated with anything.- Returns:
TRUE
if there are any parameters that were annotated with something, and false if every parameter in the parameter-list had a 'null'String
array of parameter-annotations.
If this instance ofCallable
is one which does not accept any parameters, this methhod will returnFALSE
immediately.
NOTE: The internal'parameterAnnotations'
field for classCallable
is implemented as a two-dimensionalString
-array. There may be any number of parameters that are passed to aMethod
orConstructor
, and each of those parameters may have any number of annotations that were attached to them.
SANITY-CHECK Likely99.99%
of the parameters in the Java HTML library do not have any parameter's that are annotated.- See Also:
parameterAnnotations
- Code:
- Exact Method Body:
return parameterAnnotations != null;
-
numAnnotatedParameters
public int numAnnotatedParameters()
Reports how many of the parameters in the internal list of parameters that had annotations attached to them.
SANITY-CHECK Likely99.99%
of the parameters in the Java HTML library do not have any parameter's that are annotated.- Returns:
- This will count how many parameters which are used by this
Callable
(eitherMethod
orField
) that have annotations that were attached to the parameter. - See Also:
parameterAnnotations
- Code:
- Exact Method Body:
int count = 0; if (parameterAnnotations == null) return 0; // NOTE: each parameter has an "Annotation List" stored in a 2-D array. This is why // this for-loop is using 'String[]', rather than 'String' ... // A parameter may be annotated with zero annotations, one, or many annotations. for (ReadOnlyList<String> paList : parameterAnnotations) if (paList.size() > 0) count++; return count;
-
nearlyEqualsCallableSig
public boolean nearlyEqualsCallableSig (Torello.JDUInternal.Parse.HTML.Other.CallableSignature cSig)
An internally used utility that is accessed from outside this package. This method allows a user to check whether'this'
method has an identical signature to the input instance of'CallableSignature'
.
Because this Upgrader does not execute an actual Compiler Linking-Pass, only the 'JOW' (Just One Word) of the input Parameter Types are checked.- Parameters:
cSig
- The Type Signature for any Method or Constructor.- Returns:
TRUE
if the Parameter-Names fpr'this'
Callable are all equal to the names in'cSig'
AND the "Just One Word" types match those in'cSig'
.
If either pf these two tests fail, thenFALSE
is returned.- Code:
- Exact Method Body:
// This works for Methods and Constructors. This method used to be in the actual 'Method' // and 'Constructor' sub-class due to this one-line optimization. (This is an un-necessary // check for Constructors, but not for methods). if (this.numParameters() != cSig.parameterNames.size()) return false; // If there are no parameters (for either of them), then 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(cSig.parameterNames.get(i))) return false; // If the parameter-types listed by the javadoc '.html' file differ from 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.parameterTypes.size(); i++) if (! this.parameterTypesJOW.get(i).equals(cSig.parameterTypesJOW.get(i))) return false; // ALL TESTS PASSED return true;
-
toString
public java.lang.String toString()
Dummy Method. Overriden by Concrete Sub-Classes.- Overrides:
toString
in classDeclaration
- See Also:
Method.toString()
,Constructor.toString()
- Code:
- Exact Method Body:
return "Callable is Abstract, all Concrete Sub-Classes Override this method.";
-
toString
public java.lang.String toString(int flags)
Dummy Method. Overriden by Concrete Sub-Classes.- Overrides:
toString
in classDeclaration
- See Also:
Method.toString(int)
,Constructor.toString(int)
- Code:
- Exact Method Body:
return "Callable is Abstract, all Concrete Sub-Classes Override this method.";
-
-