Home | History | Annotate | Download | only in jdiff
      1 package jdiff;
      2 
      3 import java.io.*;
      4 import java.util.*;
      5 
      6 /**
      7  * Class to represent any (name, type) pair such as a parameter.
      8  * Analogous to ParamType in the 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 parameter.
     12  *
     13  * See the file LICENSE.txt for copyright details.
     14  * @author Matthew Doar, mdoar (at) pobox.com
     15  */
     16 class ParamAPI implements Comparable {
     17     /** Name of the (name, type) pair. */
     18     public String name_;
     19 
     20     /** Type of the (name, type) pair. */
     21     public String type_;
     22 
     23     public ParamAPI(String name, String type) {
     24         name_ = name;
     25         type_ = type;
     26     }
     27 
     28     /** Compare two ParamAPI objects using both name and type. */
     29     public int compareTo(Object o) {
     30         ParamAPI oParamAPI = (ParamAPI)o;
     31         int comp = name_.compareTo(oParamAPI.name_);
     32         if (comp != 0)
     33             return comp;
     34         comp = type_.compareTo(oParamAPI.type_);
     35         if (comp != 0)
     36             return comp;
     37         return 0;
     38     }
     39 
     40     /**
     41      * Tests two ParamAPI objects using just the name, used by indexOf().
     42      */
     43     public boolean equals(Object o) {
     44         if (name_.compareTo(((ParamAPI)o).name_) == 0)
     45             return true;
     46         return false;
     47     }
     48 
     49     /** Used to create signatures. */
     50     public String toString() {
     51         if (type_.compareTo("void") == 0)
     52             return "";
     53         return type_;
     54     }
     55 }
     56