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.
Reflection-Classes Inheritance-Diagram
Native JDK API Hook:
All reflection classes above, also contain an additional (transient
, non-Serializable
) field that hooks into the native Java Tree-Parser Tools available in JDK Packagecom.sun.source.tree.*
If a more in-depth Code-Analysis is needed, the JDK's AST's have full and complete Parses of your Source-Code that can facilitate almost any analysis.- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/JavaDoc/Callable.java
- Open New Browser-Tab: Torello/JavaDoc/Callable.java
File Size: 28,557 Bytes Line Count: 678 '\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, 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)
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
If theString's
in a type-as-String
contain complicated or intricate detailed information, and all you need is a simple identifier, theJOW-String
stores the type-as-String
with allpackage-name
andgeneric-parameters
(if they were present / included) stripped from theString
. Furthermore, if the type was originally an inner-class, even the containing class-name is removed from theJOW-String
.
If a parameter to aMethod
, or the type of aField
had the (fully-qualified) type-name:java.util.stream.Stream.Builder<String>
, theJOW-String
would simply have the word"Builder"
.
NOTE: If the type, itself, is an array of any kind, the array-brackets will be included in thisString
-name.Output Single-Word, Type-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..."
NOTE: You may view theStringParse
class' methodsremoveGeneric
, andtypeToJavaIdentifier
for more information.
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;
-
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.";
-
-