KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnet > Admin > RMI > ContractDesc


1 /*
2  * ContractDesc.java
3  *
4  * Created on 18. květen 2004, 14:24
5  */

6
7 package SOFA.SOFAnet.Admin.RMI;
8
9 import SOFA.SOFAnet.Repository.Contract;
10 import java.io.Serializable JavaDoc;
11
12 /**
13  *
14  * @author Ladislav Sobr
15  */

16 public class ContractDesc implements Comparable JavaDoc, Serializable JavaDoc
17 {
18   public String JavaDoc name;
19   public String JavaDoc description;
20   
21   /** Creates a new instance of ContractDesc */
22   public ContractDesc(Contract contract)
23   {
24     this.name = contract.getName();
25     this.description = contract.getDescription();
26   }
27     
28   ContractDesc(String JavaDoc name, String JavaDoc description)
29   {
30     this.name = name;
31     this.description = description;
32   }
33
34   public boolean equals(Object JavaDoc o)
35   {
36     if (this == o) return true;
37     if (o instanceof ContractDesc)
38     {
39       ContractDesc contractDesc = (ContractDesc)o;
40       return toString().compareTo(contractDesc.toString()) == 0;
41     }
42     else return false;
43   }
44
45   public int compareTo(Object JavaDoc o)
46   {
47     ContractDesc contractDesc = (ContractDesc)o;
48     return toString().compareTo(contractDesc.toString());
49   }
50
51   public String JavaDoc toString()
52   {
53     if (description.length() == 0) return name;
54     else return name + " (" + description + ")";
55   }
56 }
57
Popular Tags