KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnet > Search > SearchRequestID


1 /*
2  * SearchRequestID.java
3  *
4  * Created on 28. duben 2004, 15:50
5  */

6
7 package SOFA.SOFAnet.Search;
8
9 import java.io.Serializable JavaDoc;
10
11 /**
12  * Identification of search request.
13  * It consists of name of source node and randomly generated unique identifier.
14  *
15  * @author Ladislav Sobr
16  */

17 public class SearchRequestID implements Serializable JavaDoc
18 {
19   private int requestMark; //identification of request that this reply belongs to
20
private String JavaDoc sourceNode; //requesting node
21

22   /** Creates a new instance of SearchRequestID */
23   public SearchRequestID()
24   {
25   }
26   
27   public SearchRequestID(int requestMark, String JavaDoc sourceNode)
28   {
29     this.requestMark = requestMark;
30     this.sourceNode = sourceNode;
31   }
32   
33   public int getRequestMark()
34   {
35     return requestMark;
36   }
37
38   public String JavaDoc getSourceNode()
39   {
40     return sourceNode;
41   }
42   
43   public void setRequestMark(int requestMark)
44   {
45     this.requestMark = requestMark;
46   }
47   
48   public void setSourceNode(String JavaDoc sourceNode)
49   {
50     this.sourceNode = sourceNode;
51   }
52   
53   public boolean equals(Object JavaDoc o)
54   {
55     if (this == o) return true;
56     if (o instanceof SearchRequestID)
57     {
58       SearchRequestID anotherSearchRequestID = (SearchRequestID)o;
59       if (requestMark != anotherSearchRequestID.requestMark) return false;
60       if (sourceNode == null)
61       {
62         if (anotherSearchRequestID.sourceNode == null) return true;
63         else return false;
64       }
65       else
66       {
67         if (anotherSearchRequestID.sourceNode == null) return false;
68         return sourceNode.compareTo(anotherSearchRequestID.sourceNode) == 0;
69       }
70     }
71     else return false;
72   }
73 }
74
Popular Tags