View Javadoc

1   package org.xvsm.lookup;
2   
3   import org.xvsm.interfaces.lookup.ILookup;
4   
5   /***
6    * The lookup-manager has to store implementations of the ILookup-interface
7    * ordered by a priority. This is achieved by storing them in an array of LookupTuple
8    * objects. LookupTuple contains a key and a lookup-service implementation. When sorting
9    * a LookupTuple array is this sorting done by the specified key, because the compareTo-
10   * function has been overloaded to provide this functionality.
11   * 
12   * @author Hannu-Daniel Goiss
13   */
14  public class LookupTuple implements Comparable<LookupTuple> {
15  	int key;
16  	ILookup lookup;
17  	
18  	/***
19  	 * @param key
20  	 * @param lookup
21  	 */
22  	public LookupTuple(int key, ILookup lookup) {
23  		this.key = key;
24  		this.lookup = lookup;
25  	}
26  
27  	/***
28  	 * @return the key
29  	 */
30  	public int getKey() {
31  		return key;
32  	}
33  
34  	/***
35  	 * @param key the key to set
36  	 */
37  	public void setKey(int key) {
38  		this.key = key;
39  	}
40  
41  	/***
42  	 * @return the lookup
43  	 */
44  	public ILookup getLookup() {
45  		return lookup;
46  	}
47  
48  	/***
49  	 * @param lookup the lookup to set
50  	 */
51  	public void setLookup(ILookup lookup) {
52  		this.lookup = lookup;
53  	}
54  
55  	/* (non-Javadoc)
56  	 * @see java.lang.Comparable#compareTo(java.lang.Object)
57  	 */
58  	public int compareTo(LookupTuple o) {
59  		return this.key - o.getKey();
60  	}
61  }