net.sourceforge.sstringsearch.search
Interface Searcher

All Superinterfaces:
Serializable

public interface Searcher
extends Serializable

Project: sstringsearch
File: Searcher.java
Class: Searcher
Created: 6. mai. 2008

Description:

For performing stringsearch.

Version:
$Revision$
Author:
Kristian Andersen Email

Method Summary
 void addSearchTerm(String term, SearchingHitListener listener)
          Adds a new searchterm with a HitListener.
 long getNumberOfSearchTerms()
          Get the number of defined searchterms.
 void removeSearchTerm(String term)
          Removes a searchterm.
 void save(OutputStream outputStream)
          Serialize the finite state automata to an outputstream.
 void save(String filename)
          Convience-method to save a finite state automata to file.
 State search(Reader reader, Object... callbackArguments)
          Searches through character data provided by the reader.
 State search(Reader input, State state, Object... callbackArguments)
          Searches through character data provided by the reader.
 

Method Detail

addSearchTerm

void addSearchTerm(String term,
                   SearchingHitListener listener)
                   throws IllegalArgumentException
Adds a new searchterm with a HitListener. Use this method when you are using StringSearch.search()

Parameters:
term - The searchterm to add.
listener - The HitListener called when this searchterm is encountered.
Throws:
IllegalArgumentException
See Also:
HitListener

search

State search(Reader reader,
             Object... callbackArguments)
             throws IOException,
                    IllegalArgumentException,
                    IllegalStateException
Searches through character data provided by the reader. When one of the defined searchterms is encountered the corresponding listener is called. Requires that all searchterms are registered with a HitListener

Parameters:
reader - A reader that provides the data to search through.
callbackArguments - Arguments that may be included when calling the listener.
Returns:
The state of the finite state automata when finished. This can be used to continue searching from a previous state
Throws:
IOException - If there is a problem reading the data.
IllegalArgumentException - If any of the arguments are invalid.
IllegalStateException - If the FSA is not ready to perform search, e.g. if no searchterms are defined.

search

State search(Reader input,
             State state,
             Object... callbackArguments)
             throws IOException,
                    IllegalArgumentException,
                    IllegalStateException
Searches through character data provided by the reader. When one of the defined searchterms is encountered the corresponding listener is called. Requires that all searchterms are registered with a HitListener

Parameters:
reader - A reader that provides the data to search through.
state - The state to start from.
callbackArguments - Arguments that may be included when calling the listener.
Returns:
The state of the finite state automata when finished. This can be used to continue searching from a previous state
Throws:
IOException - If there is a problem reading the data.
IllegalArgumentException - If any of the arguments are invalid.
IllegalStateException - If the FSA is not ready to perform search, e.g. if no searchterms are defined.

removeSearchTerm

void removeSearchTerm(String term)
Removes a searchterm.

Parameters:
term - The searchterm to remove.

save

void save(OutputStream outputStream)
          throws IOException
Serialize the finite state automata to an outputstream. Useful to avoid building a static finite state automata for each run.

Parameters:
outputStream - The outputstream to write finite state automata to.
Throws:
IOException - If something goes wrong while serializing the class.

save

void save(String filename)
          throws IOException
Convience-method to save a finite state automata to file.

Parameters:
filename - The file to write finite state automata to.
Throws:
IOException - If something goes wrong while serializing the class.

getNumberOfSearchTerms

long getNumberOfSearchTerms()
Get the number of defined searchterms.

Returns:
The number of defined searchterms.


Copyright 2005-2009 Kristian Andersen. All Rights Reserved.