KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jdiff > ParamAPI


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, doar@pobox.com
15  */

16 class ParamAPI implements Comparable JavaDoc {
17     /** Name of the (name, type) pair. */
18     public String JavaDoc name_;
19
20     /** Type of the (name, type) pair. */
21     public String JavaDoc type_;
22
23     public ParamAPI(String JavaDoc name, String JavaDoc type) {
24         name_ = name;
25         type_ = type;
26     }
27
28     /** Compare two ParamAPI objects using both name and type. */
29     public int compareTo(Object JavaDoc 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 JavaDoc 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 JavaDoc toString() {
51         if (type_.compareTo("void") == 0)
52             return "";
53         return type_;
54     }
55 }
56
Popular Tags