Initial revision
[old-projects.git] / ekit / com / swabunga / spell / engine / Word.java
1 package com.swabunga.spell.engine;
2
3 import java.util.Comparator;
4
5 /** The Word object holds both the string and the score.
6 * <p>This class is now immutable.
7 * </p>
8 */
9 public class Word implements Comparator {
10 private String word;
11 private int score;
12
13 public Word() {
14 }
15
16 public Word(String word, int score) {
17 this.word = word;
18 this.score = score;
19 }
20
21 /** The comparator interface*/
22 public int compare(Object o1, Object o2) {
23 if (((Word) o1).getScore() < ((Word) o2).getScore()) return -1;
24 if (((Word) o1).getScore() == ((Word) o2).getScore()) return 0;
25 return 1;
26 }
27
28 public String getWord() {
29 return word;
30 }
31
32 public int getScore() {
33 return score;
34 }
35
36 public String toString() {
37 return word;
38 }
39 }
40