Package jdiff
Class APIComparator
- java.lang.Object
-
- jdiff.APIComparator
-
public class APIComparator extends java.lang.ObjectThis class contains method to compare two API objects. The differences are stored in an APIDiff object. See the file LICENSE.txt for copyright details.
-
-
Constructor Summary
Constructors Constructor Description APIComparator()Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intchangedInheritance(java.lang.String oldInherit, java.lang.String newInherit)Decide if two elements changed where they were defined.booleancompareAllCtors(jdiff.ClassAPI oldClass, jdiff.ClassAPI newClass, jdiff.ClassDiff classDiff)Compare all the constructors in two classes.booleancompareAllFields(jdiff.ClassAPI oldClass, jdiff.ClassAPI newClass, jdiff.ClassDiff classDiff)Compare all the fields in two classes.booleancompareAllMethods(jdiff.ClassAPI oldClass, jdiff.ClassAPI newClass, jdiff.ClassDiff classDiff)Compare all the methods in two classes.voidcompareAPIs(API oldAPI, API newAPI)Compare two APIs.doublecompareClasses(jdiff.ClassAPI oldClass, jdiff.ClassAPI newClass, jdiff.PackageDiff pkgDiff)Compare two classes.booleancompareMethods(jdiff.MethodAPI oldMethod, jdiff.MethodAPI newMethod, jdiff.ClassDiff classDiff)Compare two methods which have the same name.doublecomparePackages(jdiff.PackageAPI oldPkg, jdiff.PackageAPI newPkg)Compare two packages.static booleandocChanged(java.lang.String oldDoc, java.lang.String newDoc)Decide if two blocks of documentation changed.static java.lang.StringlinkToClass(java.lang.String className, java.lang.String memberName, java.lang.String memberType, boolean useNew)Given the name of the class, generate a link to a relevant page.static java.lang.StringlinkToClass(jdiff.FieldAPI m, boolean useNew)Generate a link to the Javadoc page for the given field.static java.lang.StringlinkToClass(jdiff.MethodAPI m, boolean useNew)Generate a link to the Javadoc page for the given method.intnumLocalFields(java.util.List fields)Return the number of fields which are locally defined.intnumLocalMethods(java.util.List methods)Return the number of methods which are locally defined.
-
-
-
Field Detail
-
apiDiff
public APIDiff apiDiff
Top-level object representing the differences between two APIs. It is this object which is used to generate the report later on.
-
pkgDiff
public jdiff.PackageDiff pkgDiff
Package-level object representing the differences between two packages. This object is also used to determine which file to write documentation differences into.
-
-
Method Detail
-
comparePackages
public double comparePackages(jdiff.PackageAPI oldPkg, jdiff.PackageAPI newPkg)Compare two packages.
-
compareClasses
public double compareClasses(jdiff.ClassAPI oldClass, jdiff.ClassAPI newClass, jdiff.PackageDiff pkgDiff)Compare two classes. Need to compare constructors, methods and fields.
-
compareAllCtors
public boolean compareAllCtors(jdiff.ClassAPI oldClass, jdiff.ClassAPI newClass, jdiff.ClassDiff classDiff)Compare all the constructors in two classes. The compareTo method in the ConstructorAPI class acts only upon the type.
-
compareAllMethods
public boolean compareAllMethods(jdiff.ClassAPI oldClass, jdiff.ClassAPI newClass, jdiff.ClassDiff classDiff)Compare all the methods in two classes. We have to deal with the cases where: - there is only one method with a given name, but its signature changes - there is more than one method with the same name, and some of them may have signature changes The simplest way to deal with this is to make the MethodAPI comparator check the params and return type, as well as the name. This means that changing a parameter's type would cause the method to be seen as removed and added. To avoid this for the simple case, check for before recording a method as removed or added.
-
compareMethods
public boolean compareMethods(jdiff.MethodAPI oldMethod, jdiff.MethodAPI newMethod, jdiff.ClassDiff classDiff)Compare two methods which have the same name.
-
compareAllFields
public boolean compareAllFields(jdiff.ClassAPI oldClass, jdiff.ClassAPI newClass, jdiff.ClassDiff classDiff)Compare all the fields in two classes.
-
docChanged
public static boolean docChanged(java.lang.String oldDoc, java.lang.String newDoc)Decide if two blocks of documentation changed.- Returns:
- true if both are non-null and differ, or if one is null and the other is not.
-
changedInheritance
public static int changedInheritance(java.lang.String oldInherit, java.lang.String newInherit)Decide if two elements changed where they were defined.- Returns:
- 0 if both are null, or both are non-null and are the same. 1 if the oldInherit was null and newInherit is non-null. 2 if the oldInherit was non-null and newInherit is null. 3 if the oldInherit was non-null and newInherit is non-null and they differ.
-
linkToClass
public static java.lang.String linkToClass(jdiff.MethodAPI m, boolean useNew)Generate a link to the Javadoc page for the given method.
-
linkToClass
public static java.lang.String linkToClass(jdiff.FieldAPI m, boolean useNew)Generate a link to the Javadoc page for the given field.
-
linkToClass
public static java.lang.String linkToClass(java.lang.String className, java.lang.String memberName, java.lang.String memberType, boolean useNew)Given the name of the class, generate a link to a relevant page. This was originally for inheritance changes, so the JDiff page could be a class changes page, or a section in a removed or added classes table. Since there was no easy way to tell which type the link should be, it is now just a link to the relevant Javadoc page.
-
numLocalMethods
public int numLocalMethods(java.util.List methods)
Return the number of methods which are locally defined.
-
numLocalFields
public int numLocalFields(java.util.List fields)
Return the number of fields which are locally defined.
-
-