OSDN Git Service

NeverNote 0.88.
[neighbornote/NeighborNote.git] / src / com / swabunga / spell / event / StringWordTokenizer.java
1 /*\r
2 Jazzy - a Java library for Spell Checking\r
3 Copyright (C) 2001 Mindaugas Idzelis\r
4 Full text of license can be found in LICENSE.txt\r
5 \r
6 This library is free software; you can redistribute it and/or\r
7 modify it under the terms of the GNU Lesser General Public\r
8 License as published by the Free Software Foundation; either\r
9 version 2.1 of the License, or (at your option) any later version.\r
10 \r
11 This library is distributed in the hope that it will be useful,\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
14 Lesser General Public License for more details.\r
15 \r
16 You should have received a copy of the GNU Lesser General Public\r
17 License along with this library; if not, write to the Free Software\r
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
19 */\r
20 package com.swabunga.spell.event;\r
21 \r
22 \r
23 /**\r
24  * This class tokenizes a input string.\r
25  *\r
26  * <p>\r
27  * It also allows for the string to be altered by calls to replaceWord(). The result after the spell\r
28  * checking is completed is available to the call to getContext.\r
29  * </p>\r
30  *\r
31  * @author Jason Height (jheight@chariot.net.au)\r
32  * @author Anthony Roy  (ajr@antroy.co.uk)\r
33  */\r
34 public class StringWordTokenizer extends AbstractWordTokenizer {\r
35 \r
36   //~ Constructors ............................................................\r
37 \r
38   /**\r
39    * Creates a new StringWordTokenizer object.\r
40    *\r
41    * @param s the string to tokenize.\r
42    */\r
43   public StringWordTokenizer(String s) {\r
44     super(s);\r
45   }\r
46 \r
47   /**\r
48    * Creates a new StringWordTokenizer object.\r
49    *\r
50    * @param wf the custom WordFinder to use in tokenizing. Note\r
51    * that the string to tokenize will be encapsulated within the WordFinder.\r
52    */\r
53   public StringWordTokenizer(WordFinder wf) {\r
54     super(wf);\r
55   }\r
56 \r
57   /**\r
58    * Creates a new StringWordTokenizer object.\r
59    * @param s the string to work on\r
60    * @param finder the custom WordFinder to use in tokenizing. Note\r
61    * that the string to tokenize will be encapsulated within the WordFinder.\r
62    */\r
63   public StringWordTokenizer(String s, WordFinder finder) {\r
64     super(finder);\r
65     finder.setText(s);\r
66   }\r
67 \r
68   \r
69   //~ Methods .................................................................\r
70 \r
71   /**\r
72    *\r
73    * @deprecated use getContext() instead as per the WordTokenizer\r
74    * interface specification.\r
75    * @return the final text.\r
76    */\r
77   public String getFinalText() {\r
78 \r
79     return getContext();\r
80   }\r
81 \r
82   /**\r
83    * Replace the current word in the iteration with the String s.\r
84    *\r
85    * @param s the String to replace the current word.\r
86    * @throws WordNotFoundException current word not yet set.\r
87    */\r
88   public void replaceWord(String s) {\r
89     finder.replace(s);\r
90   }\r
91 }