com.fatdog.xmlEngine
Class FandO

java.lang.Object
  extended bycom.fatdog.xmlEngine.words.WordBreaker
      extended bycom.fatdog.xmlEngine.FandO
All Implemented Interfaces:
IWordHandler, XQueryParserTreeConstants

public class FandO
extends WordBreaker
implements IWordHandler, XQueryParserTreeConstants

Provides the low-level implementations for XQuery's built-in functions.

Version:
0.61
Author:
Howard Katz, howardk@fatdog.com

Field Summary
 
Fields inherited from interface com.fatdog.xmlEngine.javacc.XQueryParserTreeConstants
JJTAND, JJTATTRIBUTE, JJTATTRIBUTECONTENT, JJTCHARDATA, JJTCHARREF, JJTCONTENT, JJTDEFAULTNAMESPACEDECL, JJTDOT, JJTEMPTYTAG, JJTENCLOSEDEXPR, JJTEVERY, JJTFILTER, JJTFLWOR, JJTFOR, JJTFORLET, JJTFUNCTIONCALL, JJTGENERALCOMP, JJTIFTHENELSE, JJTINTEGERLIT, JJTLET, JJTNAMESPACEDECL, JJTNODECOMP, jjtNodeName, JJTNODETEST, JJTOR, JJTORDERBY, JJTORDERCOMP, JJTPARENS, JJTPARENT, JJTQIN, JJTQNAME, JJTRANGE, JJTRELPATH, JJTRETURN, JJTSEQ, JJTSLASHROOT, JJTSLASHSLASHROOT, JJTSOME, JJTSTARTNODE, JJTSTRINGLIT, JJTTAG, JJTTEXTTEST, JJTVALUECOMP, JJTVARIABLE, JJTVOID, JJTWHERE, JJTXMLSPACEPRESERVE, JJTXMLSPACESTRIP
 
Constructor Summary
FandO(TreeWalker walker, boolean debug)
           
 
Method Summary
 ResultList contains_word(SimpleNode path, SimpleNode wordsPlusFlag)
          Return a sequence of nodes containing the word(s) of interest.
 ResultList dispatchNamedFunction(SimpleNode node, java.lang.String name, SimpleNode args)
          The public FandO interface for built-in functions.
 void newWord(char[] word, int wordStart, int wordEnd, int parent, IntList ints)
          Supply lists of word starts and lengths for the function contains-word().
 
Methods inherited from class com.fatdog.xmlEngine.words.WordBreaker
characters, getIgnoreCase, getSearchWord, registerWordHandler, registerWordHandler, setIgnoreCase, setSearchWord, toLowerCase, toLowerCase
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FandO

public FandO(TreeWalker walker,
             boolean debug)
Method Detail

dispatchNamedFunction

public ResultList dispatchNamedFunction(SimpleNode node,
                                        java.lang.String name,
                                        SimpleNode args)
                                 throws InvalidQueryException
The public FandO interface for built-in functions.

Throws:
InvalidQueryException

contains_word

public ResultList contains_word(SimpleNode path,
                                SimpleNode wordsPlusFlag)
                         throws InvalidQueryException
Return a sequence of nodes containing the word(s) of interest.

NOTA: This is the low-level version of the contains-word() function, whose signature is :

  1. a valid XQuery location path,
  2. one or more words, separated by commas, and optionally
  3. a boolean argument. If this evaluates to true(), the query will be case-sensitive (the default is false()).

The location path argument will be evaluated to a node sequence; each node in the sequence will be inspected to see whether it contains the ANDed product of all word arguments, and returned as part of the resulting ResultList if so.

The word arguments may contain embedded whitespace and/or punctuation, which the query engine will view as additional word separators. This provides three ways of specifying word arguments: as individual words, as concatenated groups of words separated by internal whitespace and/or punctuation, or as a combination of the two.

Parameters:
path - Must evaluate to a legal XQuery location path
wordsPlusFlag - One or more words (given here as a single SimpleNode root for the query subtree, plus an optional caseIsSignificant flag).
Returns:
A ResultList object containing a node sequence satisfying the query.
Throws:
InvalidQueryException - If the argument list doesn't contain one or more words.

newWord

public void newWord(char[] word,
                    int wordStart,
                    int wordEnd,
                    int parent,
                    IntList ints)
Supply lists of word starts and lengths for the function contains-word().

FandO is a WordBreaker; WordBreaker.characters() calls this routine.

Specified by:
newWord in interface IWordHandler
Parameters:
word - A char[] array holding the word, possibly larger than the word itself
wordStart - Starting offset of the word in the array
wordEnd - Offset of the first character past the end of the word
parent - Document id index of the node in which the word is found
ints - An optional IntList you can pass indirectly to the routine via WordBreaker.characters()
See Also:
contains_word(SimpleNode,SimpleNode), IndexManager