com.raritantechnologies.xml.xQuery
Class XQueryParser

java.lang.Object
  extended bycom.raritantechnologies.xml.xQuery.XQueryParser
All Implemented Interfaces:
IConfigurable, IQueryParser
Direct Known Subclasses:
MarkLogicQueryParser

public class XQueryParser
extends java.lang.Object
implements IQueryParser

QueryParser that generates an XQuery expression. Template driven: can match a set of name/value pairs with a particular XQuery template.

XML Configuration Template:
   <QueryParser class="com.raritantechnologies.xml.xPath.XQueryParser"
                   xQueryField="[ parameter field that gets the computed XQuery String ]" >

     <!-- One or more UseXQueryTemplate tags: -->
     <UseXQueryTemplate>

       <!-- Defines query or user parameters that will cause a specific XQuery template to be selected -->
       <QueryParams isAnd="[ true | false ]" >     
         <Param name="[ name of query parameter ]" >
           <ValidValues>
             <Value>[ a valid value ]</Value>
             <Value>[ another valid value ]</Value>
             <!-- etc... -->
           </ValidValues>
         </Param>

         <!-- Alternatively can use an IComparator -->
         <Param name="[ name of query parameter ]" >
           <Comparator class="[ class of com.raritantechnologies.utils.comparators.IComparator ]" >

           </Comparator>
         </Param>
       </QueryParams>

       <UserParams>
         <Param name="[ name of User parameter ]" >
           <ValidValues>
             <Value>[ a valid value ]</Value>
             <Value>[ another valid value ]</Value>
             <!-- etc... -->
           </ValidValues>
         </Param>

         <!-- Alternatively can use an IComparator -->
         <Param name="[ name of User parameter ]" >
           <Comparator class="[ class of com.raritantechnologies.utils.comparators.IComparator ]" >

           </Comparator>
         </Param>
       </UserParams>

       <XQueryTemplate >
         <![CDATA[
           XQuery Template - variables are inserted into {fieldiD} sections of the template.
         ]]>
       </XQueryTemplate>

     </UseXQueryTemplate>

     <UseXQueryTemplate>
       <!-- etc. . . -->
     </UseXQueryTemplate>

   </QueryParser>
 

Developed by Raritan Technologies Inc..

Author:
Ted Sullivan

Constructor Summary
XQueryParser()
           
 
Method Summary
 java.lang.String createQuery(OrderedMap params, java.lang.String language, ILoginInfo userInfo)
           
 java.util.List getErrors()
          Returns the errors that occurred during the translate() step.
protected  boolean haveParser(OrderedMap params, java.lang.String language, ILoginInfo userInfo)
           
 void initialize(org.w3c.dom.Element elem)
          Initializes the object from an XML tag or element.
 OrderedMap parse(OrderedMap params, ILoginInfo userInfo)
           
 OrderedMap parse(OrderedMap params, java.lang.String language, ILoginInfo userInfo)
          Translate using the input parameters if this is how the query is passed.
 void setLanguage(java.lang.String language)
           
 void setSessionID(java.lang.String sessionID)
          Allows QueryParser object to access the sessionData.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XQueryParser

public XQueryParser()
Method Detail

parse

public OrderedMap parse(OrderedMap params,
                        java.lang.String language,
                        ILoginInfo userInfo)
                 throws QueryParseException,
                        UnsupportedLanguageException
Description copied from interface: IQueryParser
Translate using the input parameters if this is how the query is passed.

Specified by:
parse in interface IQueryParser
Parameters:
params - An ordered map containing the query parameters
language - String representing the target language (e.g. VQL)
Throws:
QueryParseException
UnsupportedLanguageException

createQuery

public java.lang.String createQuery(OrderedMap params,
                                    java.lang.String language,
                                    ILoginInfo userInfo)
                             throws QueryParseException,
                                    UnsupportedLanguageException
Specified by:
createQuery in interface IQueryParser
Throws:
QueryParseException
UnsupportedLanguageException

parse

public OrderedMap parse(OrderedMap params,
                        ILoginInfo userInfo)
Specified by:
parse in interface IQueryParser

setLanguage

public void setLanguage(java.lang.String language)
Specified by:
setLanguage in interface IQueryParser

getErrors

public java.util.List getErrors()
Description copied from interface: IQueryParser
Returns the errors that occurred during the translate() step.

Specified by:
getErrors in interface IQueryParser
Returns:
the list of error(s) (if any) that occurred.

setSessionID

public void setSessionID(java.lang.String sessionID)
Description copied from interface: IQueryParser
Allows QueryParser object to access the sessionData.

Specified by:
setSessionID in interface IQueryParser

haveParser

protected boolean haveParser(OrderedMap params,
                             java.lang.String language,
                             ILoginInfo userInfo)

initialize

public void initialize(org.w3c.dom.Element elem)
Description copied from interface: IConfigurable
Initializes the object from an XML tag or element. This method is called by the Framework as part of the application initializtion. see ConfigurationManager, XMLConfigurationManager, XMLSearchFieldMapFactory, XMLSearchSourceFactory. Configurable objects that are owned or contained by other configurable objects will be initialized in by the parent object.

Specified by:
initialize in interface IQueryParser