Class ClassFeatureSet

java.lang.Object
edu.umd.cs.findbugs.model.ClassFeatureSet
All Implemented Interfaces:
XMLWriteable

public class ClassFeatureSet extends Object implements XMLWriteable
Features of a class which may be used to identify it if it is renamed or modified.
Author:
David Hovemeyer
  • Field Details

    • CLASS_NAME_KEY

      public static final String CLASS_NAME_KEY
      See Also:
    • METHOD_NAME_KEY

      public static final String METHOD_NAME_KEY
      See Also:
    • CODE_LENGTH_KEY

      public static final String CODE_LENGTH_KEY
      See Also:
    • FIELD_NAME_KEY

      public static final String FIELD_NAME_KEY
      See Also:
    • MIN_CODE_LENGTH

      public static final int MIN_CODE_LENGTH
      Minimum code length required to add a CodeLength feature.
      See Also:
    • MIN_FEATURES

      public static final int MIN_FEATURES
      Minimum number of features which must be present in order to declare two classes similar.
      See Also:
    • MIN_MATCH

      public static final double MIN_MATCH
      Minimum similarity required to declare two classes similar.
      See Also:
    • EXACT_CLASS_NAME_MATCH

      public static final double EXACT_CLASS_NAME_MATCH
      Similarity of classes which don't have enough features to match exactly, but whose class names match exactly.
      See Also:
    • ELEMENT_NAME

      public static final String ELEMENT_NAME
      See Also:
    • FEATURE_ELEMENT_NAME

      public static final String FEATURE_ELEMENT_NAME
      See Also:
  • Constructor Details

    • ClassFeatureSet

      public ClassFeatureSet()
      Constructor. Creates an empty feature set.
  • Method Details

    • initialize

      public ClassFeatureSet initialize(org.apache.bcel.classfile.JavaClass javaClass)
      Initialize from given JavaClass.
      Parameters:
      javaClass - the JavaClass
      Returns:
      this object
    • getClassName

      public String getClassName()
      Returns:
      Returns the className.
    • setClassName

      public void setClassName(String className)
      Parameters:
      className - The className to set.
    • isInterface

      public boolean isInterface()
      Returns:
      Returns the isInterface.
    • setInterface

      public void setInterface(boolean isInterface)
      Parameters:
      isInterface - The isInterface to set.
    • getNumFeatures

      public int getNumFeatures()
    • addFeature

      public void addFeature(String feature)
    • featureIterator

      public Iterator<String> featureIterator()
    • hasFeature

      public boolean hasFeature(String feature)
    • transformClassName

      public static String transformClassName(String className)
      Transform a class name by stripping its package name.
      Parameters:
      className - a class name
      Returns:
      the transformed class name
    • isUnlikelyToBeRenamed

      public static boolean isUnlikelyToBeRenamed(String pkg)
      Return true if classes in the given package is unlikely to be renamed: e.g., because they are part of a public API.
      Parameters:
      pkg - the package name
      Returns:
      true if classes in the package is unlikely to be renamed
    • transformMethodSignature

      public static String transformMethodSignature(String signature)
      Transform a method signature to allow it to be compared even if any of its parameter types are moved to another package.
      Parameters:
      signature - a method signature
      Returns:
      the transformed signature
    • transformSignature

      public static String transformSignature(String signature)
      Transform a field or method parameter signature to allow it to be compared even if it is moved to another package.
      Parameters:
      signature - the signature
      Returns:
      the transformed signature
    • similarity

      public static double similarity(ClassFeatureSet a, ClassFeatureSet b)
    • similarTo

      public boolean similarTo(ClassFeatureSet other)
    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception
    • writeXML

      public void writeXML(XMLOutput xmlOutput) throws IOException
      Description copied from interface: XMLWriteable
      Write this object to given XMLOutput.
      Specified by:
      writeXML in interface XMLWriteable
      Parameters:
      xmlOutput - the XMLOutput for the document
      Throws:
      IOException