source: trunk/src/org/expeditee/agents/SpellcheckTree.java@ 636

Last change on this file since 636 was 376, checked in by ra33, 16 years ago
File size: 1.2 KB
Line 
1package org.expeditee.agents;
2
3import java.io.FileNotFoundException;
4import java.io.IOException;
5
6import org.expeditee.agents.wordprocessing.JSpellChecker;
7
8public class SpellcheckTree extends SearchTree {
9
10 private JSpellChecker _spellChecker = null;
11
12 public SpellcheckTree() {
13 super(null);
14
15 try {
16 _spellChecker = JSpellChecker.getInstance();
17 } catch (FileNotFoundException e) {
18 e.printStackTrace();
19 } catch (IOException e) {
20 e.printStackTrace();
21 }
22 // TODO better handle errors
23 }
24
25 @Override
26 protected String getResultSurrogate(String toSearch) {
27 if (_spellChecker == null)
28 return null;
29 _spellChecker.setText(toSearch);
30 _spellChecker.check();
31
32 String badSpelling = _spellChecker.getMisspelledWord();
33 String result = badSpelling;
34// while (badSpelling != null) {
35// _spellChecker.ignoreWord(true);
36// _spellChecker.check();
37// badSpelling = _spellChecker.getMisspelledWord();
38// if (badSpelling != null)
39// result += "," + badSpelling;
40// }
41
42 if (badSpelling == null || badSpelling.length() <= 1)
43 return null;
44
45 return "[" + result + "] " + toSearch;
46 }
47
48 @Override
49 protected String getResultsTitleSuffix() {
50 return "";
51 }
52}
Note: See TracBrowser for help on using the repository browser.