devdaily home | apple | java | perl | unix | directory | blog

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

package com.swabunga.spell.event;

/**
 * 

An interface for objects which take a String as input, and iterates through * the words in the string. *

* *

* When the object is instantiated, and before the first call to next() is made, * the following methods should throw a WordNotFoundException:
* current(), * startsSentence() and replace(). *

* *

A call to next() when hasMoreWords() returns false * should throw a WordNotFoundException.

* @author Jason Height (jheight@chariot.net.au) */ public interface WordFinder { //~ Methods ................................................................. /** * This method returns the text through which the WordFinder is iterating. * The text may have been modified through calls to replace(). * * @return the (possibly modified) text being searched. */ public String getText(); /** * This method resets the text through which the WordFinder iterates. * It must also re-initialize the WordFinder. * * @param newText the new text to search. */ public void setText(String newText); /** * This method should return the Word object representing the current word * in the iteration. * This method should not affect the state of the WordFinder object. * * @return the current Word object. * @throws WordNotFoundException current word has not yet been set. */ public Word current(); /** * Tests the finder to see if any more words are available. * * @return true if more words are available. */ public boolean hasNext(); /** * This method should return the Word object representing the next word * in the iteration (the first word if next() has not yet been called.) * * @return the next Word in the iteration. * @throws WordNotFoundException search string contains no more words. */ public Word next(); /** * This method should replace the current Word object with a Word object * representing the String newWord. * * @param newWord the word to replace the current word with. * @throws WordNotFoundException current word has not yet been set. */ public void replace(String newWord); /** * @return true if the current word starts a new sentence. * @throws WordNotFoundException current word has not yet been set. */ public boolean startsSentence(); // public void setText(); }




Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
 
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com