org.crosswire.jsword.book.search.parse
Class CustomTokenizer

java.lang.Object
  extended by org.crosswire.jsword.book.search.parse.CustomTokenizer

public class CustomTokenizer
extends Object

Our command line parsing is a little specialized, so StringTokenizer is not up to the job. The specific problem is that there is sometimes no separator between parts of the command, and since this is specialized we also leave the results in a Vector of SearchWords.

Distribution Licence:
JSword is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
The License is available on the internet here, or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
The copyright to this program is held by it's authors.

Version:
$Id: CustomTokenizer.java,v 1.12 2005/03/10 00:09:12 dmsmith Exp $
Author:
Joe Walker [joe at eireneh dot com]
See Also:
Licence

Field Summary
private static int CHAR_COMMAND
          The type of character (see charType)
private static int CHAR_PARAM
          The type of character (see charType)
private static int CHAR_SPACE
          The type of character (see charType)
 
Constructor Summary
private CustomTokenizer()
          Prevent Instansiation
 
Method Summary
private static void addWord(List output, Map commands, String word)
          Convenience function to add a Word to the Vector being created.
private static int charType(char sought, String commands)
          What class of character is this?
private static String getSingleCharWords(Map commands)
          Convenience function to add a Word to the Vector being created.
static List tokenize(String sought, Map commands)
          Convenience method to generate a Vector of SearchWords
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHAR_PARAM

private static final int CHAR_PARAM
The type of character (see charType)

See Also:
Constant Field Values

CHAR_COMMAND

private static final int CHAR_COMMAND
The type of character (see charType)

See Also:
Constant Field Values

CHAR_SPACE

private static final int CHAR_SPACE
The type of character (see charType)

See Also:
Constant Field Values
Constructor Detail

CustomTokenizer

private CustomTokenizer()
Prevent Instansiation

Method Detail

tokenize

public static List tokenize(String sought,
                            Map commands)
                     throws BookException
Convenience method to generate a Vector of SearchWords

Parameters:
sought - The text to parse
commands - The Hashtable of SearchWords to select from
Returns:
A List of selected SearchWords
Throws:
BookException

charType

private static final int charType(char sought,
                                  String commands)
What class of character is this?

Parameters:
sought - The string to be searched for
Returns:
The chatacter class

addWord

private static void addWord(List output,
                            Map commands,
                            String word)
Convenience function to add a Word to the Vector being created.

Parameters:
output - The Vector to alter
commands - The Word source
word - The trigger to look for

getSingleCharWords

private static String getSingleCharWords(Map commands)
Convenience function to add a Word to the Vector being created.

Parameters:
commands - The Word source

Copyright ? 2003-2004