Class Level0Features
- java.lang.Object
-
- com.tonic.analysis.fingerprint.features.Level0Features
-
- All Implemented Interfaces:
FeatureVector
public class Level0Features extends Object implements FeatureVector
Ultra-stable fingerprint features: normalized signature shape plus called, accessed, and instantiated targets.
-
-
Constructor Summary
Constructors Constructor Description Level0Features(String returnType, int parameterCount, List<String> paramTypes, int exceptionHandlerCount, int monitorCount, Set<String> externalCallTargets, Set<String> fieldAccessTargets, Set<String> instantiatedTypes)Creates a level-0 feature set, normalizing the types and copying the target sets in sorted order.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]computeHash()Digests every extracted feature into a hash usable for equality and lookup.intgetExceptionHandlerCount()Set<String>getExternalCallTargets()Set<String>getFieldAccessTargets()Set<String>getInstantiatedTypes()intgetMonitorCount()intgetParameterCount()StringgetReturnTypeCategory()List<String>getSortedParamCategories()booleanisValid()static StringnormalizeType(String desc)Collapses a type descriptor into a coarse category: O for objects, P for primitives, V for void, with one A per array dimension prefixed.doublesimilarity(Level0Features other)Scores similarity to another level-0 feature set as a weighted mix of exact matches and Jaccard overlaps.
-
-
-
Constructor Detail
-
Level0Features
public Level0Features(String returnType, int parameterCount, List<String> paramTypes, int exceptionHandlerCount, int monitorCount, Set<String> externalCallTargets, Set<String> fieldAccessTargets, Set<String> instantiatedTypes)
Creates a level-0 feature set, normalizing the types and copying the target sets in sorted order.- Parameters:
returnType- the return type descriptorparameterCount- the number of parametersparamTypes- the parameter type descriptorsexceptionHandlerCount- the number of exception table entriesmonitorCount- the number of monitorenter/monitorexit instructionsexternalCallTargets- the called method referencesfieldAccessTargets- the accessed field referencesinstantiatedTypes- the class names created with new
-
-
Method Detail
-
normalizeType
public static String normalizeType(String desc)
Collapses a type descriptor into a coarse category: O for objects, P for primitives, V for void, with one A per array dimension prefixed.- Parameters:
desc- the type descriptor; null or empty is treated as void- Returns:
- the category string
-
computeHash
public byte[] computeHash()
Description copied from interface:FeatureVectorDigests every extracted feature into a hash usable for equality and lookup.- Specified by:
computeHashin interfaceFeatureVector- Returns:
- the digest bytes
-
isValid
public boolean isValid()
- Specified by:
isValidin interfaceFeatureVector- Returns:
- true if extraction produced features that can be matched against
-
similarity
public double similarity(Level0Features other)
Scores similarity to another level-0 feature set as a weighted mix of exact matches and Jaccard overlaps.- Parameters:
other- the feature set to compare against- Returns:
- a score in [0, 1], 0 if other is null
-
getReturnTypeCategory
public String getReturnTypeCategory()
- Returns:
- the return type category
-
getParameterCount
public int getParameterCount()
- Returns:
- the parameter count
-
getSortedParamCategories
public List<String> getSortedParamCategories()
- Returns:
- an unmodifiable view of the normalized parameter categories, sorted
-
getExceptionHandlerCount
public int getExceptionHandlerCount()
- Returns:
- the exception handler count
-
getMonitorCount
public int getMonitorCount()
- Returns:
- the monitor count
-
getExternalCallTargets
public Set<String> getExternalCallTargets()
- Returns:
- an unmodifiable view of the called method references
-
getFieldAccessTargets
public Set<String> getFieldAccessTargets()
- Returns:
- an unmodifiable view of the accessed field references
-
-