1 package jdiff; 2 3 import java.io.*; 4 import java.util.*; 5 6 /** 7 * Class to represent a constructor, analogous to ConstructorDoc in the 8 * Javadoc doclet API. 9 * 10 * The method used for Collection comparison (compareTo) must make its 11 * comparison based upon everything that is known about this constructor. 12 * 13 * See the file LICENSE.txt for copyright details. 14 * @author Matthew Doar, mdoar (at) pobox.com 15 */ 16 class ConstructorAPI implements Comparable { 17 /** 18 * The type of the constructor, being all the parameter types 19 * separated by commas. 20 */ 21 public String type_ = null; 22 23 /** 24 * The exceptions thrown by this constructor, being all the exception types 25 * separated by commas. "no exceptions" if no exceptions are thrown. 26 */ 27 public String exceptions_ = "no exceptions"; 28 29 /** Modifiers for this class. */ 30 public Modifiers modifiers_; 31 32 /** The doc block, default is null. */ 33 public String doc_ = null; 34 35 /** Constructor. */ 36 public ConstructorAPI(String type, Modifiers modifiers) { 37 type_ = type; 38 modifiers_ = modifiers; 39 } 40 41 /** Compare two ConstructorAPI objects by type and modifiers. */ 42 public int compareTo(Object o) { 43 ConstructorAPI constructorAPI = (ConstructorAPI)o; 44 int comp = type_.compareTo(constructorAPI.type_); 45 if (comp != 0) 46 return comp; 47 comp = exceptions_.compareTo(constructorAPI.exceptions_); 48 if (comp != 0) 49 return comp; 50 comp = modifiers_.compareTo(constructorAPI.modifiers_); 51 if (comp != 0) 52 return comp; 53 if (APIComparator.docChanged(doc_, constructorAPI.doc_)) 54 return -1; 55 return 0; 56 } 57 58 /** 59 * Tests two constructors, using just the type, used by indexOf(). 60 */ 61 public boolean equals(Object o) { 62 if (type_.compareTo(((ConstructorAPI)o).type_) == 0) 63 return true; 64 return false; 65 } 66 } 67