Package Torello.JavaDoc
Class NestedType
- java.lang.Object
-
- Torello.JavaDoc.Declaration
-
- Torello.JavaDoc.NestedType
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class NestedType extends Declaration implements java.lang.Cloneable
Java Parser Bridge: Holds all information extracted from'.java'
Source-Files regarding Nested-Types (Inner-Classes).
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.JavaDocHTMLFile
A Nested-Type may be any one of the primary types, including:Classes, Interfaces, Enum's, Annotations & Records
. This class provides some reflected information about an inner-type retrieved using Java Parser.
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/NestedType.java
- Open New Browser-Tab: Torello/JavaDoc/NestedType.java
-
-
Field Summary
Serializable ID Modifier and Type Field protected static long
serialVersionUID
CIET / Kind of Nested-Type Modifier and Type Field CIET
ciet
Reflection & Inspection final- String
'sModifier and Type Field String
fullyQualifiedName
String
nameWithContainer
String
packageName
Entity / Member Count final- int
'sModifier and Type Field int
numFields
int
numMethods
Native Source-Parser Library Reference Hooks Modifier and Type Field com.sun.source.tree.ClassTree
classTree
TypeDeclaration<?>
typeDeclaration
Protected Reflection final String[] Arrays Modifier and Type Field protected String[]
extendedTypesJOW
protected String[]
genericTypeParameters
protected String[]
implementedTypesJOW
-
Fields inherited from class Torello.JavaDoc.Declaration
annotations, body, entity, id, jdComment, location, modifiers, name, signature
-
-
Constructor Summary
Constructors Constructor NestedType(com.sun.source.tree.ClassTree ct, TreeUtils util)
-
Method Summary
Interfaces that this Nested-Type Implements Modifier and Type Method boolean
extendsType(String extendedTypeJOW)
String[]
getExtendedTypesJOW()
void
getExtendedTypesJOW(Consumer<String> acceptExtendedTypesJOWAsStringConsumer)
int
numTypesExtended()
Classes that this Nested-Type Extends Modifier and Type Method String[]
getImplementedTypesJOW()
void
getImplementedTypesJOW(Consumer<String> acceptImplementedTypesJOWAsStringConsumer)
boolean
implementsType(String implementedTypeJOW)
int
numTypesImplemented()
Generic Type-Parameter (if any) Used by this Nested-Type Modifier and Type Method String[]
getGenericTypeParameters()
void
getGenericTypeParameters(Consumer<String> acceptGenericTypeParamsAsStringConsumer)
int
numGenericTypeParameters()
Methods: interface java.lang.Cloneable Modifier and Type Method NestedType
clone()
Methods: interface java.lang.Comparable Modifier and Type Method int
compareTo(NestedType nt)
Methods: class java.lang.Object Modifier and Type Method boolean
equals(NestedType other)
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
protected 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:
protected static final long serialVersionUID = 1;
-
ciet
public final CIET ciet
Identifies whether this is a nested/inner Class, Interface, Enum, Annotation etc...- Code:
- Exact Field Declaration Expression:
public final CIET ciet;
-
packageName
public final java.lang.String packageName
The name of the package in which the enclosing-class of this nested-type is defined. This field will be null if the package was not found, or left blank as the 'default class'.- Code:
- Exact Field Declaration Expression:
public final String packageName;
-
nameWithContainer
public final java.lang.String nameWithContainer
Thename
-field (Declaration.name
) of this class uses the lone Java-Identifier (Just One Word) which identifies thisNestedClass
within the scope of the enclosing class. However,nameWithContainer
is aString
that also includes any / all enclosing-class names, each followed-by a'.'
EXAMPLE: For Javajava.util.Map.Entry<K, V>
, thenameWithContainer
would be"Map.Entry"
.
Generic Type-Parameter information is not included in thisString
, and neither is the Package-Name.- Code:
- Exact Field Declaration Expression:
public final String nameWithContainer;
-
fullyQualifiedName
public final java.lang.String fullyQualifiedName
This field is identical tonameWithContainer
, but also has the Package-Name prepended to it, if the Package-Name was present in the enclosing class''.java'
file.
EXAMPLE: For Javajava.util.Map.Entry<K, V>
, thefullyQualifiedName
would be"java.util.Map.Entry"
.- Code:
- Exact Field Declaration Expression:
public final String fullyQualifiedName;
-
numFields
public final int numFields
The number of fields that are defined in this inner-type- Code:
- Exact Field Declaration Expression:
public final int numFields;
-
numMethods
public final int numMethods
The number of methods defined in this inner-type- Code:
- Exact Field Declaration Expression:
public final int numMethods;
-
genericTypeParameters
protected final java.lang.String[] genericTypeParameters
AString[]
-Array containing the actuala text of each / any / all type parameters utilized by this nested-type.
If the inner-class being parsed werejava.util.Map.Entry<K, V>
, this array would have length 2. The twoString's
in this array would contain the single-characterString's
-"K"
and"V"
.- Code:
- Exact Field Declaration Expression:
protected final String[] genericTypeParameters;
-
implementedTypesJOW
protected final java.lang.String[] implementedTypesJOW
AString[]
-Array of the interface-names that this class implements. If this Nested-Type does not implement any interfaces, then this array will be null.
JOW: Just One Word, The type-String's
in this array are single Java-Identifiers that have had all package, container-class, and generic-parameter information removed from the type-name.
If aNestedType
implemented interfacejava.util.Iterator<HTMLNode>
, the type-String
representing it in thisString[]
-Array would simply be"Iterator"
.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.- Code:
- Exact Field Declaration Expression:
protected final String[] implementedTypesJOW;
-
extendedTypesJOW
protected final java.lang.String[] extendedTypesJOW
AString[]
-Array of the types that this class or interface extends. If this Nested-Type does not extend any classes or interfaces, then this array will be null.
Note that in Java, a class may only extend a single other class; however, an interface is permitted to extend multiple other interfaces. The reason this field is aString[]
Array, rather than a simpleString
is, as was just explained, because if a Nested-Type were an interface rather than a class, it is possible in Java for that "inner interface" to have multiple parents, rather than just one.
JOW: Just One Word, The type-String's
in this array are single Java-Identifiers that have had all package, container-class, and generic-parameter information removed from the type-name.
If aNestedType
extended classjava.util.Map.Entry<K, V>
, the type-String
representing it in thisString[]
-Array would simply be"Entry"
.- Code:
- Exact Field Declaration Expression:
protected final String[] extendedTypesJOW;
-
typeDeclaration
public final transient com.github.javaparser.ast.body.TypeDeclaration<?> typeDeclaration
Hook Reference to Java-Parser Refletion Class
Though this class offers a streamlined set of reflection features, the Native Java-Parser Library Reflection-Classes offer a near-complete set of analysis tools for just about any kind of code-analysis neccessary. If you would like your Java Doc Pages to include more analytical-information, this field is provided as a convenience for such purposes.
If a user decides to make use of the Java-Parser TypeDeclaration instance that was used to build thisNestedType
, it may be retrieved from thistransient
field.- Code:
- Exact Field Declaration Expression:
public final transient TypeDeclaration<?> typeDeclaration;
-
classTree
public final transient com.sun.source.tree.ClassTree classTree
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 Sun/OracleClassTree
instance that was used to build thisNestedType
instance, it may be retrieved from thistransient
field.- Code:
- Exact Field Declaration Expression:
public final transient ClassTree classTree;
-
-
Constructor Detail
-
NestedType
public NestedType(com.sun.source.tree.ClassTree ct, TreeUtils util)
Constructs an instance of this class,NestedType
. A parsed AST node that has been compiled by Java's Source-Parser, and the exact instance ofTreeUtils
that generated the parsed node must be passed by parameter to this constructor.- Parameters:
ct
- Any instance of a Java ASTNestedType
Node. It is required that this member / entity AST-Node is one which the Java-Compiler generated using the exact sameTreeUtils
instance also being passed by parameter here.
Any time that the Java-Compiler parses a 'NestedType' Member / Entity, that member is converted into an instance of the AST-NodeClassTree
.util
- This utility class will contain references to all of the most important instances that are used when compiling a standard Java Souce-Code ('.java'
File). In this Java-Doc Web-Page'Upgrade'
Package, whenever any'.java'
file is compiled and converted into an Abstract Syntax Tree, a new instance ofTreeUtils
will be created / generated.
Each source-file in a Java-Project will be compiled once, and converted into an instance ofTreeUtils
. Note that it is imperative that theTreeUtils
instance being passed to this method is the same instance that was used to generate theNestedType
-Node instance with this constructor-invocation.
An instance ofTreeUtils
. is always available as a member-field of the top-level classJavaDocHTMLFile.treeUtils
.
-
-
Method Detail
-
numTypesImplemented
public int numTypesImplemented()
The number of types listed among the types in the'implements'
clause of this inner-type's declaration.- Returns:
- The number of types which this
NestedType
implements - See Also:
implementedTypesJOW
- Code:
- Exact Method Body:
return (this.implementedTypesJOW != null) ? this.implementedTypesJOW.length : 0;
-
numTypesExtended
public int numTypesExtended()
The number of types listed among the types in the'extends'
clause of this inner-type's declaration.- Returns:
- The number of types which this
NestedType
extends - See Also:
extendedTypesJOW
- Code:
- Exact Method Body:
return (this.extendedTypesJOW != null) ? this.extendedTypesJOW.length : 0;
-
numGenericTypeParameters
public int numGenericTypeParameters()
The number of generic type-parameters declared by thisNestedType
. If this class is not a generic-type, then zero is returned, gracefully.- Returns:
- The number of generic type-parameters in the signature-declaration of this inner-class.
- See Also:
genericTypeParameters
- Code:
- Exact Method Body:
return (this.genericTypeParameters != null) ? this.genericTypeParameters.length : 0;
-
implementsType
public boolean implementsType(java.lang.String implementedTypeJOW)
Checks whether thisNestedType
implements a particular interface- Returns:
TRUE
, if and only if the protected-internalimplementedTypesJOW
array contains input-parameter'implementedTypeJOW'
- See Also:
implementedTypesJOW
- Code:
- Exact Method Body:
if (this.implementedTypesJOW != null) for (String type : this.implementedTypesJOW) if (type.equals(implementedTypeJOW)) return true; return false;
-
extendsType
public boolean extendsType(java.lang.String extendedTypeJOW)
A list of all types extended by thisNestedType
- Returns:
- A clone of the protected-internal
extendedTypesJOW
array. - See Also:
implementedTypesJOW
- Code:
- Exact Method Body:
if (this.extendedTypesJOW != null) for (String type : this.extendedTypesJOW) if (type.equals(extendedTypeJOW)) return true; return false;
-
getGenericTypeParameters
public java.lang.String[] getGenericTypeParameters()
A list of all generic type-parameters declared by thisNestedType
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 protected-internal
genericTypeParameters
array, or null if this inner-type is not a generic-type. - Code:
- Exact Method Body:
return (this.genericTypeParameters != null) ? this.genericTypeParameters.clone() : null;
-
getImplementedTypesJOW
public java.lang.String[] getImplementedTypesJOW()
A list of all types implemented by thisNestedType
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 protected-internal
implementedTypesJOW
array, or null if this inner-type does not implement any interfaces. - See Also:
implementedTypesJOW
- Code:
- Exact Method Body:
return (this.implementedTypesJOW != null) ? this.implementedTypesJOW.clone() : null;
-
getExtendedTypesJOW
public java.lang.String[] getExtendedTypesJOW()
A list of all types extended by thisNestedType
\
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 protected-internal
extendedTypesJOW
array, or null if this inner-type does not extend any other types. - See Also:
implementedTypesJOW
- Code:
- Exact Method Body:
return (this.extendedTypesJOW != null) ? this.extendedTypesJOW.clone() : null;
-
getGenericTypeParameters
public void getGenericTypeParameters (java.util.function.Consumer<java.lang.String> acceptGenericTypeParamsAsStringConsumer)
Provides the list ofgenericTypeParameters
to a user-providedjava.util.function.Consumer<String[]>
If thisMethod
orConstructor
is not a generic-type, and does not declare any generic type-parameters, this method exits 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:
acceptGenericTypeParamsAsStringConsumer
- This should be anyjava.util.function.Consumer
that will accept a reference from thegenericTypeParameters
array, and perform whatever operations needed.- See Also:
genericTypeParameters
- Code:
- Exact Method Body:
if (genericTypeParameters != null) for (String genericTypeParameter : genericTypeParameters) acceptGenericTypeParamsAsStringConsumer.accept(genericTypeParameter);
-
getExtendedTypesJOW
public void getExtendedTypesJOW (java.util.function.Consumer<java.lang.String> acceptExtendedTypesJOWAsStringConsumer)
Provides the list ofextendedTypesJOW
to a user-providedjava.util.function.Consumer<String[]>
If thisNestedType
does not extend and types, this method exits 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:
acceptExtendedTypesJOWAsStringConsumer
- This should be anyjava.util.function.Consumer
that will accept a reference from theextendedTypesJOW
array, and perform whatever operations needed.- See Also:
extendedTypesJOW
- Code:
- Exact Method Body:
if (extendedTypesJOW != null) for (String extendedTypeJOW : extendedTypesJOW) acceptExtendedTypesJOWAsStringConsumer.accept(extendedTypeJOW);
-
getImplementedTypesJOW
public void getImplementedTypesJOW (java.util.function.Consumer<java.lang.String> acceptImplementedTypesJOWAsStringConsumer)
Provides the list ofimplementedTypesJOW
to a user-providedjava.util.function.Consumer<String[]>
If thisNestedType
does not extend and types, this method exits 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:
acceptImplementedTypesJOWAsStringConsumer
- This should be anyjava.util.function.Consumer
that will accept a reference from theimplementedTypesJOW
array, and perform whatever operations needed.- See Also:
implementedTypesJOW
- Code:
- Exact Method Body:
if (implementedTypesJOW != null) for (String implementedTypeJOW : implementedTypesJOW) acceptImplementedTypesJOWAsStringConsumer.accept(implementedTypeJOW);
-
toString
public java.lang.String toString()
Generates aString
of thisnested-type
, with most information included.- Overrides:
toString
in classDeclaration
- Returns:
- A printable
String
of thisnested-type
. - See Also:
PF
,toString(int)
,StrCSV.toCSV(String[], boolean, boolean, Integer)
- Code:
- Exact Method Body:
return "Name: [" + name + "]\n" + "With Container: [" + nameWithContainer + "]\n" + "Kind: [" + ciet.toString() + "]\n" + "Signature: [" + StrPrint.abbrevEndRDSF(signature, MAX_STR_LEN, true) + "]\n" + // "Type Parameters:".length() ==> 16 (17=16+1) printedTypeParameters(17) + "Modifiers: [" + StrCSV.toCSV(modifiers, true, true, null) + "]\n" + // 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 class expects a flags that has been masked using the constant (public, static, final int
) fields of classPF
. Please view this class for more information about the flags available for modifying the return-value of thistoString()
method.- Overrides:
toString
in classDeclaration
- Parameters:
flags
- These are the toString flags from class PF ("Print Flags"). View available flags listed in classPF
.- Returns:
- A printable
String
of this method, with comment information included as well. - See Also:
StrCSV.toCSV(String[], boolean, boolean, Integer)
,toString()
,PF
- Code:
- Exact Method Body:
boolean color = (flags & UNIX_COLORS) > 0; String nameTitle = "Nested " + ciet.toString(); // 7 ==> " Name: ".length() int LEN = nameTitle.length() + 7; return printedName(nameTitle, LEN, color) + StringParse.rightSpacePad("Fully Qualified:", LEN) + '[' + fullyQualifiedName + "]\n" + StringParse.rightSpacePad("With Container:", LEN) + '[' + nameWithContainer + "]\n" + printedSignature(LEN, color) + printedTypeParameters(LEN) + printedModifiers(LEN) + printedExtendsImplements(LEN) + printedMethodField(LEN, color) + printedLocation(LEN, color, (flags & BRIEF_LOCATION) > 0) + // The previous method does not add a '\n' end to the end of the returned string // This is optional, it adds a '\n' AT THE BEGINNING if it is included printedComments(LEN, color, (flags & JAVADOC_COMMENTS) > 0);
-
clone
public NestedType clone()
Java'sinterface Cloneable
requirements. This instantiates a newNestedType
with identical fields.- Overrides:
clone
in classjava.lang.Object
- Returns:
- A new
NestedType
whose internal fields are identical to this one. A deep copy on all internal arrays is performed. New arrays are instantiated. - Code:
- Exact Method Body:
return new NestedType(this);
-
compareTo
public int compareTo(NestedType nt)
Java'sinterface Comparable<T>
requirements. This does a very simple comparison using the two nested-types's'name'
field.- Parameters:
nt
- Any otherNested-Type
to be compared to'this'
- Returns:
- An integer that fulfills Java's
interface Comparable<NestedType>, public boolean compareTo(NestedType nt)
method requirements. - Code:
- Exact Method Body:
return (this == nt) ? 0 : this.name.compareTo(nt.name);
-
equals
public boolean equals(NestedType other)
This should be called an "atypical version" of the usualequals(Object other)
method. This version of equals merely compares the name of the field defined. The presumption here is that the definition of a 'field' only has meaning - at all - inside the context of aclass, interface,
orenumerated-type
where that field is defined. Since inside any'.java'
source-code file, there may only be one field with a given name, this method shall return TRUE whenever the field being compared also has the same name.- Parameters:
other
- This may be any other field. It is strongly suggested that'other'
be a field defined in the same'.java'
source-code file as'this'
field.- Returns:
- This method returns TRUE when
'this'
instance ofField
has the same'name'
as the name-field of input-parameter'other'
- Code:
- Exact Method Body:
return this.name.equals(other.name);
-
-