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
Java Parser Bridge: 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. Rather than re-write the code that can deal with / handle a list of parameters (their names and types), thisabstract class
has a few methods for handling these features, and then bothclass Constructor
, andclass Method
may 're-use' the parameter-list handling code in their own definitions.
There is a Java-Parser Library that is required to use this Package. The Java Doc Upgrader Package / Tool will not work without this'.jar'
file being placed in yourCLASSPATH
environment-variable. That'.jar'
is available here:
http://developer.torello.directory/ralphsReference/jars/javaparser-core-3.16.2.jar
There is a book available and an internet "Gitter" support web-site chat-room with some of the people involved in writing this library. There are quite a number of available jars in the "Master Jar Distribution" - but the core library jar is fully sufficient for running the tasks needed by this Java-Doc Upgrade Tool's logic.
Reflection-Classes Inheritance-Diagram
IMPORTANT:
All reflection classes above, also contain an additional (transient
, non-Serializable
) field that hooks into the native Java-Parser Library classes, providing an option for a more in-depth or complete analysis using that Library's features & extensive utilities.- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/JavaDoc/Callable.java
- Open New Browser-Tab: Torello/JavaDoc/Callable.java
-
-
Field Summary
Serializable ID Modifier and Type Field static long
serialVersionUID
Reflection & Inspection final-String(s) Modifier and Type Field protected String[]
exceptions
protected String[][]
parameterAnnotations
protected String[]
parameterNames
protected String[]
parameterTypes
protected String[]
parameterTypesJOW
-
Fields inherited from class Torello.JavaDoc.Declaration
annotations, body, entity, id, jdComment, location, modifiers, name, signature
-
-
Method Summary
Methods - Reflection: Parameter Names Modifier and Type Method String
getParameterName(int i)
String[]
getParameterNames()
void
getParameterNames(Consumer<String> acceptParamNameAsStringConsumer)
boolean
hasParameterNamed(String name)
Methods - Reflection: Parameter Types Modifier and Type Method String
getParameterType(int i)
String
getParameterType(String parameterName)
String[]
getParameterTypes()
void
getParameterTypes(Consumer<String> acceptParamTypeAsStringConsumer)
boolean
hasParameterTyped(String type)
Methods - Reflection: Parameter Types (JOW: Just One Word) Modifier and Type Method String
getParameterTypeJOW(int i)
String
getParameterTypeJOW(String parameterName)
String[]
getParameterTypesJOW()
void
getParameterTypesJOW(Consumer<String> acceptParamTypeAsStringConsumer)
boolean
hasParameterTypedJOW(String type)
Methods - Reflection: Parameter Annotations Modifier and Type Method String[][]
getParameterAnnotations()
String[]
getParameterAnnotations(int i)
String[]
getParameterAnnotations(String parameterName)
void
getParameterAnnotations(Consumer<String[]> acceptParamAnnotationAsStringConsumer)
boolean
hasAnnotatedParameters()
int
numAnnotatedParameters()
Methods - Reflection: Parameters Modifier and Type Method boolean
hasParameters()
int
numParameters()
Methods - Reflection: Exceptions Modifier and Type Method String[]
getExceptions()
void
getExceptions(Consumer<String> acceptExceptionsAsStringConsumer)
boolean
hasException(String exception)
boolean
hasExceptions()
int
numExceptions()
Methods: class java.lang.Object Modifier and Type Method String
toString()
String
toString(int flags)
-
Methods inherited from class Torello.JavaDoc.Declaration
getAnnotations, getAnnotations, getModifiers, getModifiers, hasAnnotations, hasModifier, hasModifiers, numAnnotations, numModifiers
-
-
-
-
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;
-
parameterNames
protected final java.lang.String[] parameterNames
The names of all parameters to thisMethod
orConstructor
.
NOTE: Access to the internal-arrays is restricted as'protected'
to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code'.java'
file on disk.
IMPORTANT: Thisarray
must be considered an array that is parallel to the other two arrays,parameterTypes
andparameterTypesJOW
If thisCallable
instance represents aMethod
orConstructor
that does not accept any parameters, then this field is assigned null.- See Also:
getParameterNames()
,getParameterNames(Consumer)
,hasParameterNamed(String)
,getParameterName(int)
- Code:
- Exact Field Declaration Expression:
protected final String[] parameterNames;
-
parameterTypes
protected final 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 Java Parser Library allows.
NOTE: Theprotected String[]
arrayparameterTypesJOW
reduces these types (asString's
) to a single-word. If aMethod
or aConstructor
accepted a paremeter such asjava.util.Iterable<Integer>
, and this seemed 'difficult to work with' - the entry inparameterTypesJOW
at the same array-location would contain, simply,Iterable
.
NOTE: Access to the internal-arrays is restricted as'protected'
to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code'.java'
file on disk.
IMPORTANT: Thisarray
must be considered an array that is parallel to the other two arrays,parameterNames
andparameterTypesJOW
.
If thisCallable
instance represents aMethod
orConstructor
that does not accept any parameters, then this field is assigned null.- See Also:
parameterTypesJOW
,getParameterTypes()
,getParameterTypes(Consumer)
,hasParameterTyped(String)
,getParameterType(int)
- Code:
- Exact Field Declaration Expression:
protected final String[] parameterTypes;
-
parameterTypesJOW
protected final 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[]"
NOTE: You may view theStringParse
class' methodsremoveGeneric
, andtypeToJavaIdentifier
for more information.
NOTE: Access to the internal-arrays is restricted as'protected'
to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code'.java'
file on disk.
IMPORTANT: Thisarray
must be considered an array that is parallel to the other two arrays,parameterNames
andparameterTypes
If thisCallable
instance represents aMethod
orConstructor
that does not accept any parameters, then this field is assigned null.- See Also:
parameterTypes
,getParameterTypesJOW()
,getParameterTypesJOW(Consumer)
,hasParameterTypedJOW(String)
,getParameterTypeJOW(int)
- Code:
- Exact Field Declaration Expression:
protected final String[] parameterTypesJOW;
-
parameterAnnotations
protected final 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.
Java Parser offers a variant of the standardtoString()
that is known as theLexicalPreservingPrinter
. This printer can retrieve the actual character data that may be found in the source-code file for an element in a Java Parser'AST'
(Abstract Syntax Tree). The list of annotations on a parameter (if any) will each be saved as ajava.lang.String
.
NOTE: In almost all cases (particularly in the Java HTML Library), this two-dimensional array, itself, will simply be null - since parameter annotations are somewhat uncommon - although, perhaps, some users make use of them from time to time.
ALSO: This array must be considered as a parallel array to the other arrays,'parameterNames'
and'parameterTypes'
.Item Possibility of being null parameterAnnotations
null if this Method
orConstructor
has zero argumentsparameterAnnotations[i]
Always null, unless the ith
parameter of thisCallable
was annotated with somethingparameterAnnotations[i][j]
Will never be null, (again, as long as parameterAnnotations[i]
is not null.
Note that there may be more than one annotation on a given parameter, which is the whole reason for having a second array-dimension.- See Also:
getParameterAnnotations()
,getParameterAnnotations(int)
- Code:
- Exact Field Declaration Expression:
protected final String[][] parameterAnnotations;
-
exceptions
protected final 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.
NOTE: Access to the internal-arrays is restricted as'protected'
to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code'.java'
file on disk.
If thisCallable
instance represents aMethod
orConstructor
that does have any declared throw-statements, then this field is assigned null.- See Also:
getExceptions()
,getExceptions(Consumer)
,hasException(String)
- Code:
- Exact Field Declaration Expression:
protected final String[] exceptions;
-
-
Method Detail
-
getParameterNames
public java.lang.String[] getParameterNames()
Retrieves the list ofparameterNames
as aString[]
array clone
NOTE: Access to the internal-arrays is restricted as'protected'
to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code'.java'
file on disk.- Returns:
- An instance of
String[]
that employs theclone()
method of the internal data-structure, protecting its contents. If thisCallable
instance represents aMethod
orConstructor
that does not accept any parameters, then null is returned. - See Also:
parameterNames
- Code:
- Exact Method Body:
return (parameterNames != null) ? parameterNames.clone() : null;
-
getParameterNames
public void getParameterNames (java.util.function.Consumer<java.lang.String> acceptParamNameAsStringConsumer)
Provides the list ofparameterNames
to a user-providedjava.util.function.Consumer<String>
If thisMethod
orConstructor
does not accept any parameters, this method shall exit immediately, and gracefully.
NOTE: Access to the internal-arrays is restricted as'protected'
to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code'.java'
file on disk.- Parameters:
acceptParamNameAsStringConsumer
- This should be anyjava.util.function.Consumer
that will accept a reference from theparameterNames
array, and perform whatever operations needed.- See Also:
parameterNames
- Code:
- Exact Method Body:
if (parameterNames != null) for (String parameterName : parameterNames) acceptParamNameAsStringConsumer.accept(parameterName);
-
hasParameterNamed
public boolean hasParameterNamed(java.lang.String name)
Check whether a particular'name'
has the same name as one of the parameters in the signature of thisCallable
.- Parameters:
name
- Any parameter name- Returns:
- This method will return
TRUE
if any of the parameters defined in this instance ofCallable
match the provided'name'
. If thisCallable
instance represents aMethod
orConstructor
that does not accept any parameters, then this method shall returnFALSE
, gracefully. - See Also:
parameterNames
- Code:
- Exact Method Body:
if (parameterNames != null) for (String parameterName : parameterNames) if (name.equals(parameterName)) return true; return false;
-
getParameterName
public java.lang.String getParameterName(int i)
Returns the name of theith
parameter.- Parameters:
i
- identifies which parameter is being requested.
NOTE: Unlike with Java array's, the first parameter is numbered'1'
(rather than zero), the second -'2'
, and so on and so forth.- Returns:
- The name of the
ith
parameter, as aString
. - Throws:
java.lang.IndexOutOfBoundsException
- If the value passed to'i'
is negative, zero, or greater than the number of parameters used by thisMethod
orConstructor
.- See Also:
parameterNames
- Code:
- Exact Method Body:
if (parameterNames == null) throw new IndexOutOfBoundsException( "There are no parameters accepted by the signature of the declaration for this " + this.getClass().getSimpleName() + ", " + i + " > 0" ); return parameterNames[i-1];
-
getParameterTypes
public java.lang.String[] getParameterTypes()
Retrieves the list ofparameterTypes
as aString[]
array.
NOTE: Access to the internal-arrays is restricted as'protected'
to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code'.java'
file on disk.- Returns:
- An instance of
String[]
that employs theclone()
method of the internal data-structure, protecting its contents. If thisCallable
instance represents aMethod
orConstructor
that does not accept any parameters, then null is returned. - See Also:
parameterTypes
- Code:
- Exact Method Body:
return (parameterTypes != null) ? parameterTypes.clone() : null;
-
getParameterTypes
public void getParameterTypes (java.util.function.Consumer<java.lang.String> acceptParamTypeAsStringConsumer)
Provides the list ofparameterTypes
to a user-providedjava.util.function.Consumer<String>
If thisMethod
orConstructor
does not accept any parameters, this method shall exit immediately, and gracefully.
NOTE: Access to the internal-arrays is restricted as'protected'
to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code'.java'
file on disk.- Parameters:
acceptParamTypeAsStringConsumer
- This should be anyjava.util.function.Consumer
that will accept a reference from theparameterTypes
array, and perform whatever operations needed.- See Also:
parameterTypes
- Code:
- Exact Method Body:
if (parameterTypes != null) for (String parameterType : parameterTypes) acceptParamTypeAsStringConsumer.accept(parameterType);
-
hasParameterTyped
public boolean hasParameterTyped(java.lang.String type)
Check whether a particular'type'
(as aString
) has the sameString
-value as one of the parameters in the signature of thisCallable
.- Parameters:
type
- Any fully-qualified parameter type as ajava.lang.String
- Returns:
- This method will return
TRUE
if any of the parameters defined in this instance ofCallable
have a type that matches the provided'type'
. If thisCallable
instance represents aMethod
orConstructor
that does not accept any parameters,FALSE
is returned, gracefully. - See Also:
parameterTypes
- Code:
- Exact Method Body:
if (parameterTypes != null) for (String parameterType : parameterTypes) if (type.equals(parameterType)) return true; return false;
-
getParameterType
public java.lang.String getParameterType(int i)
Returns the type of theith
parameter.- Parameters:
i
- identifies which parameter whose type is being requested.
NOTE: Unlike with Java array's, the first parameter is numbered'1'
(rather than zero), the second -'2'
, and so on and so forth.- Returns:
- The fully-qualified type of the
ith
parameter, as aString
. - Throws:
java.lang.IndexOutOfBoundsException
- If the value passed to'i'
is negative, zero, or greater than the number of parameters used by thisMethod
orConstructor
.- See Also:
parameterTypes
- Code:
- Exact Method Body:
if (parameterTypes == null) throw new IndexOutOfBoundsException( "There are no parameters accepted by the signature of the declaration for this " + this.getClass().getSimpleName() + ", " + i + " > 0" ); return parameterTypes[i-1];
-
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.length; i++) if (parameterNames[i].equals(parameterName)) return parameterTypes[i]; return null;
-
getParameterTypesJOW
public java.lang.String[] getParameterTypesJOW()
Retrieves the list ofparameterTypesJOW
as aString[]
array. Each type in thisString
-array will be just a single-word - the name of theclass, interface, enum,
orrecord
.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.
NOTE: Access to the internal-arrays is restricted as'protected'
to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code'.java'
file on disk.- Returns:
- An instance of
String[]
that employs theclone()
method of the internal data-structure, protecting its contents. If thisCallable
instance represents aMethod
orConstructor
that does not accept any parameters, then null is returned. - See Also:
parameterTypesJOW
,parameterTypes
- Code:
- Exact Method Body:
return (parameterTypesJOW != null) ? parameterTypesJOW.clone() : null;
-
getParameterTypesJOW
public void getParameterTypesJOW (java.util.function.Consumer<java.lang.String> acceptParamTypeAsStringConsumer)
Provides the list ofparameterTypesJOW
to a user-providedjava.util.function.Consumer<String>
If thisMethod
orConstructor
does not accept any parameters, this method shall exit immediately, and gracefully.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.
NOTE: Access to the internal-arrays is restricted as'protected'
to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code'.java'
file on disk.- Parameters:
acceptParamTypeAsStringConsumer
- This should be anyjava.util.function.Consumer
that will accept a reference from theparameterTypesJOW
array, and perform whatever operations needed.- See Also:
parameterTypesJOW
,parameterTypes
- Code:
- Exact Method Body:
if (parameterTypesJOW != null) for (String parameterTypeJOW : parameterTypesJOW) acceptParamTypeAsStringConsumer.accept(parameterTypeJOW);
-
hasParameterTypedJOW
public boolean hasParameterTypedJOW(java.lang.String type)
Check whether a particular'type'
(as aString
) has the sameString
-value as one of the parameters in the signature of thisCallable
.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:
type
- Any, just-one-word, parameter type as ajava.lang.String
.- Returns:
- This method will return
TRUE
if any of the parameters defined in this instance ofCallable
have a type whose-name matches the provided'type'
.
If thisCallable
represents aMethod
orConstructor
that does not accept any parameters, this method shall returnFALSE
, gracefully. - See Also:
parameterTypesJOW
,parameterTypes
- Code:
- Exact Method Body:
if (parameterTypesJOW != null) for (String parameterTypeJOW : parameterTypesJOW) if (type.equals(parameterTypeJOW)) return true; return false;
-
getParameterTypeJOW
public java.lang.String getParameterTypeJOW(int i)
Returns the type of theith
parameter.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:
i
- identifies which parameter whose type is being requested.
NOTE: Unlike with Java array's, the first parameter is numbered'1'
(rather than zero), the second -'2'
, and so on and so forth.- Returns:
- The one-word type-name of the
ith
parameter, as aString
. - Throws:
java.lang.IndexOutOfBoundsException
- If the value passed to'i'
is negative, zero, or greater than the number of parameters used by thisMethod
orConstructor
.- See Also:
parameterTypesJOW
,parameterTypes
- Code:
- Exact Method Body:
if (parameterTypesJOW == null) throw new IndexOutOfBoundsException( "There are no parameters accepted by the signature of the declaration for this " + this.getClass().getSimpleName() + ", " + i + " > 0" ); return parameterTypesJOW[i-1]; // May also throw IOOBEX
-
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.length; i++) if (parameterNames[i].equals(parameterName)) return parameterTypesJOW[i]; return null;
-
getParameterAnnotations
public java.lang.String[][] getParameterAnnotations()
Returns a clone of the internal two-dimensionalparameterAnnotations
array.
The length of this array will be precisely equal to the number of parameters that were ascribed to thisCallable
- which is how many parameters are used when calling thisMethod
orConstructor
. This means that the "first order" of this two-dimensionalString
array will never be null.
The "second order" of this two-dimensionalString
array, however, can contain nulls. For every parameter that was not annotated with anything, it's respective place in the array will be null! (Note that this means in likely99.99%
of situations, calling this method with simply return aString
array that if filled with nulls, since annotated parameters are not very common)
NOTE: The value returned by this method may also be null. If this method (getParameterAnnotations
) is invoked on aCallable
instanc whose signature doesn't have any parameters in the first place, then the "first order" of this two-dimensional array will be null (this method returns null in this case).
NOTE: Access to the internal-arrays is restricted as'protected'
to prevent any accidental or intentional changing of the values. This is to ensure that the contents of this class are always consistent with the source-code'.java'
file on disk.- Returns:
- A clone of the
parameterAnnotations
array. If thisCallable
instance represents aMethod
orConstructor
that does not accept any parameters, then null is returned. - See Also:
parameterAnnotations
- Code:
- Exact Method Body:
if (parameterAnnotations == null) return null; String[][] ret = new String[parameterAnnotations.length][]; for (int i=0; i < ret.length; i++) ret[i] = (parameterAnnotations[i] == null) ? null : parameterAnnotations[i].clone(); return ret;
-
getParameterAnnotations
public java.lang.String[] getParameterAnnotations(int i)
Returns the list of annotations (if any) that were ascribed to theith
parameter of thisMethod
orConstructor
.- Parameters:
i
- identifies which parameter whose annotations list is being requested.
NOTE: Unlike Java array's, the first parameter is numbered'1'
(rather than zero), the second -'2'
, and so on and so forth.- Returns:
- The list of annotations that were placed on the
ith
parameter, as aString[]
array.
IMPORTANT: This method will return null if there weren't any annotations placed on the parameter in the source-code, rather than a zero-lengthString[]
array.
SANITY CHECK: Since most parameters to a method or constructor aren't annotated with anything, invoking this method will usually get you a null return value. - Throws:
java.lang.IndexOutOfBoundsException
- If the value passed to'i'
is negative, zero, or greater than the number of parameters used by thisMethod
orConstructor
.- See Also:
parameterAnnotations
- Code:
- Exact Method Body:
if (parameterAnnotations == null) throw new IndexOutOfBoundsException( "There are no parameters accepted by the signature of the declaration for this " + this.getClass().getSimpleName() + ", " + i + " > 0" ); return parameterAnnotations[i-1]; // Also may throw IOOBEX
-
getParameterAnnotations
public void getParameterAnnotations (java.util.function.Consumer<java.lang.String[]> acceptParamAnnotationAsStringConsumer)
Provides the list ofparameterAnnotations
to a user-providedjava.util.function.Consumer<String[]>
NOTE: Since any number of annotations may adorn each and every parameter in the signature of thisCallable
, thisConsumer
must accept aString[]
-Array, rather than aString
.
If thisMethod
orConstructor
does not accept any parameters, this method shall exit immediately, and gracefully.- Parameters:
acceptParamAnnotationAsStringConsumer
- This should be anyjava.util.function.Consumer
that will accept a reference from theparameterAnnotations
array, and perform whatever operations needed.- See Also:
parameterAnnotations
- Code:
- Exact Method Body:
if (parameterAnnotations != null) for (String[] parameterAnnotation : parameterAnnotations) acceptParamAnnotationAsStringConsumer.accept(parameterAnnotation);
-
getParameterAnnotations
public 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 (parameterNames == null) return null; for (int i=0; i < parameterNames.length; i++) if (parameterNames[i].equals(parameterName)) return parameterAnnotations[i]; // In the line above, if a parameter isnt annotated, that location in the // array will have a 'null' return null;
-
getExceptions
public java.lang.String[] getExceptions()
Retrieves the list ofException's
as aString[]
array. TheString's
that are returned from this method are the ones stored internally to theexceptions
String
-Array.- Returns:
- An instance of
String[]
that employs theclone()
method of the internal data-structure, protecting its contents. If thisCallable
instance represents aMethod
orConstructor
which has not declared any exception's in the'throws'
-part of itsDeclaration.signature
then this method will return null. - See Also:
exceptions
- Code:
- Exact Method Body:
return (exceptions != null) ? exceptions.clone() : null;
-
getExceptions
public void getExceptions (java.util.function.Consumer<java.lang.String> acceptExceptionsAsStringConsumer)
Provides the list ofexceptions
to a user-providedjava.util.function.Consumer<String>
If thisMethod
orConstructor
does not declar any thrown exceptions in its signature, this method exits gracefullly.- Parameters:
acceptExceptionsAsStringConsumer
- This should be anyjava.util.function.Consumer
that will accept a reference from theexceptions
array, and perform whatever operations needed.- See Also:
exceptions
- Code:
- Exact Method Body:
if (exceptions != null) for (String exception : exceptions) acceptExceptionsAsStringConsumer.accept(exception);
-
hasException
public boolean hasException(java.lang.String exception)
Check whether a particular'exception'
(or other'Throwable'
) is thrown, according to the declared-signature of thisCallable
.- Parameters:
exception
- AnyException, Error
orThrowable
name, as ajava.lang.String
- Returns:
- This method will return
TRUE
if any of theThrowables
listed in this instance ofCallable
match the provided'exception'
.
NOTE: The exceptions listed in this class are only the ones that are included in theMethod
orConstructor
Signature. This should be similar to (but not identical to) the list of Checked-Exceptions. No in-depth code-analysis is performed, as it is a nearly impossible problem to solve. Instead, when a parse is performed, the exceptions listed in the'throws'
clause of theMethod
orConstructor
being parsed placed into this class'exceptions'
array.
FINALLY: The exception-name asString
should be the simple name of the exception, which excludes the exception class' package location. (This array might haveIOException
, but notjava.io.IOException
).
Exception's may not have generic type-parameters (the Java Compiler produces a compile time error if an attempt is made to build a class that inherits'Throwable'
, and tries to specify generic type-parameters).
On the off chance that the exception is an inner-class (I've never done that, but it is allowed), the containing outer-classes should be present in the exception-name array. - See Also:
exceptions
- Code:
- Exact Method Body:
if (exceptions == null) return false; for (String e : exceptions) if (e.equals(exception)) return true; return false;
-
numParameters
public int numParameters()
Returns the array-length of the internal'parameterNames'
array, or zero if that array is null.- Returns:
- The number of parameters in the
Declaration.signature
of thisMethod
orConstructor
. - See Also:
parameterNames
- Code:
- Exact Method Body:
return (parameterNames != null) ? parameterNames.length : 0;
-
hasParameters
public boolean hasParameters()
Returns whether there were parameters parsed from the source-code file for'this'
instance of'Callable'
.- Returns:
- Whether the protected, internal
'parameterNames'
array is non-null, and has a length greater than zero. - See Also:
parameterNames
- Code:
- Exact Method Body:
return (parameterNames != null) && (parameterNames.length > 0);
-
numExceptions
public int numExceptions()
Returns the array-length of the internalexceptions
array, or simply 0 if that array is null.- Returns:
- The number of declared excepion throws in the
signature of this
Callable
- See Also:
exceptions
- Code:
- Exact Method Body:
return (exceptions == null) ? 0 : exceptions.length;
-
hasExceptions
public boolean hasExceptions()
Returns whether there were exceptions parsed from the source-code file for'this'
instance of'Callable'
.
NOTE: Only exceptions which are declared in theDeclaration.signature
of thisCallable
, inside the original source-code'.java'
file from which thisCallable
was parsed will be listed in the n this class' internal-protectedexceptions
array.- Returns:
- Whether the protected, internal
'exceptions'
array is non-null, and has a length greater than zero - See Also:
exceptions
- Code:
- Exact Method Body:
return (exceptions != null) && (exceptions.length > 0);
-
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:
if (parameterAnnotations == null) return false; for (String[] paList : parameterAnnotations) if (paList != null) return true; return false;
-
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 (String[] paList : parameterAnnotations) if (paList != null) 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.";
-
-