Package io.github.classgraph
Class ArrayTypeSignature
- java.lang.Object
-
- io.github.classgraph.ScanResultObject
-
- io.github.classgraph.HierarchicalTypeSignature
-
- io.github.classgraph.TypeSignature
-
- io.github.classgraph.ReferenceTypeSignature
-
- io.github.classgraph.ArrayTypeSignature
-
public class ArrayTypeSignature extends ReferenceTypeSignature
An array type signature.
-
-
Field Summary
Fields Modifier and Type Field Description private ArrayClassInfoarrayClassInfoArray class info.private java.lang.StringclassNameHuman-readable class name, e.g.private java.lang.Class<?>elementClassRefThe element class.private TypeSignaturenestedTypeThe nested type (anotherArrayTypeSignature, or the base element type).private java.lang.StringtypeSignatureStrThe raw type signature string for the array type.-
Fields inherited from class io.github.classgraph.HierarchicalTypeSignature
typeAnnotationInfo
-
Fields inherited from class io.github.classgraph.ScanResultObject
classRef, scanResult
-
-
Constructor Summary
Constructors Constructor Description ArrayTypeSignature(TypeSignature elementTypeSignature, int numDims, java.lang.String typeSignatureStr)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddTypeAnnotation(java.util.List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo)Add a type annotation to this type.booleanequals(java.lang.Object obj)booleanequalsIgnoringTypeParams(TypeSignature other)Compare base types, ignoring generic type parameters.protected voidfindReferencedClassNames(java.util.Set<java.lang.String> refdClassNames)Get the names of any classes referenced in the type signature.ArrayClassInfogetArrayClassInfo()Return anArrayClassInfoinstance for the array class, cast to its superclass.protected ClassInfogetClassInfo()Get theClassInfoobject for the referenced class, or null if the referenced class was not encountered during scanning (i.e.protected java.lang.StringgetClassName()The name of the class (used byScanResultObject.getClassInfo()to fetch theClassInfoobject for the class).TypeSignaturegetElementTypeSignature()Get the type signature of the innermost element type of the array.TypeSignaturegetNestedType()Get the nested type, which is anotherArrayTypeSignaturewith one dimension fewer, if this array has 2 or more dimensions, otherwise this returns the element type.intgetNumDimensions()Get the number of dimensions of the array.AnnotationInfoListgetTypeAnnotationInfo()Get a list ofAnnotationInfoobjects for the type annotations on this array type, or null if none.java.lang.StringgetTypeSignatureStr()Get the raw array type signature string, e.g.inthashCode()java.lang.Class<?>loadClass()Obtain aClass<?>reference for the array class named by thisArrayClassInfoobject.java.lang.Class<?>loadClass(boolean ignoreExceptions)Obtain aClass<?>reference for the array class named by thisArrayClassInfoobject.java.lang.Class<?>loadElementClass()Get aClass<?>reference for the array element type.java.lang.Class<?>loadElementClass(boolean ignoreExceptions)Get aClass<?>reference for the innermost array element type.(package private) static ArrayTypeSignatureparse(Parser parser, java.lang.String definingClassName)Parses the array type signature.(package private) voidsetScanResult(ScanResult scanResult)Set ScanResult backreferences in info objects after scan has completed.protected voidtoStringInternal(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, java.lang.StringBuilder buf)Render type signature to string.-
Methods inherited from class io.github.classgraph.ReferenceTypeSignature
parseClassBound, parseReferenceTypeSignature
-
Methods inherited from class io.github.classgraph.TypeSignature
findReferencedClassInfo, parse
-
Methods inherited from class io.github.classgraph.HierarchicalTypeSignature
addTypeAnnotation, toString
-
Methods inherited from class io.github.classgraph.ScanResultObject
findReferencedClassInfo, loadClass, loadClass, toString, toString, toStringWithSimpleNames
-
-
-
-
Field Detail
-
typeSignatureStr
private final java.lang.String typeSignatureStr
The raw type signature string for the array type.
-
className
private java.lang.String className
Human-readable class name, e.g. "java.lang.String[]".
-
arrayClassInfo
private ArrayClassInfo arrayClassInfo
Array class info.
-
elementClassRef
private java.lang.Class<?> elementClassRef
The element class.
-
nestedType
private final TypeSignature nestedType
The nested type (anotherArrayTypeSignature, or the base element type).
-
-
Constructor Detail
-
ArrayTypeSignature
ArrayTypeSignature(TypeSignature elementTypeSignature, int numDims, java.lang.String typeSignatureStr)
Constructor.- Parameters:
elementTypeSignature- The type signature of the array elements.numDims- The number of array dimensions.typeSignatureStr- Raw array type signature string (e.g. "[[I")
-
-
Method Detail
-
getTypeSignatureStr
public java.lang.String getTypeSignatureStr()
Get the raw array type signature string, e.g. "[[I".- Returns:
- the raw array type signature string.
-
getElementTypeSignature
public TypeSignature getElementTypeSignature()
Get the type signature of the innermost element type of the array.- Returns:
- The type signature of the innermost element type.
-
getNumDimensions
public int getNumDimensions()
Get the number of dimensions of the array.- Returns:
- The number of dimensions of the array.
-
getNestedType
public TypeSignature getNestedType()
Get the nested type, which is anotherArrayTypeSignaturewith one dimension fewer, if this array has 2 or more dimensions, otherwise this returns the element type.- Returns:
- The nested type.
-
addTypeAnnotation
protected void addTypeAnnotation(java.util.List<Classfile.TypePathNode> typePath, AnnotationInfo annotationInfo)
Description copied from class:TypeSignatureAdd a type annotation to this type.- Specified by:
addTypeAnnotationin classTypeSignature- Parameters:
typePath- The type path.annotationInfo- The annotation to add.
-
getTypeAnnotationInfo
public AnnotationInfoList getTypeAnnotationInfo()
Get a list ofAnnotationInfoobjects for the type annotations on this array type, or null if none.- Overrides:
getTypeAnnotationInfoin classTypeSignature- Returns:
- a list of
AnnotationInfoobjects for the type annotations of on this array type, or null if none. - See Also:
if you want to read for type annotations on inner (nested) dimensions of the array type.
-
getClassName
protected java.lang.String getClassName()
Description copied from class:ScanResultObjectThe name of the class (used byScanResultObject.getClassInfo()to fetch theClassInfoobject for the class).- Specified by:
getClassNamein classScanResultObject- Returns:
- The class name.
-
getClassInfo
protected ClassInfo getClassInfo()
Description copied from class:ScanResultObjectGet theClassInfoobject for the referenced class, or null if the referenced class was not encountered during scanning (i.e. no ClassInfo object was created for the class during scanning). N.B. even if this method returns null,ScanResultObject.loadClass()may be able to load the referenced class by name.- Overrides:
getClassInfoin classScanResultObject- Returns:
- The
ClassInfoobject for the referenced class.
-
getArrayClassInfo
public ArrayClassInfo getArrayClassInfo()
Return anArrayClassInfoinstance for the array class, cast to its superclass.- Returns:
- the
ArrayClassInfoinstance.
-
setScanResult
void setScanResult(ScanResult scanResult)
Description copied from class:ScanResultObjectSet ScanResult backreferences in info objects after scan has completed.- Overrides:
setScanResultin classHierarchicalTypeSignature- Parameters:
scanResult- the scan result
-
findReferencedClassNames
protected void findReferencedClassNames(java.util.Set<java.lang.String> refdClassNames)
Get the names of any classes referenced in the type signature.- Overrides:
findReferencedClassNamesin classTypeSignature- Parameters:
refdClassNames- the referenced class names.
-
loadElementClass
public java.lang.Class<?> loadElementClass(boolean ignoreExceptions)
Get aClass<?>reference for the innermost array element type. Causes the ClassLoader to load the class, if it is not already loaded.- Parameters:
ignoreExceptions- Whether or not to ignore exceptions.- Returns:
- a
Class<?>reference for the innermost array element type. Also works for arrays of primitive element type.
-
loadElementClass
public java.lang.Class<?> loadElementClass()
Get aClass<?>reference for the array element type. Causes the ClassLoader to load the element class, if it is not already loaded.- Returns:
- a
Class<?>reference for the array element type. Also works for arrays of primitive element type.
-
loadClass
public java.lang.Class<?> loadClass(boolean ignoreExceptions)
Obtain aClass<?>reference for the array class named by thisArrayClassInfoobject. Causes the ClassLoader to load the element class, if it is not already loaded.- Overrides:
loadClassin classScanResultObject- Parameters:
ignoreExceptions- Whether or not to ignore exceptions.- Returns:
- The class reference, or null, if ignoreExceptions is true and there was an exception or error loading the class.
- Throws:
java.lang.IllegalArgumentException- if ignoreExceptions is false and there were problems loading the class.
-
loadClass
public java.lang.Class<?> loadClass()
Obtain aClass<?>reference for the array class named by thisArrayClassInfoobject. Causes the ClassLoader to load the element class, if it is not already loaded.- Overrides:
loadClassin classScanResultObject- Returns:
- The class reference.
- Throws:
java.lang.IllegalArgumentException- if there were problems loading the class.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
equalsIgnoringTypeParams
public boolean equalsIgnoringTypeParams(TypeSignature other)
Description copied from class:TypeSignatureCompare base types, ignoring generic type parameters.- Specified by:
equalsIgnoringTypeParamsin classTypeSignature- Parameters:
other- the otherTypeSignatureto compare to.- Returns:
- True if the two
TypeSignatureobjects are equal, ignoring type parameters.
-
toStringInternal
protected void toStringInternal(boolean useSimpleNames, AnnotationInfoList annotationsToExclude, java.lang.StringBuilder buf)Description copied from class:HierarchicalTypeSignatureRender type signature to string.- Specified by:
toStringInternalin classHierarchicalTypeSignature- Parameters:
useSimpleNames- whether to use simple names for classes.annotationsToExclude- toplevel annotations to exclude, to eliminate duplication (toplevel annotations are both class/field/method annotations and type annotations).buf- theStringBuilderto write to.
-
parse
static ArrayTypeSignature parse(Parser parser, java.lang.String definingClassName) throws ParseException
Parses the array type signature.- Parameters:
parser- the parserdefiningClassName- the defining class name- Returns:
- the array type signature
- Throws:
ParseException- if parsing fails
-
-