refactory: added UI removed from core plugin.
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpdt / internal / ui / text / spelling / engine / RankedWordProposal.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11
12 package net.sourceforge.phpdt.internal.ui.text.spelling.engine;
13
14 /**
15  * Ranked word proposal for quick fix and content assist.
16  * 
17  * @since 3.0
18  */
19 public class RankedWordProposal implements Comparable {
20
21         /** The word rank */
22         private int fRank;
23
24         /** The word text */
25         private final String fText;
26
27         /**
28          * Creates a new ranked word proposal.
29          * 
30          * @param text
31          *            The text of this proposal
32          * @param rank
33          *            The rank of this proposal
34          */
35         public RankedWordProposal(final String text, final int rank) {
36                 fText = text;
37                 fRank = rank;
38         }
39
40         /*
41          * @see java.lang.Comparable#compareTo(java.lang.Object)
42          */
43         public final int compareTo(Object object) {
44
45                 final RankedWordProposal word = (RankedWordProposal) object;
46                 final int rank = word.getRank();
47
48                 if (fRank < rank)
49                         return -1;
50
51                 if (fRank > rank)
52                         return 1;
53
54                 return 0;
55         }
56
57         /*
58          * @see java.lang.Object#equals(java.lang.Object)
59          */
60         public final boolean equals(Object object) {
61
62                 if (object instanceof RankedWordProposal)
63                         return object.hashCode() == hashCode();
64
65                 return false;
66         }
67
68         /**
69          * Returns the rank of the word
70          * 
71          * @return The rank of the word
72          */
73         public final int getRank() {
74                 return fRank;
75         }
76
77         /**
78          * Returns the text of this word.
79          * 
80          * @return The text of this word
81          */
82         public final String getText() {
83                 return fText;
84         }
85
86         /*
87          * @see java.lang.Object#hashCode()
88          */
89         public final int hashCode() {
90                 return fText.hashCode();
91         }
92
93         /**
94          * Sets the rank of the word.
95          * 
96          * @param rank
97          *            The rank to set
98          */
99         public final void setRank(final int rank) {
100                 fRank = rank;
101         }
102 }