org.jafer.query.converter
Class RPNQueryConverter

java.lang.Object
  extended by org.jafer.query.converter.Converter
      extended by org.jafer.query.converter.RPNQueryConverter

public class RPNQueryConverter
extends Converter

This helper class contains all the methods to convert Z3950 RPN queries to and from Jafer Queries


Constructor Summary
RPNQueryConverter()
           
 
Method Summary
private static org.w3c.dom.Node buildConstraintModel(z3950.v3.RPNStructure structure, QueryBuilder builder)
          Builds a jafer constraint model node from the supplied rpnStructure
static z3950.v3.RPNQuery convertJaferToRPN(JaferQuery jaferQuery)
          This method converts a jafer query to the z3950.v3.RPNQuery format.
static JaferQuery convertRPNToJafer(z3950.v3.RPNQuery rpnQuery)
          This method converts a z3950.v3.RPNQuery to the JaferQuery format
private static z3950.v3.RPNStructure processAndNode(org.w3c.dom.Node node)
          Process an AND jafer query node.
static z3950.v3.RPNStructure processConstraintModelNode(org.w3c.dom.Node constraintModel)
          This method processes a constraint model Node.
private static z3950.v3.RPNStructure processNode(org.w3c.dom.Node node)
          This method processes the supplied jafer querey node and converts it to an RPN structure.
private static z3950.v3.RPNStructure processOrNode(org.w3c.dom.Node node)
          Process an OR jafer query node.
private static org.w3c.dom.Node processRPNStructure(z3950.v3.RPNStructure structure)
          This method creates a jafer query node for the supplied RPNStructure.
 
Methods inherited from class org.jafer.query.converter.Converter
findNotChild, getFirstChild, getNodeValue, getSecondChild, selectNode, selectNodeList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RPNQueryConverter

public RPNQueryConverter()
Method Detail

convertRPNToJafer

public static JaferQuery convertRPNToJafer(z3950.v3.RPNQuery rpnQuery)
                                    throws QueryException
This method converts a z3950.v3.RPNQuery to the JaferQuery format

Parameters:
rpnQuery - The z3950.v3.RPNQuery
Returns:
the constructed jafer query
Throws:
QueryException

convertJaferToRPN

public static z3950.v3.RPNQuery convertJaferToRPN(JaferQuery jaferQuery)
                                           throws QueryException
This method converts a jafer query to the z3950.v3.RPNQuery format. It expects that the jafer querie has been normalised first

Parameters:
jaferQuery - TThe jafer query to convert
Returns:
the constructed rpn query
Throws:
QueryException

processNode

private static z3950.v3.RPNStructure processNode(org.w3c.dom.Node node)
                                          throws QueryException
This method processes the supplied jafer querey node and converts it to an RPN structure. It can be called recursively to process nodes lower in the query tree.

Parameters:
node - The jafer query node to process
Returns:
The constructed RPNStructure for the node being processed
Throws:
QueryException

processAndNode

private static z3950.v3.RPNStructure processAndNode(org.w3c.dom.Node node)
                                             throws QueryException
Process an AND jafer query node. Expects the Node to have already been normalised

Parameters:
node - The AND node to process
Returns:
A constructed RPNStructure for the AND node
Throws:
QueryException

processOrNode

private static z3950.v3.RPNStructure processOrNode(org.w3c.dom.Node node)
                                            throws QueryException
Process an OR jafer query node. Expects the Node to have already been normalised

Parameters:
node - The OR node to process
Returns:
A constructed RPNStructure for the OR node
Throws:
QueryException

processConstraintModelNode

public static z3950.v3.RPNStructure processConstraintModelNode(org.w3c.dom.Node constraintModel)
                                                        throws QueryException
This method processes a constraint model Node.

Parameters:
constraintModel - The constraint model node to process
Returns:
An RPNStructure representation of the constraint
Throws:
QueryException

processRPNStructure

private static org.w3c.dom.Node processRPNStructure(z3950.v3.RPNStructure structure)
                                             throws QueryException
This method creates a jafer query node for the supplied RPNStructure. It is a recursive method that calls itself in order to process the sub RPNStructures

Parameters:
structure - The rpn structure to process
Returns:
A jafer query node representation of the structure
Throws:
QueryException

buildConstraintModel

private static org.w3c.dom.Node buildConstraintModel(z3950.v3.RPNStructure structure,
                                                     QueryBuilder builder)
                                              throws QueryException
Builds a jafer constraint model node from the supplied rpnStructure

Parameters:
structure - The structure to process
builder - Instance of a query builder to use to create the node
Returns:
The constructed constarint model node
Throws:
QueryException