+++ /dev/null
-/*\r
-Jazzy - a Java library for Spell Checking\r
-Copyright (C) 2001 Mindaugas Idzelis\r
-Full text of license can be found in LICENSE.txt\r
-\r
-This library is free software; you can redistribute it and/or\r
-modify it under the terms of the GNU Lesser General Public\r
-License as published by the Free Software Foundation; either\r
-version 2.1 of the License, or (at your option) any later version.\r
-\r
-This library is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-Lesser General Public License for more details.\r
-\r
-You should have received a copy of the GNU Lesser General Public\r
-License along with this library; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
-*/\r
-//:folding=indent:\r
-package com.swabunga.spell.event;\r
-\r
-\r
-/**\r
- * A word finder for XML or HTML documents, which searches text for sequences\r
- * of letters, but ignores the text inside any tags.\r
- *\r
- * @author Anthony Roy (ajr@antroy.co.uk)\r
- */\r
-public class XMLWordFinder extends AbstractWordFinder {\r
-\r
- //~ Instance/static variables ...............................................\r
-\r
- //~ Constructors ............................................................\r
-\r
- /**\r
- * Creates a new DefaultWordFinder object.\r
- *\r
- * @param inText the text to search.\r
- */\r
- public XMLWordFinder(String inText) {\r
- super(inText);\r
- }\r
-\r
- //~ Methods .................................................................\r
-\r
- /**\r
- * This method scans the text from the end of the last word, and returns a\r
- * new Word object corresponding to the next word.\r
- *\r
- * @return the next word.\r
- * @throws WordNotFoundException search string contains no more words.\r
- */\r
- public Word next() {\r
-\r
- if (currentWord == null)\r
- throw new WordNotFoundException("No more words found.");\r
-\r
- currentWord.copy(nextWord);\r
-\r
- setSentenceIterator(currentWord);\r
-\r
- int i = currentWord.getEnd();\r
- boolean finished = false;\r
- boolean started = false;\r
-\r
- search: /* Find words. */\r
- while (i < text.length() && !finished) {\r
- if (!started && isWordChar(i)) {\r
- nextWord.setStart(i++);\r
- started = true;\r
- continue search;\r
- } else if (started) {\r
- if (isWordChar(i)) {\r
- i++;\r
- continue search;\r
- } else {\r
- nextWord.setText(text.substring(nextWord.getStart(), i));\r
- finished = true;\r
- break search;\r
- }\r
- }\r
-\r
- //Ignore things inside tags.\r
- int i2 = ignore(i, '<', '>');\r
- i = (i2 == i ? i + 1 : i2);\r
- }\r
-\r
- if (!started) {\r
- nextWord = null;\r
- } else if (!finished) {\r
- nextWord.setText(text.substring(nextWord.getStart(), i));\r
- }\r
-\r
- return currentWord;\r
- }\r
-}\r