~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to results/plugins/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

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